From b3ca9a35c816cc4e4b570c89fef907c79719db6b Mon Sep 17 00:00:00 2001 From: liuzx Date: Thu, 25 Nov 2021 17:05:36 +0800 Subject: [PATCH 1/2] fix bug --- routers/repo/modelarts.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index e7b2de3ec..5ad5a215e 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -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) @@ -936,6 +935,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) From 8e409892100364e25042abfd6229bf281a87b027 Mon Sep 17 00:00:00 2001 From: liuzx Date: Thu, 25 Nov 2021 17:51:29 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AE=AD=E7=BB=83?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E6=97=B6=E5=81=B6=E5=B0=94=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E6=B2=A1=E5=88=A0=E6=8E=89=E5=8E=9F=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/repo/modelarts.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index 5ad5a215e..9ea5de5c3 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -903,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)