Browse Source

Merge branch 'liuzx_trainjob' of https://git.openi.org.cn/OpenI/aiforge into liuzx_trainjob

tags/v1.21.12.1
zhoupzh 4 years ago
parent
commit
0227376db3
1 changed files with 13 additions and 12 deletions
  1. +13
    -12
      routers/repo/modelarts.go

+ 13
- 12
routers/repo/modelarts.go View File

@@ -485,20 +485,12 @@ func trainJobNewVersionDataPrepare(ctx *context.Context) error {
// ctx.ServerError("canNewJob can info failed", err)
// return err
// }
// ctx.Data["canNewJob"] = canNewJob

task, err := models.GetCloudbrainByJobIDAndVersionName(jobID, versionName)
if err != nil {
log.Error("GetCloudbrainByJobIDAndVersionName(%s) failed:%v", jobID, err.Error())
return err
}
//判断权限
canNewJob, err := canUserCreateTrainJobVersion(ctx, task.UserID)
if !canNewJob {
ctx.ServerError("user cann't new trainjob", err)
return err
}
ctx.Data["canNewJob"] = canNewJob

t := time.Now()
var jobName = cutString(ctx.User.Name, 5) + t.Format("2006010215") + strconv.Itoa(int(t.Unix()))[5:]
@@ -890,6 +882,13 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ
EngineName := form.EngineName
isLatestVersion := modelarts.IsLatestVersion

//判断权限
canNewJob, _ := canUserCreateTrainJobVersion(ctx, latestTask.UserID)
if !canNewJob {
ctx.RenderWithErr("user cann't new trainjob", tplModelArtsTrainJobVersionNew, &form)
return
}

if err := paramCheckCreateTrainJob(form); err != nil {
log.Error("paramCheckCreateTrainJob failed:(%v)", err)
VersionErrorDataPrepare(ctx, form)
@@ -904,10 +903,11 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ
// }

//todo: del the codeLocalPath
_, err = ioutil.ReadDir(codeLocalPath)
if err == nil {
os.RemoveAll(codeLocalPath)
}
// _, err = ioutil.ReadDir(codeLocalPath)
// if err == nil {
// os.RemoveAll(codeLocalPath)
// }
os.RemoveAll(codeLocalPath)

gitRepo, _ := git.OpenRepository(repo.RepoPath())
commitID, _ := gitRepo.GetBranchCommitID(branch_name)
@@ -936,6 +936,7 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ
}

parentDir := VersionOutputPath + "/"
// parentDir := ""
// if err := uploadCodeToObs(codeLocalPath, jobName, ""); err != nil {
if err := uploadCodeToObs(codeLocalPath, jobName, parentDir); err != nil {
log.Error("Failed to uploadCodeToObs: %s (%v)", repo.FullName(), err)


Loading…
Cancel
Save