diff --git a/routers/repo/aisafety.go b/routers/repo/aisafety.go index dc656033b..98e102336 100644 --- a/routers/repo/aisafety.go +++ b/routers/repo/aisafety.go @@ -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") diff --git a/routers/routes/routes.go b/routers/routes/routes.go index b555a6756..851a8d017 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -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())