From b501ebc9574df68e6e634e77ee4e38e43af239ea Mon Sep 17 00:00:00 2001 From: zouap Date: Sat, 8 Oct 2022 15:41:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=81=9C=E6=AD=A2=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/aisafety.go | 44 ++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/routers/repo/aisafety.go b/routers/repo/aisafety.go index b6cd2d603..4e9708a58 100644 --- a/routers/repo/aisafety.go +++ b/routers/repo/aisafety.go @@ -83,6 +83,40 @@ func GetAiSafetyTask(ctx *context.Context) { return } syncAiSafetyTaskStatus(job) + job, err = models.GetCloudbrainByJobIDWithDeleted(ID) + ctx.JSON(200, job) +} + +func StopAiSafetyTask(ctx *context.Context) { + +} + +func DelAiSafetyTask(ctx *context.Context) { + var ID = ctx.Params(":jobid") + task, err := models.GetCloudbrainByJobIDWithDeleted(ID) + result := make(map[string]interface{}) + result["code"] = 1 + if err != nil { + log.Error("GetCloudbrainByJobID failed:" + err.Error()) + result["msg"] = "No such task." + ctx.JSON(200, result) + return + } + if task.Status != string(models.JobStopped) && task.Status != string(models.JobFailed) && task.Status != string(models.JobSucceeded) { + log.Error("the job(%s) has not been stopped", task.JobName, ctx.Data["msgID"]) + result["msg"] = "the job(" + task.JobName + ") has not been stopped" + ctx.JSON(200, result) + return + } + err = models.DeleteJob(task) + if err != nil { + result["msg"] = err.Error() + ctx.JSON(200, result) + return + } + result["code"] = 0 + result["msg"] = "Succeed" + ctx.JSON(200, result) } func syncAiSafetyTaskStatus(job *models.Cloudbrain) { @@ -350,14 +384,6 @@ func isTaskNotFinished(status string) bool { return false } -func StopAiSafetyTask(ctx *context.Context) { - -} - -func DelAiSafetyTask(ctx *context.Context) { - -} - func AiSafetyCreateForGetGPU(ctx *context.Context) { t := time.Now() ctx.Data["PageIsCloudBrain"] = true @@ -767,7 +793,7 @@ func createForGPU(ctx *context.Context, jobName string) { ctx.RenderWithErr(err.Error(), tplCloudBrainBenchmarkNew, nil) return } - ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/cloudbrain/modelsafety_test") + //ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/cloudbrain/modelsafety_test") } func getGpuModelSafetyCommand(BootFile string, params string, CkptName string, DisplayJobName string) (string, error) {