|
@@ -329,6 +329,8 @@ func TrainJobNew(ctx *context.Context) { |
|
|
ctx.HTML(200, tplModelArtsTrainJobNew) |
|
|
ctx.HTML(200, tplModelArtsTrainJobNew) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//todo: show the error in html |
|
|
|
|
|
//todo; param check |
|
|
func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) { |
|
|
func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) { |
|
|
ctx.Data["PageIsCloudBrain"] = true |
|
|
ctx.Data["PageIsCloudBrain"] = true |
|
|
jobName := form.JobName |
|
|
jobName := form.JobName |
|
@@ -346,6 +348,13 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) |
|
|
logObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.LogPath |
|
|
logObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.LogPath |
|
|
dataPath := "/" + setting.Bucket + "/" + setting.BasePath + path.Join(uuid[0:1], uuid[1:2]) + "/" + uuid + "/" |
|
|
dataPath := "/" + setting.Bucket + "/" + setting.BasePath + path.Join(uuid[0:1], uuid[1:2]) + "/" + uuid + "/" |
|
|
|
|
|
|
|
|
|
|
|
//param check |
|
|
|
|
|
if err := paramCheckCreateTrainJob(form); err != nil { |
|
|
|
|
|
log.Error("paramCheckCreateTrainJob failed:(%v)", err) |
|
|
|
|
|
ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobNew, &form) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if err := git.Clone(repo.RepoPath(), codeLocalPath, git.CloneRepoOptions{}); err != nil { |
|
|
if err := git.Clone(repo.RepoPath(), codeLocalPath, git.CloneRepoOptions{}); err != nil { |
|
|
log.Error("Failed to clone repository: %s (%v)", repo.FullName(), err) |
|
|
log.Error("Failed to clone repository: %s (%v)", repo.FullName(), err) |
|
|
ctx.RenderWithErr("Failed to clone repository", tplModelArtsTrainJobNew, &form) |
|
|
ctx.RenderWithErr("Failed to clone repository", tplModelArtsTrainJobNew, &form) |
|
@@ -467,3 +476,17 @@ func obsMkdir(dir string) error { |
|
|
|
|
|
|
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func paramCheckCreateTrainJob(form auth.CreateModelArtsTrainJobForm) error { |
|
|
|
|
|
if !strings.HasSuffix(form.BootFile, ".py") { |
|
|
|
|
|
log.Error("the boot file(%s) must be a python file", form.BootFile) |
|
|
|
|
|
return errors.New("the boot file is not a python file") |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if form.WorkServerNumber > 25 || form.WorkServerNumber < 1{ |
|
|
|
|
|
log.Error("the WorkServerNumber(%d) must be in (1,25)", form.WorkServerNumber) |
|
|
|
|
|
return errors.New("the WorkServerNumber(%d) must be in (1,25)") |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
|
|
} |