|
|
|
@@ -35,6 +35,8 @@ const ( |
|
|
|
tplCloudBrainBenchmarkIndex base.TplName = "repo/cloudbrain/benchmark/index" |
|
|
|
tplCloudBrainBenchmarkNew base.TplName = "repo/cloudbrain/benchmark/new" |
|
|
|
tplCloudBrainBenchmarkShow base.TplName = "repo/cloudbrain/benchmark/show" |
|
|
|
|
|
|
|
tplCloudBrainTrainJobNew base.TplName = "repo/cloudbrain/trainjob/new" |
|
|
|
) |
|
|
|
|
|
|
|
var ( |
|
|
|
@@ -187,32 +189,37 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { |
|
|
|
resourceSpecId := form.ResourceSpecId |
|
|
|
repo := ctx.Repo.Repository |
|
|
|
|
|
|
|
tasks, err := models.GetCloudbrainsByDisplayJobName(repo.ID, string(models.JobTypeDebug), displayJobName) |
|
|
|
tpl := tplCloudBrainNew |
|
|
|
if jobType == string(models.JobTypeTrain) { |
|
|
|
tpl = tplCloudBrainTrainJobNew |
|
|
|
} |
|
|
|
|
|
|
|
tasks, err := models.GetCloudbrainsByDisplayJobName(repo.ID, jobType, displayJobName) |
|
|
|
if err == nil { |
|
|
|
if len(tasks) != 0 { |
|
|
|
log.Error("the job name did already exist", ctx.Data["MsgID"]) |
|
|
|
cloudBrainNewDataPrepare(ctx) |
|
|
|
ctx.RenderWithErr("the job name did already exist", tplCloudBrainNew, &form) |
|
|
|
ctx.RenderWithErr("the job name did already exist", tpl, &form) |
|
|
|
return |
|
|
|
} |
|
|
|
} else { |
|
|
|
if !models.IsErrJobNotExist(err) { |
|
|
|
log.Error("system error, %v", err, ctx.Data["MsgID"]) |
|
|
|
cloudBrainNewDataPrepare(ctx) |
|
|
|
ctx.RenderWithErr("system error", tplCloudBrainNew, &form) |
|
|
|
ctx.RenderWithErr("system error", tpl, &form) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if !jobNamePattern.MatchString(displayJobName) { |
|
|
|
ctx.RenderWithErr(ctx.Tr("repo.cloudbrain_jobname_err"), tplCloudBrainNew, &form) |
|
|
|
ctx.RenderWithErr(ctx.Tr("repo.cloudbrain_jobname_err"), tpl, &form) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if jobType != string(models.JobTypeBenchmark) && jobType != string(models.JobTypeDebug) && jobType != string(models.JobTypeSnn4imagenet) && jobType != string(models.JobTypeBrainScore) { |
|
|
|
log.Error("jobtype error:", jobType, ctx.Data["MsgID"]) |
|
|
|
cloudBrainNewDataPrepare(ctx) |
|
|
|
ctx.RenderWithErr("jobtype error", tplCloudBrainNew, &form) |
|
|
|
ctx.RenderWithErr("jobtype error", tpl, &form) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
@@ -220,13 +227,13 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { |
|
|
|
if err != nil { |
|
|
|
log.Error("GetCloudbrainCountByUserID failed:%v", err, ctx.Data["MsgID"]) |
|
|
|
cloudBrainNewDataPrepare(ctx) |
|
|
|
ctx.RenderWithErr("system error", tplCloudBrainNew, &form) |
|
|
|
ctx.RenderWithErr("system error", tpl, &form) |
|
|
|
return |
|
|
|
} else { |
|
|
|
if count >= 1 { |
|
|
|
log.Error("the user already has running or waiting task", ctx.Data["MsgID"]) |
|
|
|
cloudBrainNewDataPrepare(ctx) |
|
|
|
ctx.RenderWithErr("you have already a running or waiting task, can not create more", tplCloudBrainNew, &form) |
|
|
|
ctx.RenderWithErr("you have already a running or waiting task, can not create more", tpl, &form) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
@@ -269,11 +276,15 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { |
|
|
|
0, 0, resourceSpecId) |
|
|
|
if err != nil { |
|
|
|
cloudBrainNewDataPrepare(ctx) |
|
|
|
ctx.RenderWithErr(err.Error(), tplCloudBrainNew, &form) |
|
|
|
ctx.RenderWithErr(err.Error(), tpl, &form) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/debugjob?debugListType=all") |
|
|
|
if jobType == string(models.JobTypeTrain) { |
|
|
|
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/modelarts/train-job?listType=all") |
|
|
|
} else { |
|
|
|
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/debugjob?debugListType=all") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func CloudBrainRestart(ctx *context.Context) { |
|
|
|
@@ -1395,3 +1406,12 @@ func BenchmarkDel(ctx *context.Context) { |
|
|
|
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/cloudbrain/benchmark") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func CloudBrainTrainJobNew(ctx *context.Context) { |
|
|
|
err := cloudBrainNewDataPrepare(ctx) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("get new train-job info failed", err) |
|
|
|
return |
|
|
|
} |
|
|
|
ctx.HTML(http.StatusOK, tplCloudBrainTrainJobNew) |
|
|
|
} |