Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/679 Reviewed-by: lewis <747342561@qq.com>tags/v1.21.12.1
| @@ -70,6 +70,7 @@ type Cloudbrain struct { | |||
| VersionID int64 `xorm:"INDEX DEFAULT 0"` | |||
| VersionName string | |||
| Uuid string | |||
| DatasetName string | |||
| User *User `xorm:"-"` | |||
| Repo *Repository `xorm:"-"` | |||
| @@ -195,6 +195,12 @@ func GenerateTrainJob(ctx *context.Context, req *GenerateTrainJobReq) error { | |||
| return err | |||
| } | |||
| attach, err := models.GetAttachmentByUUID(req.Uuid) | |||
| if err != nil { | |||
| log.Error("GetAttachmentByUUID(%s) failed:%v", strconv.FormatInt(jobResult.JobID, 10), err.Error()) | |||
| return nil | |||
| } | |||
| err = models.CreateCloudbrain(&models.Cloudbrain{ | |||
| Status: TransTrainJobStatus(jobResult.Status), | |||
| UserID: ctx.User.ID, | |||
| @@ -206,6 +212,7 @@ func GenerateTrainJob(ctx *context.Context, req *GenerateTrainJobReq) error { | |||
| VersionID: jobResult.VersionID, | |||
| VersionName: jobResult.VersionName, | |||
| Uuid: req.Uuid, | |||
| DatasetName: attach.Name, | |||
| }) | |||
| if err != nil { | |||
| @@ -764,15 +764,15 @@ submit_image=Submit Image | |||
| download=Download | |||
| cloudbrain=cloudbrain | |||
| cloudbrain=Cloudbrain | |||
| cloudbrain.new=New cloudbrain | |||
| cloudbrain.desc=cloudbrain | |||
| cloudbrain.desc=Cloudbrain | |||
| cloudbrain.cancel=Cancel | |||
| cloudbrain.commit_image = submit | |||
| clone_cnt=download | |||
| balance = balance | |||
| balance.total_view = total balance | |||
| balance.available = available balance: | |||
| cloudbrain.commit_image = Submit | |||
| clone_cnt=Download | |||
| balance = Balance | |||
| balance.total_view = Total Balance | |||
| balance.available = Available Balance: | |||
| cloudbrain1 = cloudbrain1 | |||
| cloudbrain2 = cloudbrain2 | |||
| cloudbrain_selection = select cloudbrain | |||
| @@ -787,7 +787,7 @@ cloudbrain_status_runtime = Running Time | |||
| modelarts.notebook=Debug Task | |||
| modelarts.train_job=Create Task | |||
| modelarts.train_job=Train Task | |||
| modelarts.train_job.new_debug= New Debug Task | |||
| modelarts.train_job.new_train=New Train Task | |||
| modelarts.train_job.config=Configuration information | |||
| @@ -35,10 +35,10 @@ const ( | |||
| tplModelArtsNew base.TplName = "repo/modelarts/new" | |||
| tplModelArtsShow base.TplName = "repo/modelarts/show" | |||
| tplModelArtsTrainJobIndex base.TplName = "repo/modelarts/trainjob/index" | |||
| tplModelArtsTrainJobNew base.TplName = "repo/modelarts/trainjob/new" | |||
| tplModelArtsTrainJobShow base.TplName = "repo/modelarts/trainjob/show" | |||
| tplModelArtsTrainJobShowModels base.TplName = "repo/modelarts/trainjob/models/index" | |||
| tplModelArtsTrainJobIndex base.TplName = "repo/modelarts/trainjob/index" | |||
| tplModelArtsTrainJobNew base.TplName = "repo/modelarts/trainjob/new" | |||
| tplModelArtsTrainJobShow base.TplName = "repo/modelarts/trainjob/show" | |||
| tplModelArtsTrainJobShowModels base.TplName = "repo/modelarts/trainjob/models/index" | |||
| ) | |||
| // MustEnableDataset check if repository enable internal cb | |||
| @@ -621,7 +621,7 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) | |||
| codeObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.CodePath | |||
| outputObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.OutputPath | |||
| 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 + uuid + "/" | |||
| //can, err := canUserCreateTrainJob(ctx.User.ID) | |||
| //if err != nil { | |||
| @@ -644,9 +644,20 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) | |||
| } | |||
| if err := git.Clone(repo.RepoPath(), codeLocalPath, git.CloneRepoOptions{}); err != nil { | |||
| log.Error("Failed to clone repository: %s (%v)", repo.FullName(), err) | |||
| log.Error("创建任务失败,任务名称已存在!: %s (%v)", repo.FullName(), err) | |||
| trainJobNewDataPrepare(ctx) | |||
| ctx.RenderWithErr("Failed to clone repository", tplModelArtsTrainJobNew, &form) | |||
| attach, err := models.GetAttachmentByUUID(uuid) | |||
| if err != nil { | |||
| log.Error("GetAttachmentByUUID(%s) failed:%v", uuid, err.Error()) | |||
| return | |||
| } | |||
| ctx.Data["bootFile"] = form.BootFile | |||
| ctx.Data["uuid"] = form.Attachment | |||
| ctx.Data["datasetName"] = attach.Name | |||
| ctx.Data["params"] = form.Params | |||
| // ctx.RenderWithErr("Failed to clone repository", tplModelArtsTrainJobNew, &form) | |||
| ctx.RenderWithErr("创建任务失败,任务名称已存在!", tplModelArtsTrainJobNew, &form) | |||
| // ctx.RenderWithErr(err, tplModelArtsTrainJobNew, &form) | |||
| return | |||
| } | |||
| @@ -756,6 +767,15 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) | |||
| if err != nil { | |||
| log.Error("GenerateTrainJob failed:%v", err.Error()) | |||
| trainJobNewDataPrepare(ctx) | |||
| attach, err := models.GetAttachmentByUUID(uuid) | |||
| if err != nil { | |||
| log.Error("GetAttachmentByUUID(%s) failed:%v", uuid, err.Error()) | |||
| return | |||
| } | |||
| ctx.Data["bootFile"] = form.BootFile | |||
| ctx.Data["uuid"] = form.Attachment | |||
| ctx.Data["datasetName"] = attach.Name | |||
| ctx.Data["params"] = form.Params | |||
| ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobNew, &form) | |||
| return | |||
| } | |||
| @@ -860,12 +880,12 @@ func TrainJobShow(ctx *context.Context) { | |||
| return | |||
| } | |||
| attach, err := models.GetAttachmentByUUID(task.Uuid) | |||
| if err != nil { | |||
| log.Error("GetAttachmentByUUID(%s) failed:%v", jobID, err.Error()) | |||
| ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobShow, nil) | |||
| return | |||
| } | |||
| // attach, err := models.GetAttachmentByUUID(task.Uuid) | |||
| // if err != nil { | |||
| // log.Error("GetAttachmentByUUID(%s) failed:%v", jobID, err.Error()) | |||
| // ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobShow, nil) | |||
| // return | |||
| // } | |||
| result, err := modelarts.GetTrainJob(jobID, strconv.FormatInt(task.VersionID, 10)) | |||
| if err != nil { | |||
| @@ -889,7 +909,7 @@ func TrainJobShow(ctx *context.Context) { | |||
| return | |||
| } | |||
| result.DatasetName = attach.Name | |||
| result.DatasetName = task.DatasetName | |||
| } | |||
| resultLogFile, resultLog, err := trainJobGetLog(jobID) | |||
| @@ -355,7 +355,7 @@ | |||
| <form id="stopForm-{{.JobID}}" action="{{$.Link}}/{{.JobID}}/stop" method="post" style="margin-left:-1px;"> | |||
| {{$.CsrfTokenHtml}} | |||
| {{if $.Permission.CanWrite $.UnitTypeCloudBrain}} | |||
| <a id="stop-model-debug-{{.JobID}}" class="ui basic {{if or (eq .Status "KILLED") (eq .Status "FAILED") (eq .Status "START_FAILED")}}disabled {{else}}blue {{end}}button" onclick="document.getElementById('stopForm-{{.JobID}}').submit();"> | |||
| <a id="stop-model-debug-{{.JobID}}" class="ui basic {{if eq .Status "KILLED" "FAILED" "START_FAILED" "KILLING"}}disabled {{else}}blue {{end}}button" onclick="document.getElementById('stopForm-{{.JobID}}').submit();"> | |||
| {{$.i18n.Tr "repo.stop"}} | |||
| </a> | |||
| {{else}} | |||
| @@ -535,7 +535,7 @@ | |||
| $('#model-delete-'+jobID).removeClass('red') | |||
| $('#model-delete-'+jobID).addClass('disabled') | |||
| } | |||
| if(status=="KILLED" || status=="FAILED"){ | |||
| if(status=="KILLED" || status=="FAILED" || status=="KILLING"){ | |||
| $('#stop-model-debug-'+jobID).removeClass('blue') | |||
| $('#stop-model-debug-'+jobID).addClass('disabled') | |||
| $('#model-delete-'+jobID).removeClass('disabled') | |||
| @@ -235,7 +235,11 @@ | |||
| </div> --> | |||
| <div class="inline unite min_title field required"> | |||
| <label>{{.i18n.Tr "repo.modelarts.train_job.start_file"}}</label> | |||
| <input style="width: 33.5%;" name="boot_file" id="trainjob_boot_file" value="" tabindex="3" autofocus required maxlength="255" > | |||
| {{if .bootFile}} | |||
| <input style="width: 33.5%;" name="boot_file" id="trainjob_boot_file" value="{{.bootFile}}" tabindex="3" autofocus required maxlength="255" > | |||
| {{else}} | |||
| <input style="width: 33.5%;" name="boot_file" id="trainjob_boot_file" value="" tabindex="3" autofocus required maxlength="255" > | |||
| {{end}} | |||
| <span> | |||
| <i class="question circle icon link" data-content={{.i18n.Tr "repo.modelarts.train_job.boot_file_helper"}} data-position="right center" data-variation="mini"></i> | |||
| </span> | |||
| @@ -244,7 +248,11 @@ | |||
| <label>{{.i18n.Tr "repo.modelarts.train_job.dataset"}}</label> | |||
| <select class="ui search dropdown width80" id="trainjob_datasets" name="attachment"> | |||
| {{range .attachments}} | |||
| <option name="attachment" value="{{.UUID}}">{{.Attachment.Name}}</option> | |||
| {{if $.uuid}} | |||
| <option name="attachment" value="{{$.uuid}}">{{$.datasetName}}</option> | |||
| {{else}} | |||
| <option name="attachment" value="{{.UUID}}">{{.Attachment.Name}}</option> | |||
| {{end}} | |||
| {{end}} | |||
| </select> | |||
| </div> | |||
| @@ -368,10 +376,10 @@ | |||
| function Add_parameter(i){ | |||
| value = '<div class="two fields width85" id= "para'+ i +'">' + | |||
| '<div class="field">' + | |||
| '<input type="text" name="shipping_first-name" placeholder={{.i18n.Tr "repo.modelarts.train_job.parameter_name"}}> ' + | |||
| '<input type="text" name="shipping_first-name" required placeholder={{.i18n.Tr "repo.modelarts.train_job.parameter_name"}}> ' + | |||
| '</div> ' + | |||
| '<div class="field"> ' + | |||
| '<input type="text" name="shipping_last-name" placeholder={{.i18n.Tr "repo.modelarts.train_job.parameter_value"}}>' + | |||
| '<input type="text" name="shipping_last-name" required placeholder={{.i18n.Tr "repo.modelarts.train_job.parameter_value"}}>' + | |||
| '</div>'+ | |||
| '<span>' + | |||
| '<i class="trash icon">' + | |||