diff --git a/models/cloudbrain.go b/models/cloudbrain.go index be14c633e..563ab9d06 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -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:"-"` diff --git a/modules/modelarts/modelarts.go b/modules/modelarts/modelarts.go index a0d068b56..5717d044f 100755 --- a/modules/modelarts/modelarts.go +++ b/modules/modelarts/modelarts.go @@ -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 { diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 7d1d7a3e0..7fa8c7a4f 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -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 diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index b37af704d..856826bd7 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -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) diff --git a/templates/repo/modelarts/trainjob/index.tmpl b/templates/repo/modelarts/trainjob/index.tmpl index 4337d6de8..7bc14d6a4 100755 --- a/templates/repo/modelarts/trainjob/index.tmpl +++ b/templates/repo/modelarts/trainjob/index.tmpl @@ -355,7 +355,7 @@