Browse Source

save param

tags/v1.21.12.1
lewis 4 years ago
parent
commit
c5d0ba74f0
3 changed files with 12 additions and 6 deletions
  1. +3
    -0
      modules/auth/modelarts.go
  2. +7
    -4
      routers/repo/modelarts.go
  3. +2
    -2
      templates/repo/modelarts/trainjob/new.tmpl

+ 3
- 0
modules/auth/modelarts.go View File

@@ -24,6 +24,9 @@ type CreateModelArtsTrainJobForm struct {
PoolID string `form:"pool_id" binding:"Required"` PoolID string `form:"pool_id" binding:"Required"`
Flavor string `form:"flavor" binding:"Required"` Flavor string `form:"flavor" binding:"Required"`
Description string `form:"description"` 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 { func (f *CreateModelArtsTrainJobForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {


+ 7
- 4
routers/repo/modelarts.go View File

@@ -329,8 +329,6 @@ 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
@@ -341,6 +339,7 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm)
bootFile := form.BootFile bootFile := form.BootFile
flavorCode := form.Flavor flavorCode := form.Flavor
poolID := form.PoolID poolID := form.PoolID
isSaveParam := form.IsSaveParam
repo := ctx.Repo.Repository repo := ctx.Repo.Repository
codeLocalPath := setting.JobPath + jobName + modelarts.CodePath codeLocalPath := setting.JobPath + jobName + modelarts.CodePath
codeObsPath := "/" + setting.Bucket + modelarts.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 return
} }


if isSaveParam == "on" {
//todo: save param
}

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)
@@ -480,12 +483,12 @@ func obsMkdir(dir string) error {
func paramCheckCreateTrainJob(form auth.CreateModelArtsTrainJobForm) error { func paramCheckCreateTrainJob(form auth.CreateModelArtsTrainJobForm) error {
if !strings.HasSuffix(form.BootFile, ".py") { if !strings.HasSuffix(form.BootFile, ".py") {
log.Error("the boot file(%s) must be a python file", form.BootFile) 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{ if form.WorkServerNumber > 25 || form.WorkServerNumber < 1{
log.Error("the WorkServerNumber(%d) must be in (1,25)", form.WorkServerNumber) 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 return nil


+ 2
- 2
templates/repo/modelarts/trainjob/new.tmpl View File

@@ -215,7 +215,7 @@
</div> </div>
<div class="inline field"> <div class="inline field">
<div class="ui save checkbox"> <div class="ui save checkbox">
<input name="template" type="checkbox">
<input name="is_save_para" type="checkbox">
<label>{{.i18n.Tr "repo.modelarts.train_job.query_whether_save_parameter"}} <label>{{.i18n.Tr "repo.modelarts.train_job.query_whether_save_parameter"}}
<span> <span>
<i class="question circle icon link" data-content={{.i18n.Tr "repo.modelarts.train_job.save_helper"}} data-position="right center" data-variation="mini"></i> <i class="question circle icon link" data-content={{.i18n.Tr "repo.modelarts.train_job.save_helper"}} data-position="right center" data-variation="mini"></i>
@@ -226,7 +226,7 @@
<div class="disabled field" id="save_para"> <div class="disabled field" id="save_para">
<div class="field"> <div class="field">
<label>{{.i18n.Tr "repo.modelarts.train_job.job_parameter_name"}}</label> <label>{{.i18n.Tr "repo.modelarts.train_job.job_parameter_name"}}</label>
<input name="job_type" id="cloudbrain_job_type" value="{{.notebook_type}}" tabindex="3" autofocus maxlength="255">
<input name="parameter_template_name" id="parameter_template_name" tabindex="3" autofocus maxlength="255">
</div> </div>
<div class="field"> <div class="field">
<label for="parameter_description">{{.i18n.Tr "repo.modelarts.train_job.parameter_description"}}</label> <label for="parameter_description">{{.i18n.Tr "repo.modelarts.train_job.parameter_description"}}</label>


Loading…
Cancel
Save