Browse Source

Merge pull request '限制云脑任务数量' (#1003) from cloudbrain_limit into V20211213.patch

Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/1003
tags/v1.21.12.1
lewis 4 years ago
parent
commit
5a09f1de21
1 changed files with 17 additions and 2 deletions
  1. +17
    -2
      routers/repo/modelarts.go

+ 17
- 2
routers/repo/modelarts.go View File

@@ -699,6 +699,21 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm)
VersionCount := modelarts.VersionCount VersionCount := modelarts.VersionCount
EngineName := form.EngineName EngineName := form.EngineName


count, err := models.GetCloudbrainTrainJobCountByUserID(ctx.User.ID)
if err != nil {
log.Error("GetCloudbrainTrainJobCountByUserID failed:%v", err, ctx.Data["MsgID"])
ErrorNewDataPrepare(ctx, form)
ctx.RenderWithErr("system error", tplModelArtsTrainJobNew, &form)
return
} else {
if count >= 1 {
log.Error("the user already has running or waiting task", ctx.Data["MsgID"])
ErrorNewDataPrepare(ctx, form)
ctx.RenderWithErr("you have already a running or waiting task, can not create more", tplModelArtsTrainJobNew, &form)
return
}
}

if err := paramCheckCreateTrainJob(form); err != nil { if err := paramCheckCreateTrainJob(form); err != nil {
log.Error("paramCheckCreateTrainJob failed:(%v)", err) log.Error("paramCheckCreateTrainJob failed:(%v)", err)
ErrorNewDataPrepare(ctx, form) ErrorNewDataPrepare(ctx, form)
@@ -872,13 +887,13 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ
count, err := models.GetCloudbrainTrainJobCountByUserID(ctx.User.ID) count, err := models.GetCloudbrainTrainJobCountByUserID(ctx.User.ID)
if err != nil { if err != nil {
log.Error("GetCloudbrainTrainJobCountByUserID failed:%v", err, ctx.Data["MsgID"]) log.Error("GetCloudbrainTrainJobCountByUserID failed:%v", err, ctx.Data["MsgID"])
cloudBrainNewDataPrepare(ctx)
VersionErrorDataPrepare(ctx, form)
ctx.RenderWithErr("system error", tplModelArtsTrainJobVersionNew, &form) ctx.RenderWithErr("system error", tplModelArtsTrainJobVersionNew, &form)
return return
} else { } else {
if count >= 1 { if count >= 1 {
log.Error("the user already has running or waiting task", ctx.Data["MsgID"]) log.Error("the user already has running or waiting task", ctx.Data["MsgID"])
cloudBrainNewDataPrepare(ctx)
VersionErrorDataPrepare(ctx, form)
ctx.RenderWithErr("you have already a running or waiting task, can not create more", tplModelArtsTrainJobVersionNew, &form) ctx.RenderWithErr("you have already a running or waiting task, can not create more", tplModelArtsTrainJobVersionNew, &form)
return return
} }


Loading…
Cancel
Save