From c5d0ba74f0a4259f7d1cd4549cf6bdc35ec1cc3a Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Thu, 1 Apr 2021 09:29:57 +0800 Subject: [PATCH] save param --- modules/auth/modelarts.go | 3 +++ routers/repo/modelarts.go | 11 +++++++---- templates/repo/modelarts/trainjob/new.tmpl | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/modules/auth/modelarts.go b/modules/auth/modelarts.go index 306b6b963..84442ce43 100755 --- a/modules/auth/modelarts.go +++ b/modules/auth/modelarts.go @@ -24,6 +24,9 @@ type CreateModelArtsTrainJobForm struct { PoolID string `form:"pool_id" binding:"Required"` Flavor string `form:"flavor" binding:"Required"` Description string `form:"description"` + IsSaveParam string `form:"is_save_para"` + ParameterTemplateName string `form:"parameter_template_name"` + PrameterDescription string `form:"parameter_description"` } func (f *CreateModelArtsTrainJobForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors { diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index 03a439709..0c442af8b 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -329,8 +329,6 @@ func TrainJobNew(ctx *context.Context) { ctx.HTML(200, tplModelArtsTrainJobNew) } -//todo: show the error in html -//todo; param check func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) { ctx.Data["PageIsCloudBrain"] = true jobName := form.JobName @@ -341,6 +339,7 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) bootFile := form.BootFile flavorCode := form.Flavor poolID := form.PoolID + isSaveParam := form.IsSaveParam repo := ctx.Repo.Repository codeLocalPath := setting.JobPath + jobName + modelarts.CodePath codeObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.CodePath @@ -355,6 +354,10 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) return } + if isSaveParam == "on" { + //todo: save param + } + if err := git.Clone(repo.RepoPath(), codeLocalPath, git.CloneRepoOptions{}); err != nil { log.Error("Failed to clone repository: %s (%v)", repo.FullName(), err) ctx.RenderWithErr("Failed to clone repository", tplModelArtsTrainJobNew, &form) @@ -480,12 +483,12 @@ func obsMkdir(dir string) error { 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") + return errors.New("启动文件必须是python文件") } 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 errors.New("计算节点数必须在1-25之间") } return nil diff --git a/templates/repo/modelarts/trainjob/new.tmpl b/templates/repo/modelarts/trainjob/new.tmpl index aeb288c5a..cd0b15195 100755 --- a/templates/repo/modelarts/trainjob/new.tmpl +++ b/templates/repo/modelarts/trainjob/new.tmpl @@ -215,7 +215,7 @@
- +