Browse Source

提交代码。

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.22.10.1^2
zouap 3 years ago
parent
commit
bdf17495f3
2 changed files with 50 additions and 2 deletions
  1. +40
    -0
      routers/repo/aisafety.go
  2. +10
    -2
      routers/routes/routes.go

+ 40
- 0
routers/repo/aisafety.go View File

@@ -55,6 +55,46 @@ func CloudBrainAiSafetyCreateTest(ctx *context.Context) {
}
}

func GetAiSafetyTask(ctx *context.Context) {
var ID = ctx.Params(":jobid")
task, err := models.GetCloudbrainByJobIDWithDeleted(ID)
if err != nil {
log.Error("GetCloudbrainByJobID failed:" + err.Error())
ctx.NotFound(ctx.Req.URL.RequestURI(), nil)
return
}
if task.Type == models.TypeCloudBrainTwo {

} else if task.Type == models.TypeCloudBrainOne {

}
}

func isTaskFinished(status string) bool {
if status == string(models.ModelArtsTrainJobRunning) || status == string(models.ModelArtsTrainJobWaiting) {
return false
}
if status == string(models.JobWaiting) || status == string(models.JobRunning) {
return false
}

if status == string(models.ModelArtsTrainJobUnknown) || status == string(models.ModelArtsTrainJobInit) {
return false
}
if status == string(models.ModelArtsTrainJobImageCreating) || status == string(models.ModelArtsTrainJobSubmitTrying) {
return false
}
return true
}

func StopAiSafetyTask(ctx *context.Context) {

}

func DelAiSafetyTask(ctx *context.Context) {

}

func CloudBrainAiSafetyCreate(ctx *context.Context) {
ctx.Data["PageIsCloudBrain"] = true
displayJobName := ctx.Query("DisplayJobName")


+ 10
- 2
routers/routes/routes.go View File

@@ -1126,7 +1126,6 @@ func RegisterRoutes(m *macaron.Macaron) {
})
m.Get("/create", reqWechatBind, reqRepoCloudBrainWriter, repo.CloudBrainBenchmarkNew)
m.Post("/create", reqWechatBind, reqRepoCloudBrainWriter, bindIgnErr(auth.CreateCloudBrainForm{}), repo.CloudBrainBenchmarkCreate)
m.Post("/create_safetytask", reqWechatBind, reqRepoCloudBrainWriter, repo.CloudBrainAiSafetyCreate)
m.Get("/create_safetytask_test", repo.CloudBrainAiSafetyCreateTest)
m.Get("/get_child_types", repo.GetChildTypes)
})
@@ -1174,7 +1173,7 @@ func RegisterRoutes(m *macaron.Macaron) {
}, context.RepoRef())
m.Group("/modelmanage", func() {
m.Post("/create_model", repo.SaveModel)
m.Post("/create_model_convert", reqRepoModelManageWriter, repo.SaveModelConvert)
m.Post("/create_model_convert", reqWechatBind, reqRepoModelManageWriter, repo.SaveModelConvert)
m.Post("/create_new_model", repo.SaveNewNameModel)
m.Delete("/delete_model", repo.DeleteModel)
m.Post("/delete_model_convert/:id", repo.DeleteModelConvert)
@@ -1201,6 +1200,15 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Get("/downloadall", repo.DownloadMultiModelFile)
}, context.RepoRef())

m.Group("/modelsafety", func() {
m.Group("/:jobid", func() {
m.Get("", reqRepoCloudBrainWriter, repo.GetAiSafetyTask)
m.Post("/stop", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.StopAiSafetyTask)
m.Post("/del", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.DelAiSafetyTask)
m.Post("/create", reqWechatBind, reqRepoCloudBrainWriter, repo.CloudBrainAiSafetyCreate)
})
}, context.RepoRef())

m.Group("/debugjob", func() {
m.Get("", reqRepoCloudBrainReader, repo.DebugJobIndex)
}, context.RepoRef())


Loading…
Cancel
Save