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) {