|
|
|
@@ -105,6 +105,15 @@ func MustEnableModelArts(ctx *context.Context) { |
|
|
|
} |
|
|
|
|
|
|
|
func NotebookNew(ctx *context.Context) { |
|
|
|
err := modelartsNewDataPrepare(ctx) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("get new cloudbrain info failed", err) |
|
|
|
return |
|
|
|
} |
|
|
|
ctx.HTML(200, tplModelArtsNotebookNew) |
|
|
|
} |
|
|
|
|
|
|
|
func modelartsNewDataPrepare(ctx *context.Context) error { |
|
|
|
ctx.Data["PageIsCloudBrain"] = true |
|
|
|
|
|
|
|
t := time.Now() |
|
|
|
@@ -113,8 +122,9 @@ func NotebookNew(ctx *context.Context) { |
|
|
|
|
|
|
|
attachs, err := models.GetModelArtsUserAttachments(ctx.User.ID) |
|
|
|
if err != nil { |
|
|
|
log.Error("GetAllUserAttachments failed:", err) |
|
|
|
ctx.ServerError("GetAllUserAttachments failed:", err) |
|
|
|
return |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
ctx.Data["attachments"] = attachs |
|
|
|
@@ -125,8 +135,7 @@ func NotebookNew(ctx *context.Context) { |
|
|
|
json.Unmarshal([]byte(setting.FlavorInfos), &modelarts.FlavorInfos) |
|
|
|
} |
|
|
|
ctx.Data["flavors"] = modelarts.FlavorInfos.FlavorInfo |
|
|
|
|
|
|
|
ctx.HTML(200, tplModelArtsNotebookNew) |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
func NotebookCreate(ctx *context.Context, form auth.CreateModelArtsNotebookForm) { |
|
|
|
@@ -151,13 +160,15 @@ func NotebookCreate(ctx *context.Context, form auth.CreateModelArtsNotebookForm) |
|
|
|
for _, task := range tasks { |
|
|
|
if strings.EqualFold(task.JobName, jobName) { |
|
|
|
log.Error("the job name did already exist", ctx.Data["MsgID"]) |
|
|
|
ctx.RenderWithErr("作业名称已经被使用!", tplModelArtsNotebookNew, &form) |
|
|
|
modelartsNewDataPrepare(ctx) |
|
|
|
ctx.RenderWithErr("任务名称已经被使用!", tplModelArtsNotebookNew, &form) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
if !models.IsErrJobNotExist(err) { |
|
|
|
log.Error("system error, %v", err, ctx.Data["MsgID"]) |
|
|
|
modelartsNewDataPrepare(ctx) |
|
|
|
ctx.RenderWithErr("system error", tplModelArtsNotebookNew, &form) |
|
|
|
return |
|
|
|
} |
|
|
|
@@ -166,13 +177,13 @@ func NotebookCreate(ctx *context.Context, form auth.CreateModelArtsNotebookForm) |
|
|
|
count, err := models.GetCloudbrainNotebookCountByUserID(ctx.User.ID) |
|
|
|
if err != nil { |
|
|
|
log.Error("GetCloudbrainNotebookCountByUserID failed:%v", err, ctx.Data["MsgID"]) |
|
|
|
cloudBrainNewDataPrepare(ctx) |
|
|
|
modelartsNewDataPrepare(ctx) |
|
|
|
ctx.RenderWithErr("system error", tplModelArtsNotebookNew, &form) |
|
|
|
return |
|
|
|
} else { |
|
|
|
if count >= 1 { |
|
|
|
log.Error("the user already has running or waiting task", ctx.Data["MsgID"]) |
|
|
|
cloudBrainNewDataPrepare(ctx) |
|
|
|
modelartsNewDataPrepare(ctx) |
|
|
|
ctx.RenderWithErr("you have already a running or waiting task, can not create more", tplModelArtsNotebookNew, &form) |
|
|
|
return |
|
|
|
} |
|
|
|
@@ -822,7 +833,7 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) |
|
|
|
if strings.EqualFold(task.JobName, jobName) { |
|
|
|
log.Error("the job name did already exist", ctx.Data["MsgID"]) |
|
|
|
trainJobErrorNewDataPrepare(ctx, form) |
|
|
|
ctx.RenderWithErr("作业名称已经被使用!", tplModelArtsInferenceJobNew, &form) |
|
|
|
ctx.RenderWithErr("任务名称已经被使用!", tplModelArtsInferenceJobNew, &form) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
@@ -1660,7 +1671,7 @@ func InferenceJobCreate(ctx *context.Context, form auth.CreateModelArtsInference |
|
|
|
if strings.EqualFold(task.JobName, jobName) { |
|
|
|
log.Error("the job name did already exist", ctx.Data["MsgID"]) |
|
|
|
inferenceJobErrorNewDataPrepare(ctx, form) |
|
|
|
ctx.RenderWithErr("作业名称已经被使用!", tplModelArtsInferenceJobNew, &form) |
|
|
|
ctx.RenderWithErr("任务名称已经被使用!", tplModelArtsInferenceJobNew, &form) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|