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/routers/repo/modelarts.go b/routers/repo/modelarts.go index b37af704d..885a0e66b 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 @@ -644,9 +644,10 @@ 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) + // ctx.RenderWithErr("Failed to clone repository", tplModelArtsTrainJobNew, &form) + ctx.RenderWithErr("创建任务失败,任务名称已存在!", tplModelArtsTrainJobNew, &form) return } @@ -860,12 +861,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 +890,7 @@ func TrainJobShow(ctx *context.Context) { return } - result.DatasetName = attach.Name + result.DatasetName = task.DatasetName } resultLogFile, resultLog, err := trainJobGetLog(jobID)