| @@ -485,20 +485,12 @@ func trainJobNewVersionDataPrepare(ctx *context.Context) error { | |||||
| // ctx.ServerError("canNewJob can info failed", err) | // ctx.ServerError("canNewJob can info failed", err) | ||||
| // return err | // return err | ||||
| // } | // } | ||||
| // ctx.Data["canNewJob"] = canNewJob | |||||
| task, err := models.GetCloudbrainByJobIDAndVersionName(jobID, versionName) | task, err := models.GetCloudbrainByJobIDAndVersionName(jobID, versionName) | ||||
| if err != nil { | if err != nil { | ||||
| log.Error("GetCloudbrainByJobIDAndVersionName(%s) failed:%v", jobID, err.Error()) | log.Error("GetCloudbrainByJobIDAndVersionName(%s) failed:%v", jobID, err.Error()) | ||||
| return err | 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() | t := time.Now() | ||||
| var jobName = cutString(ctx.User.Name, 5) + t.Format("2006010215") + strconv.Itoa(int(t.Unix()))[5:] | 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 | EngineName := form.EngineName | ||||
| isLatestVersion := modelarts.IsLatestVersion | 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 { | if err := paramCheckCreateTrainJob(form); err != nil { | ||||
| log.Error("paramCheckCreateTrainJob failed:(%v)", err) | log.Error("paramCheckCreateTrainJob failed:(%v)", err) | ||||
| VersionErrorDataPrepare(ctx, form) | VersionErrorDataPrepare(ctx, form) | ||||
| @@ -936,6 +935,7 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ | |||||
| } | } | ||||
| parentDir := VersionOutputPath + "/" | parentDir := VersionOutputPath + "/" | ||||
| // parentDir := "" | |||||
| // if err := uploadCodeToObs(codeLocalPath, jobName, ""); err != nil { | // if err := uploadCodeToObs(codeLocalPath, jobName, ""); err != nil { | ||||
| if err := uploadCodeToObs(codeLocalPath, jobName, parentDir); err != nil { | if err := uploadCodeToObs(codeLocalPath, jobName, parentDir); err != nil { | ||||
| log.Error("Failed to uploadCodeToObs: %s (%v)", repo.FullName(), err) | log.Error("Failed to uploadCodeToObs: %s (%v)", repo.FullName(), err) | ||||