From 749bc36079ab140443bef3be6d7a28a301414573 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Thu, 25 Nov 2021 16:03:06 +0800 Subject: [PATCH 1/5] fix issue --- templates/repo/modelarts/trainjob/show.tmpl | 4 ++-- templates/repo/modelarts/trainjob/version_new.tmpl | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/templates/repo/modelarts/trainjob/show.tmpl b/templates/repo/modelarts/trainjob/show.tmpl index 4c9f38bb0..b34c1924b 100755 --- a/templates/repo/modelarts/trainjob/show.tmpl +++ b/templates/repo/modelarts/trainjob/show.tmpl @@ -714,8 +714,8 @@ td, th { let scrollTop = container.scrollTop let scrollHeight = container.scrollHeight let clientHeight = container.clientHeight - - if(parseInt(scrollTop) + clientHeight == scrollHeight && scrollHeight>clientHeight){ + console.log(scrollTop,scrollHeight,clientHeight) + if(parseInt(scrollTop) + clientHeight == scrollHeight || parseInt(scrollTop) + clientHeight +1 == scrollHeight || parseInt(scrollTop) + clientHeight - 1 == scrollHeight){ let end_line = $(`#log${version_name} input[name=end_line]`).val() $.get(`/api/v1/repos/${userName}/${repoPath}/modelarts/train-job/${jobID}/log?version_name=${version_name}&base_line=${end_line}&lines=50&order=desc`, (data) => { if (data.Lines == 0){ diff --git a/templates/repo/modelarts/trainjob/version_new.tmpl b/templates/repo/modelarts/trainjob/version_new.tmpl index 51f468c4d..bd104dde8 100644 --- a/templates/repo/modelarts/trainjob/version_new.tmpl +++ b/templates/repo/modelarts/trainjob/version_new.tmpl @@ -156,7 +156,11 @@
{{.CsrfTokenHtml}} + {{if .version_name}} + + {{else}} + {{end}}

{{.i18n.Tr "repo.modelarts.train_job.basic_info"}}:

@@ -167,8 +171,11 @@
- + {{if .version_name}} + + {{else}} + {{end}}
From 251b2c081e287b051ab235934e1234de90658df9 Mon Sep 17 00:00:00 2001 From: liuzx Date: Thu, 25 Nov 2021 16:21:42 +0800 Subject: [PATCH 2/5] fix bug --- routers/repo/modelarts.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index e048b98f4..e7b2de3ec 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -479,6 +479,7 @@ func trainJobNewVersionDataPrepare(ctx *context.Context) error { ctx.Data["PageIsCloudBrain"] = true var jobID = ctx.Params(":jobid") var versionName = ctx.Query("version_name") + // canNewJob, err := canUserCreateTrainJobVersion(ctx, jobID, versionName) // if err != nil { // ctx.ServerError("canNewJob can info failed", err) @@ -491,6 +492,13 @@ func trainJobNewVersionDataPrepare(ctx *context.Context) error { 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:] @@ -643,6 +651,7 @@ func VersionErrorDataPrepare(ctx *context.Context, form auth.CreateModelArtsTrai ctx.Data["engine_name"] = form.EngineName ctx.Data["flavor_code"] = task.FlavorCode ctx.Data["engine_id"] = task.EngineID + ctx.Data["version_name"] = form.VersionName ctx.Data["bootFile"] = form.BootFile ctx.Data["uuid"] = form.Attachment @@ -1183,7 +1192,7 @@ func TrainJobShow(ctx *context.Context) { if len(parameters.Parameter) > 0 { paramTemp := "" for _, Parameter := range parameters.Parameter { - param := Parameter.Label + " = " + Parameter.Value + ", " + param := Parameter.Label + " = " + Parameter.Value + "; " paramTemp = paramTemp + param } VersionListTasks[i].Parameters = paramTemp[:len(paramTemp)-2] @@ -1328,7 +1337,6 @@ func canUserCreateTrainJobVersion(ctx *context.Context, userID int64) (bool, err return true, nil } else { log.Error("Only user itself and admin can new trainjob!") - // ctx.ServerError("Only user itself and admin can new trainjob!", nil) return false, nil } } From 27f0edd591e3640cc723382fafa717f1295f60a9 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Thu, 25 Nov 2021 16:36:57 +0800 Subject: [PATCH 3/5] fix issue --- templates/repo/modelarts/trainjob/show.tmpl | 2 -- templates/repo/modelarts/trainjob/version_new.tmpl | 9 ++++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/templates/repo/modelarts/trainjob/show.tmpl b/templates/repo/modelarts/trainjob/show.tmpl index b34c1924b..a3fdddf38 100755 --- a/templates/repo/modelarts/trainjob/show.tmpl +++ b/templates/repo/modelarts/trainjob/show.tmpl @@ -549,7 +549,6 @@ td, th { function refreshStatus(version_name){ $.get(`/api/v1/repos/${userName}/${repoPath}/modelarts/train-job/${jobID}?version_name=${version_name}`,(data)=>{ - console.log(data) // header status and duration $(`#${version_name}-duration-span`).text(data.JobDuration) $(`#${version_name}-status-span span`).text(data.JobStatus) @@ -714,7 +713,6 @@ td, th { let scrollTop = container.scrollTop let scrollHeight = container.scrollHeight let clientHeight = container.clientHeight - console.log(scrollTop,scrollHeight,clientHeight) if(parseInt(scrollTop) + clientHeight == scrollHeight || parseInt(scrollTop) + clientHeight +1 == scrollHeight || parseInt(scrollTop) + clientHeight - 1 == scrollHeight){ let end_line = $(`#log${version_name} input[name=end_line]`).val() $.get(`/api/v1/repos/${userName}/${repoPath}/modelarts/train-job/${jobID}/log?version_name=${version_name}&base_line=${end_line}&lines=50&order=desc`, (data) => { diff --git a/templates/repo/modelarts/trainjob/version_new.tmpl b/templates/repo/modelarts/trainjob/version_new.tmpl index bd104dde8..d9a0d3e50 100644 --- a/templates/repo/modelarts/trainjob/version_new.tmpl +++ b/templates/repo/modelarts/trainjob/version_new.tmpl @@ -528,8 +528,8 @@ identifier : 'run_para_list', rules: [ { - type: 'maxLength[256]', - prompt : '所有字符最长不超过256个字符。' + type: 'maxLength[255]', + prompt : '所有字符最长不超过255个字符。' } ] }, @@ -585,8 +585,8 @@ identifier : 'run_para_list', rules: [ { - type: 'maxLength[256]', - prompt : '所有字符最长不超过256个字符。' + type: 'maxLength[255]', + prompt : '所有字符最长不超过255个字符。' } ] }, @@ -621,7 +621,6 @@ function get_name(){ let name1=$("#engine_name .text").text() let name2=$("#flaver_name .text").text() - console.log(name1,name2) $("input#ai_engine_name").val(name1) $("input#ai_flaver_name").val(name2) From 3e83bc79a92a88443f9403f615f52dc682d2a2d9 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Thu, 25 Nov 2021 16:50:14 +0800 Subject: [PATCH 4/5] fix issue --- templates/repo/create.tmpl | 2 +- templates/repo/migrate.tmpl | 2 +- templates/repo/pulls/fork.tmpl | 2 +- templates/repo/settings/options.tmpl | 2 +- templates/user/settings/profile.tmpl | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/templates/repo/create.tmpl b/templates/repo/create.tmpl index ddf887b51..fbc601cc5 100644 --- a/templates/repo/create.tmpl +++ b/templates/repo/create.tmpl @@ -54,7 +54,7 @@
- +
diff --git a/templates/repo/migrate.tmpl b/templates/repo/migrate.tmpl index ba17fd83f..e8771fdbe 100644 --- a/templates/repo/migrate.tmpl +++ b/templates/repo/migrate.tmpl @@ -122,7 +122,7 @@
- +
diff --git a/templates/repo/pulls/fork.tmpl b/templates/repo/pulls/fork.tmpl index c7ad0f087..a7c79bc73 100644 --- a/templates/repo/pulls/fork.tmpl +++ b/templates/repo/pulls/fork.tmpl @@ -53,7 +53,7 @@
- +
diff --git a/templates/repo/settings/options.tmpl b/templates/repo/settings/options.tmpl index 6aea5214e..2a501a1e4 100644 --- a/templates/repo/settings/options.tmpl +++ b/templates/repo/settings/options.tmpl @@ -41,7 +41,7 @@ {{end}}
- +
diff --git a/templates/user/settings/profile.tmpl b/templates/user/settings/profile.tmpl index ff677f35f..54c6695ec 100644 --- a/templates/user/settings/profile.tmpl +++ b/templates/user/settings/profile.tmpl @@ -34,7 +34,7 @@
- +
From b3ca9a35c816cc4e4b570c89fef907c79719db6b Mon Sep 17 00:00:00 2001 From: liuzx Date: Thu, 25 Nov 2021 17:05:36 +0800 Subject: [PATCH 5/5] 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)