Browse Source

新增停止接口。

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

+ 35
- 9
routers/repo/aisafety.go View File

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


Loading…
Cancel
Save