From 70dca4ff3f58719c05efc66b48df8273531dc3de Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Mon, 1 Nov 2021 11:03:41 +0800 Subject: [PATCH 1/9] fix issue cloudbrain moderlarts --- templates/repo/cloudbrain/index.tmpl | 51 +++++++++++++++++----- templates/repo/modelarts/notebook/index.tmpl | 58 ++++++++++++++++++------- templates/repo/modelarts/trainjob/index.tmpl | 63 ++++++++++++++++++++++------ 3 files changed, 133 insertions(+), 39 deletions(-) diff --git a/templates/repo/cloudbrain/index.tmpl b/templates/repo/cloudbrain/index.tmpl index 795e35aac..ff9bb24c4 100755 --- a/templates/repo/cloudbrain/index.tmpl +++ b/templates/repo/cloudbrain/index.tmpl @@ -323,7 +323,7 @@ {{else}} {{.Status}} {{end}} --> - {{.Status}} + {{.Status}} - + 调试 -
+ {{$.CsrfTokenHtml}} - + 停止
@@ -376,14 +376,14 @@ - 提交镜像 + 提交镜像 -
+ {{$.CsrfTokenHtml}} - + 删除
@@ -512,23 +512,52 @@ $(document).ready(loadJobStatus); function loadJobStatus() { $(".job-status").each((index, job) => { - console.log("---------",index,job) const jobID = job.dataset.jobid; const repoPath = job.dataset.repopath; if (job.textContent.trim() == 'STOPPED' || job.textContent.trim() == 'FAILED') { return } - + $.get(`/api/v1/repos/${repoPath}/cloudbrain/${jobID}`, (data) => { const jobID = data.JobID const status = data.JobStatus if (status != job.textContent.trim()) { - //$('#' + jobID).text(status) + console.log("---------") + $('#' + jobID+'-icon').removeClass().addClass(status) + $('#' + jobID+ '-text').text(status) + //if (status == 'STOPPED') { - window.location.reload() + // window.location.reload() //} } + if(status==="RUNNING"){ + $('#model-debug').removeClass('disabled') + $('#model-debug').addClass('blue') + $('#model-image').removeClass('disabled') + $('#model-image').addClass('blue') + + + } + if(status!=="RUNNING"){ + $('#model-debug').removeClass('blue') + $('#model-debug').addClass('disabled') + $('#model-image').removeClass('blue') + $('#model-image').addClass('disabled') + + } + if(status!=="STOPPED" || status!=="FAILED"){ + $('#stop-model-debug').removeClass('disabled') + $('#stop-model-debug').addClass('blue') + $('#model-delete').removeClass('red') + $('#model-delete').addClass('disabled') + } + if(status=="STOPPED" || status=="FAILED"){ + $('#stop-model-debug').removeClass('blue') + $('#stop-model-debug').addClass('disabled') + $('#model-delete').removeClass('disabled') + $('#model-delete').addClass('red') + } }).fail(function(err) { console.log(err); }); diff --git a/templates/repo/modelarts/notebook/index.tmpl b/templates/repo/modelarts/notebook/index.tmpl index 2a4115723..8f8396cb9 100755 --- a/templates/repo/modelarts/notebook/index.tmpl +++ b/templates/repo/modelarts/notebook/index.tmpl @@ -291,7 +291,7 @@ {{.Status}} --> - {{.Status}} + {{.Status}} {{TimeSinceUnix .Cloudbrain.CreatedUnix $.Lang}} @@ -310,33 +310,33 @@ - + 调试 -
+ {{$.CsrfTokenHtml}} - + 停止
-
+ - + - - 提交镜像 + -
+ -
+ {{$.CsrfTokenHtml}} - + 删除
@@ -423,7 +423,7 @@ // 加载任务状态 var timeid = window.setInterval(loadJobStatus, 15000); - // $(document).ready(loadJobStatus); + $(document).ready(loadJobStatus); function loadJobStatus() { $(".job-status").each((index, job) => { const jobID = job.dataset.jobid; @@ -435,12 +435,38 @@ $.get(`/api/v1/repos/${repoPath}/modelarts/notebook/${jobID}`, (data) => { const jobID = data.JobID const status = data.JobStatus - if (status != job.textContent.trim() || status=='RUNNING') { - //$('#' + jobID).text(status) + if (status != job.textContent.trim()) { + console.log("---------") + $('#' + jobID+'-icon').removeClass().addClass(status) + $('#' + jobID+ '-text').text(status) + //if (status == 'STOPPED') { - window.location.reload() + // window.location.reload() //} } + if(status==="RUNNING"){ + $('#model-debug').removeClass('disabled') + $('#model-debug').addClass('blue') + + + } + if(status!=="RUNNING"){ + $('#model-debug').removeClass('blue') + $('#model-debug').addClass('disabled') + + } + if(status!=="STOPPED" || status!=="FAILED"){ + $('#stop-model-debug').removeClass('disabled') + $('#stop-model-debug').addClass('blue') + $('#model-delete').removeClass('red') + $('#model-delete').addClass('disabled') + } + if(status=="STOPPED" || status=="FAILED"){ + $('#stop-model-debug').removeClass('blue') + $('#stop-model-debug').addClass('disabled') + $('#model-delete').removeClass('disabled') + $('#model-delete').addClass('red') + } }).fail(function(err) { console.log(err); }); diff --git a/templates/repo/modelarts/trainjob/index.tmpl b/templates/repo/modelarts/trainjob/index.tmpl index 0d15638ad..8c2bab57f 100755 --- a/templates/repo/modelarts/trainjob/index.tmpl +++ b/templates/repo/modelarts/trainjob/index.tmpl @@ -317,7 +317,7 @@ {{.Status}} --> - {{.Status}} + {{.Status}} {{TimeSinceUnix .Cloudbrain.CreatedUnix $.Lang}} @@ -329,7 +329,7 @@ {{.Status}} --> - {{.TrainJobDuration}} + {{.TrainJobDuration}} @@ -351,16 +351,16 @@ 调试 --> -
+ {{$.CsrfTokenHtml}} - + 停止
- + 模型下载 @@ -370,9 +370,9 @@
-
+ {{$.CsrfTokenHtml}} - + 删除
@@ -459,7 +459,7 @@ // 加载任务状态 var timeid = window.setInterval(loadJobStatus, 15000); - // $(document).ready(loadJobStatus); + $(document).ready(loadJobStatus); function loadJobStatus() { $(".job-status").each((index, job) => { const jobID = job.dataset.jobid; @@ -471,18 +471,57 @@ $.get(`/api/v1/repos/${repoPath}/modelarts/train-job/${jobID}`, (data) => { const jobID = data.JobID const status = data.JobStatus - if (status != job.textContent.trim() || status=='RUNNING') { - //$('#' + jobID).text(status) + function runtime(){ + if(time){ + let hours = time/3600000<10 ? time/3600000+"0":time/3600000 + let miuns = time%3600000/60000<10 ? time%3600000/60000+"0":time%3600000/60000 + let seconds = time%60000/1000<10 ? time%60000/1000<10+"0":time%60000/1000<10 + return hours + ":" + miuns + ":" + seconds + }else{ + return "00:00:00" + } + } + if (status != job.textContent.trim()) { + + $('#' + jobID+'-icon').removeClass().addClass(status) + $('#' + jobID+ '-text').text(status) + //if (status == 'STOPPED') { - window.location.reload() + // window.location.reload() //} } + if(status==="RUNNING"){ + $('#model-debug').removeClass('disabled') + $('#model-debug').addClass('blue') + let TrainDuration = runtime(time) + $('#model-duration').text(TrainDuration) + + + + } + if(status!=="RUNNING"){ + $('#model-debug').removeClass('blue') + $('#model-debug').addClass('disabled') + + } + if(status!=="STOPPED" || status!=="FAILED"){ + $('#stop-model-debug').removeClass('disabled') + $('#stop-model-debug').addClass('blue') + $('#model-delete').removeClass('red') + $('#model-delete').addClass('disabled') + } + if(status=="STOPPED" || status=="FAILED"){ + $('#stop-model-debug').removeClass('blue') + $('#stop-model-debug').addClass('disabled') + $('#model-delete').removeClass('disabled') + $('#model-delete').addClass('red') + } }).fail(function(err) { console.log(err); }); }); }; - + // 获取弹窗 var modal = document.getElementById('imageModal'); From 769b450e43b566a42b83321328c8fe81505b1b9f Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Mon, 1 Nov 2021 12:17:14 +0800 Subject: [PATCH 2/9] update --- templates/repo/cloudbrain/index.tmpl | 40 +++++------ templates/repo/modelarts/notebook/index.tmpl | 44 ++++++------- templates/repo/modelarts/trainjob/index.tmpl | 42 ++++++------ templates/repo/modelarts/trainjob/new.tmpl | 99 ++++++++++++++++++++++++++-- web_src/less/openi.less | 4 +- 5 files changed, 160 insertions(+), 69 deletions(-) diff --git a/templates/repo/cloudbrain/index.tmpl b/templates/repo/cloudbrain/index.tmpl index ff9bb24c4..d776dba99 100755 --- a/templates/repo/cloudbrain/index.tmpl +++ b/templates/repo/cloudbrain/index.tmpl @@ -357,13 +357,13 @@ {{end}} - + 调试
{{$.CsrfTokenHtml}} - + 停止
@@ -376,14 +376,14 @@ - 提交镜像 + 提交镜像
{{$.CsrfTokenHtml}} - + 删除
@@ -532,31 +532,31 @@ //} } if(status==="RUNNING"){ - $('#model-debug').removeClass('disabled') - $('#model-debug').addClass('blue') - $('#model-image').removeClass('disabled') - $('#model-image').addClass('blue') + $('#model-debug-'+jobID).removeClass('disabled') + $('#model-debug-'+jobID).addClass('blue') + $('#model-image-'+jobID).removeClass('disabled') + $('#model-image-'+jobID).addClass('blue') } if(status!=="RUNNING"){ - $('#model-debug').removeClass('blue') - $('#model-debug').addClass('disabled') - $('#model-image').removeClass('blue') - $('#model-image').addClass('disabled') + $('#model-debug-'+jobID).removeClass('blue') + $('#model-debug-'+jobID).addClass('disabled') + $('#model-image-'+jobID).removeClass('blue') + $('#model-image-'+jobID).addClass('disabled') } if(status!=="STOPPED" || status!=="FAILED"){ - $('#stop-model-debug').removeClass('disabled') - $('#stop-model-debug').addClass('blue') - $('#model-delete').removeClass('red') - $('#model-delete').addClass('disabled') + $('#stop-model-debug-'+jobID).removeClass('disabled') + $('#stop-model-debug-'+jobID).addClass('blue') + $('#model-delete-'+jobID).removeClass('red') + $('#model-delete-'+jobID).addClass('disabled') } if(status=="STOPPED" || status=="FAILED"){ - $('#stop-model-debug').removeClass('blue') - $('#stop-model-debug').addClass('disabled') - $('#model-delete').removeClass('disabled') - $('#model-delete').addClass('red') + $('#stop-model-debug-'+jobID).removeClass('blue') + $('#stop-model-debug-'+jobID).addClass('disabled') + $('#model-delete-'+jobID).removeClass('disabled') + $('#model-delete-'+jobID).addClass('red') } }).fail(function(err) { console.log(err); diff --git a/templates/repo/modelarts/notebook/index.tmpl b/templates/repo/modelarts/notebook/index.tmpl index bb2a9d154..86d9a7243 100755 --- a/templates/repo/modelarts/notebook/index.tmpl +++ b/templates/repo/modelarts/notebook/index.tmpl @@ -254,17 +254,17 @@
-
+
{{$.i18n.Tr "repo.cloudbrain_task"}}
{{$.i18n.Tr "repo.cloudbrain_status_createtime"}}
-
+
{{$.i18n.Tr "repo.cloudbrain_creator"}}
-
- {{$.i18n.Tr "repo.cloudbrain_operate"}} +
+ {{$.i18n.Tr "repo.cloudbrain_operate"}}
@@ -278,7 +278,7 @@
-
+ -
+
{{if .User.Name}} {{else}} @@ -305,17 +305,17 @@ {{end}}
-
+
- + 调试
{{$.CsrfTokenHtml}} - + 停止
@@ -336,7 +336,7 @@
{{$.CsrfTokenHtml}} - + 删除
@@ -445,27 +445,27 @@ //} } if(status==="RUNNING"){ - $('#model-debug').removeClass('disabled') - $('#model-debug').addClass('blue') + $('#model-debug-'+jobID).removeClass('disabled') + $('#model-debug-'+jobID).addClass('blue') } if(status!=="RUNNING"){ - $('#model-debug').removeClass('blue') - $('#model-debug').addClass('disabled') + $('#model-debug-'+jobID).removeClass('blue') + $('#model-debug-'+jobID).addClass('disabled') } if(status!=="STOPPED" || status!=="FAILED"){ - $('#stop-model-debug').removeClass('disabled') - $('#stop-model-debug').addClass('blue') - $('#model-delete').removeClass('red') - $('#model-delete').addClass('disabled') + $('#stop-model-debug-'+jobID).removeClass('disabled') + $('#stop-model-debug-'+jobID).addClass('blue') + $('#model-delete-'+jobID).removeClass('red') + $('#model-delete-'+jobID).addClass('disabled') } if(status=="STOPPED" || status=="FAILED"){ - $('#stop-model-debug').removeClass('blue') - $('#stop-model-debug').addClass('disabled') - $('#model-delete').removeClass('disabled') - $('#model-delete').addClass('red') + $('#stop-model-debug-'+jobID).removeClass('blue') + $('#stop-model-debug-'+jobID).addClass('disabled') + $('#model-delete-'+jobID).removeClass('disabled') + $('#model-delete-'+jobID).addClass('red') } }).fail(function(err) { console.log(err); diff --git a/templates/repo/modelarts/trainjob/index.tmpl b/templates/repo/modelarts/trainjob/index.tmpl index f332f9a6a..19e2615c9 100755 --- a/templates/repo/modelarts/trainjob/index.tmpl +++ b/templates/repo/modelarts/trainjob/index.tmpl @@ -286,11 +286,11 @@
{{$.i18n.Tr "repo.cloudbrain_status_runtime"}}
-
+
{{$.i18n.Tr "repo.cloudbrain_creator"}}
- {{$.i18n.Tr "repo.cloudbrain_operate"}} + {{$.i18n.Tr "repo.cloudbrain_operate"}}
@@ -329,13 +329,13 @@ {{.Status}} --> - {{.TrainJobDuration}} + {{.TrainJobDuration}}
-
+
{{if .User.Name}} {{else}} @@ -353,14 +353,14 @@ -->
{{$.CsrfTokenHtml}} - + 停止
- + 模型下载 @@ -372,7 +372,7 @@
{{$.CsrfTokenHtml}} - + 删除
@@ -493,8 +493,8 @@ //} } if(status==="RUNNING"){ - $('#model-debug').removeClass('disabled') - $('#model-debug').addClass('blue') + $('#model-debug-'+jobID).removeClass('disabled') + $('#model-debug-'+jobID).addClass('blue') // let TrainDuration = runtime(time) // $('#model-duration').text(TrainDuration) @@ -502,21 +502,21 @@ } if(status!=="RUNNING"){ - $('#model-debug').removeClass('blue') - $('#model-debug').addClass('disabled') + $('#model-debug-'+jobID).removeClass('blue') + $('#model-debug-'+jobID).addClass('disabled') } - if(status!=="STOPPED" || status!=="FAILED"){ - $('#stop-model-debug').removeClass('disabled') - $('#stop-model-debug').addClass('blue') - $('#model-delete').removeClass('red') - $('#model-delete').addClass('disabled') + if(status!=="KILLED" || status!=="FAILED"){ + $('#stop-model-debug-'+jobID).removeClass('disabled') + $('#stop-model-debug-'+jobID).addClass('blue') + $('#model-delete-'+jobID).removeClass('red') + $('#model-delete-'+jobID).addClass('disabled') } - if(status=="STOPPED" || status=="FAILED"){ - $('#stop-model-debug').removeClass('blue') - $('#stop-model-debug').addClass('disabled') - $('#model-delete').removeClass('disabled') - $('#model-delete').addClass('red') + if(status=="KILLED" || status=="FAILED"){ + $('#stop-model-debug-'+jobID).removeClass('blue') + $('#stop-model-debug-'+jobID).addClass('disabled') + $('#model-delete-'+jobID).removeClass('disabled') + $('#model-delete-'+jobID).addClass('red') } }).fail(function(err) { console.log(err); diff --git a/templates/repo/modelarts/trainjob/new.tmpl b/templates/repo/modelarts/trainjob/new.tmpl index 310ee56b2..3e852c619 100755 --- a/templates/repo/modelarts/trainjob/new.tmpl +++ b/templates/repo/modelarts/trainjob/new.tmpl @@ -49,12 +49,98 @@ text-align: center; color: #C2C7CC;" } +#mask { + position: fixed; + top: 0px; + left: 0px; + right: 0px; + bottom: 0px; + filter: alpha(opacity=60); + background-color: #777; + z-index: 1000; + display: none; + opacity: 0.8; + -moz-opacity: 0.5; + padding-top: 100px; + color: #000000 + } + /* 加载圈css效果图 */ + +#loadingPage { + margin: 200px auto; + width: 50px; + height: 40px; + text-align: center; + font-size: 10px; + display: block; +} + +#loadingPage>div { + background-color: green; + height: 100%; + width: 6px; + display: inline-block; + -webkit-animation: sk-stretchdelay 1.2s infinite ease-in-out; + animation: sk-stretchdelay 1.2s infinite ease-in-out; + } + + #loadingPage .rect2 { + -webkit-animation-delay: -1.1s; + animation-delay: -1.1s; + } + + #loadingPage .rect3 { + -webkit-animation-delay: -1.0s; + animation-delay: -1.0s; + } + + #loadingPage .rect4 { + -webkit-animation-delay: -0.9s; + animation-delay: -0.9s; + } + + #loadingPage .rect5 { + -webkit-animation-delay: -0.8s; + animation-delay: -0.8s; + } + + @-webkit-keyframes sk-stretchdelay { + 0%, + 40%, + 100% { + -webkit-transform: scaleY(0.4) + } + 20% { + -webkit-transform: scaleY(1.0) + } + } + + @keyframes sk-stretchdelay { + 0%, + 40%, + 100% { + transform: scaleY(0.4); + -webkit-transform: scaleY(0.4); + } + 20% { + transform: scaleY(1.0); + -webkit-transform: scaleY(1.0); + } +} -
+ +
+
+
+
+
+
+
+
-
{{template "repo/header" .}}
@@ -412,14 +498,19 @@ } }, onSuccess: function(){ - $('.ui.page.dimmer').dimmer('show') + // $('.ui.page.dimmer').dimmer('show') + document.getElementById("mask").style.display = "block" }, onFailure: function(e){ return false; } }) } - + document.onreadystatechange = function() { + if (document.readyState === "complete") { + document.getElementById("mask").style.display = "none" + } + } function send_run_para(){ var run_parameters = [] var msg = {} diff --git a/web_src/less/openi.less b/web_src/less/openi.less index aa9d31d76..56234586e 100644 --- a/web_src/less/openi.less +++ b/web_src/less/openi.less @@ -227,12 +227,12 @@ footer .column{margin-bottom:0!important; padding-bottom:0!important;} .STOPPED, .KILLED{display:inline-block;width:18px;height:18px;background:url("/img/icons.svg");background-position: -496px -52px;background-position: -459px -52px;} .RUNNING{display:inline-block;width:18px;height:18px;background:url("/img/icons.svg");background-position: -496px -52px;background-position: -478px -52px;} .i-bg-orange{background-position: -495px -51px;} -.FAILED{display:inline-block;width:18px;height:18px;background:url("/img/icons.svg");background-position: -496px -52px;background-position: -532px -52px;} +.FAILED,.START_FAILED{display:inline-block;width:18px;height:18px;background:url("/img/icons.svg");background-position: -496px -52px;background-position: -532px -52px;} .i-bg-green{background-position: -441px -52px;} .i-bg-used{background-position: -514px -52px;} .icon-bind{background-position: -550px -52px;} .icon-unbind{background-position: -568px -52px;} -.CREATING, .STOPPING, .DELETING, .STARTING, .WAITING{display:inline-block;background-image:url('/img/loading.gif');background-repeat:no-repeat;width:16px;height:16px;background-size:16px 16px;margin-right:5px;} +.CREATING, .STOPPING, .DELETING, .STARTING, .WAITING ,.INIT,.KILLING{display:inline-block;background-image:url('/img/loading.gif');background-repeat:no-repeat;width:16px;height:16px;background-size:16px 16px;margin-right:5px;} .COMPLETED{display:inline-block;width:18px;height:18px;background:url("/img/icons.svg");background-position: -496px -52px;background-position: -441px -52px;} .text_over{ From bfbd213c6fca42f2fddb4d48073203d19f769a9e Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Mon, 1 Nov 2021 15:43:53 +0800 Subject: [PATCH 3/9] =?UTF-8?q?dataset=E6=8C=87=E6=A0=87=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E6=97=B6=E4=BF=9D=E7=95=99=E5=B0=8F=E6=95=B0=EF=BC=8C=E4=B8=8D?= =?UTF-8?q?=E5=8F=96=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/normalization/normalization.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/normalization/normalization.go b/modules/normalization/normalization.go index c2b545f90..ce616d7f8 100644 --- a/modules/normalization/normalization.go +++ b/modules/normalization/normalization.go @@ -43,7 +43,7 @@ func GetCompleteInitValue(issuesClosed int64, releases int64, developAge int64, return setting.RadarMap.CompletenessIssuesClosed*float64(issuesClosed) + setting.RadarMap.CompletenessReleases*float64(releases) + setting.RadarMap.CompletenessDevelopAge*float64(developAge) + - setting.RadarMap.CompletenessDataset*float64(dataset/(1024*1024)) + + setting.RadarMap.CompletenessDataset*(float64(dataset)/(1024*1024)) + setting.RadarMap.CompletenessModel*float64(model) + setting.RadarMap.CompletenessWiki*float64(wiki) From 204d8ffe3063fbac71d83fac70555dc2187149e2 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Mon, 1 Nov 2021 16:25:10 +0800 Subject: [PATCH 4/9] update --- options/locale/locale_en-US.ini | 19 ++++++-- options/locale/locale_zh-CN.ini | 17 +++++-- routers/api/v1/repo/modelarts.go | 1 + templates/repo/cloudbrain/index.tmpl | 14 +++--- templates/repo/modelarts/notebook/index.tmpl | 12 ++--- templates/repo/modelarts/trainjob/index.tmpl | 70 ++++++++++++++++------------ 6 files changed, 84 insertions(+), 49 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 18ca21925..d8913ed1a 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -755,6 +755,15 @@ unit_disabled = The site administrator has disabled this repository section. language_other = Other datasets = Datasets datasets.desc = Enable Dataset + +debug=Debug +stop=Stop +delete=Delete +model_download=Model Download +submit_image=Submit Image +download=Download + + cloudbrain=cloudbrain cloudbrain.new=New cloudbrain cloudbrain.desc=cloudbrain @@ -777,9 +786,13 @@ cloudbrain_status_createtime = Status/Createtime cloudbrain_status_runtime = Running Time -modelarts.notebook=Debug Job -modelarts.train_job=Create Job -modelarts.train_job.new=New Job +modelarts.notebook=Debug Task +modelarts.train_job=Create Task +modelarts.train_job.new_debug= New Debug Task +modelarts.train_job.new_train=New Train Task + + + modelarts.train_job.basic_info=Basic Info modelarts.train_job.job_status=Job Status modelarts.train_job.job_name=Job Name diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 8ac895ec9..9af32fd99 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -757,6 +757,14 @@ unit_disabled=站点管理员已禁用此项目单元。 language_other=其它 datasets=数据集 datasets.desc=数据集功能 + +debug=调试 +stop=停止 +delete=删除 +model_download=模型下载 +submit_image=提交镜像 +download=模型下载 + cloudbrain=云脑 cloudbrain.new=新建任务 cloudbrain.desc=云脑功能 @@ -779,9 +787,12 @@ cloudbrain_status_createtime=状态/创建时间 cloudbrain_status_runtime = 运行时长 cloudbrain_jobname_err=只能以小写字母或数字开头且只包含小写字母、数字、_和-,不能以_结尾,最长36个字符。 -modelarts.notebook=调试作业 -modelarts.train_job=训练作业 -modelarts.train_job.new=新建作业 +modelarts.notebook=调试任务 +modelarts.train_job=训练任务 +modelarts.train_job.new_debug=新建调试任务 +modelarts.train_job.new_train=新建训练任务 + + modelarts.train_job.basic_info=基本信息 modelarts.train_job.job_status=作业状态 modelarts.train_job.job_name=作业名称 diff --git a/routers/api/v1/repo/modelarts.go b/routers/api/v1/repo/modelarts.go index f38cb1ad7..2e825d8cc 100755 --- a/routers/api/v1/repo/modelarts.go +++ b/routers/api/v1/repo/modelarts.go @@ -74,6 +74,7 @@ func GetModelArtsTrainJob(ctx *context.APIContext) { ctx.JSON(http.StatusOK, map[string]interface{}{ "JobID": jobID, "JobStatus": job.Status, + "JobDuration": job.Duration, }) } diff --git a/templates/repo/cloudbrain/index.tmpl b/templates/repo/cloudbrain/index.tmpl index d776dba99..2201cd272 100755 --- a/templates/repo/cloudbrain/index.tmpl +++ b/templates/repo/cloudbrain/index.tmpl @@ -239,7 +239,7 @@ @@ -255,7 +255,7 @@
- 新建调试任务 + {{$.i18n.Tr "repo.modelarts.train_job.new_debug"}}
@@ -358,25 +358,25 @@ - 调试 + {{$.i18n.Tr "repo.debug"}}
{{$.CsrfTokenHtml}} - 停止 + {{$.i18n.Tr "repo.stop"}}
@@ -384,7 +384,7 @@
{{$.CsrfTokenHtml}} - 删除 + {{$.i18n.Tr "repo.delete"}}
diff --git a/templates/repo/modelarts/notebook/index.tmpl b/templates/repo/modelarts/notebook/index.tmpl index 86d9a7243..194d0604a 100755 --- a/templates/repo/modelarts/notebook/index.tmpl +++ b/templates/repo/modelarts/notebook/index.tmpl @@ -208,8 +208,8 @@
@@ -224,7 +224,7 @@
- 新建调试任务 + {{$.i18n.Tr "repo.modelarts.train_job.new_debug"}}
@@ -311,12 +311,12 @@ 查看 --> - 调试 + {{$.i18n.Tr "repo.debug"}}
{{$.CsrfTokenHtml}} - 停止 + {{$.i18n.Tr "repo.stop"}}
@@ -337,7 +337,7 @@
{{$.CsrfTokenHtml}} - 删除 + {{$.i18n.Tr "repo.delete"}}
diff --git a/templates/repo/modelarts/trainjob/index.tmpl b/templates/repo/modelarts/trainjob/index.tmpl index 19e2615c9..5397110ff 100755 --- a/templates/repo/modelarts/trainjob/index.tmpl +++ b/templates/repo/modelarts/trainjob/index.tmpl @@ -231,8 +231,8 @@
@@ -247,7 +247,7 @@
- 新建训练任务 + {{$.i18n.Tr "repo.modelarts.train_job.new_train"}}
@@ -283,13 +283,13 @@
{{$.i18n.Tr "repo.cloudbrain_status_createtime"}}
-
+
{{$.i18n.Tr "repo.cloudbrain_status_runtime"}}
{{$.i18n.Tr "repo.cloudbrain_creator"}}
-
+
{{$.i18n.Tr "repo.cloudbrain_operate"}}
@@ -323,13 +323,13 @@ {{TimeSinceUnix .Cloudbrain.CreatedUnix $.Lang}}
-
+
- {{.TrainJobDuration}} + @@ -343,7 +343,7 @@ {{end}}
-
+
@@ -456,7 +456,31 @@ .modal('show') } } + function runtime(time){ + if(time){ + let hours = time/3600000<10 ? "0"+parseInt(time/3600000):parseInt(time/3600000) + let miuns = time%3600000/60000<10 ? "0"+parseInt(time%3600000/60000):parseInt(time%3600000/60000) + let seconds = time%60000/1000<10 ? "0"+parseInt(time%60000/1000):parseInt(time%60000/1000) + return hours + ":" + miuns + ":" + seconds + }else{ + return "00:00:00" + } + } + function loadJobDuration() { + $(".job-status").each((index, job) => { + const jobID = job.dataset.jobid; + const repoPath = job.dataset.repopath; + $.get(`/api/v1/repos/${repoPath}/modelarts/train-job/${jobID}`, (data) => { + const duration = data.JobDuration + const jobID = data.JobID + let train_duration = runtime(duration) + $('#duration-'+jobID).text(train_duration) + }) + + }) + } + $(document).ready(loadJobDuration); // 加载任务状态 var timeid = window.setInterval(loadJobStatus, 15000); $(document).ready(loadJobStatus); @@ -464,6 +488,7 @@ $(".job-status").each((index, job) => { const jobID = job.dataset.jobid; const repoPath = job.dataset.repopath; + if (job.textContent.trim() == 'IMAGE_FAILED' || job.textContent.trim() == 'SUBMIT_FAILED' || job.textContent.trim() == 'DELETE_FAILED' || job.textContent.trim() == 'KILLED' || job.textContent.trim() == 'COMPLETED' || job.textContent.trim() == 'FAILED' || job.textContent.trim() == 'CANCELED' || job.textContent.trim() == 'LOST') { @@ -473,32 +498,17 @@ $.get(`/api/v1/repos/${repoPath}/modelarts/train-job/${jobID}`, (data) => { const jobID = data.JobID const status = data.JobStatus - function runtime(){ - if(time){ - let hours = time/3600000<10 ? time/3600000+"0":time/3600000 - let miuns = time%3600000/60000<10 ? time%3600000/60000+"0":time%3600000/60000 - let seconds = time%60000/1000<10 ? time%60000/1000<10+"0":time%60000/1000<10 - return hours + ":" + miuns + ":" + seconds - }else{ - return "00:00:00" - } - } + const duration = data.JobDuration if (status != job.textContent.trim()) { - $('#' + jobID+'-icon').removeClass().addClass(status) $('#' + jobID+ '-text').text(status) - - //if (status == 'STOPPED') { - // window.location.reload() - //} + } if(status==="RUNNING"){ $('#model-debug-'+jobID).removeClass('disabled') $('#model-debug-'+jobID).addClass('blue') - // let TrainDuration = runtime(time) - // $('#model-duration').text(TrainDuration) - - + let train_duration = runtime(duration) + $('#duration-'+jobID).text(train_duration) } if(status!=="RUNNING"){ From 807367ac502bc1422b99f32d92b4be3b612cb0bd Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Mon, 1 Nov 2021 16:48:31 +0800 Subject: [PATCH 5/9] fix issue --- options/locale/locale_en-US.ini | 2 +- options/locale/locale_zh-CN.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index d8913ed1a..ef77c17be 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -798,7 +798,7 @@ modelarts.train_job.job_status=Job Status modelarts.train_job.job_name=Job Name modelarts.train_job.version=Job Version modelarts.train_job.start_time=Start Time -modelarts.train_job.dura_time=Duration Time +modelarts.train_job.dura_time=Running Time modelarts.train_job.description=Description modelarts.train_job.parameter_setting=Parameter setting modelarts.train_job.parameter_setting_info=Parameter Info diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 9af32fd99..3c0d051dd 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -798,7 +798,7 @@ modelarts.train_job.job_status=作业状态 modelarts.train_job.job_name=作业名称 modelarts.train_job.version=作业版本 modelarts.train_job.start_time=开始时间 -modelarts.train_job.dura_time=持续时间 +modelarts.train_job.dura_time=运行时长 modelarts.train_job.description=作业描述 modelarts.train_job.parameter_setting=参数设置 modelarts.train_job.parameter_setting_info=参数信息 From 4219800d103178824ad1da542932743fe332a8f3 Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Mon, 1 Nov 2021 17:00:31 +0800 Subject: [PATCH 6/9] show failed job --- routers/repo/modelarts.go | 12 ++++++------ templates/repo/modelarts/notebook/index.tmpl | 1 + templates/repo/modelarts/trainjob/index.tmpl | 1 + 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index 166fe6704..a679e8a25 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -357,14 +357,14 @@ func NotebookShow(ctx *context.Context) { task, err := models.GetCloudbrainByJobID(jobID) if err != nil { ctx.Data["error"] = err.Error() - ctx.RenderWithErr(err.Error(), tplModelArtsNotebookIndex, nil) + ctx.RenderWithErr(err.Error(), tplModelArtsNotebookShow, nil) return } result, err := modelarts.GetJob(jobID) if err != nil { ctx.Data["error"] = err.Error() - ctx.RenderWithErr(err.Error(), tplModelArtsNotebookIndex, nil) + ctx.RenderWithErr(err.Error(), tplModelArtsNotebookShow, nil) return } @@ -373,7 +373,7 @@ func NotebookShow(ctx *context.Context) { err = models.UpdateJob(task) if err != nil { ctx.Data["error"] = err.Error() - ctx.RenderWithErr(err.Error(), tplModelArtsNotebookIndex, nil) + ctx.RenderWithErr(err.Error(), tplModelArtsNotebookShow, nil) return } @@ -838,21 +838,21 @@ func TrainJobShow(ctx *context.Context) { task, err := models.GetCloudbrainByJobID(jobID) if err != nil { log.Error("GetCloudbrainByJobID(%s) failed:%v", jobID, err.Error()) - ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobIndex, nil) + 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(), tplModelArtsTrainJobIndex, nil) + ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobShow, nil) return } result, err := modelarts.GetTrainJob(jobID, strconv.FormatInt(task.VersionID, 10)) if err != nil { log.Error("GetJob(%s) failed:%v", jobID, err.Error()) - ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobIndex, nil) + ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobShow, nil) return } diff --git a/templates/repo/modelarts/notebook/index.tmpl b/templates/repo/modelarts/notebook/index.tmpl index 194d0604a..721089727 100755 --- a/templates/repo/modelarts/notebook/index.tmpl +++ b/templates/repo/modelarts/notebook/index.tmpl @@ -200,6 +200,7 @@ {{template "repo/header" .}}
+ {{template "base/alert" .}} diff --git a/templates/repo/modelarts/trainjob/index.tmpl b/templates/repo/modelarts/trainjob/index.tmpl index 5397110ff..eee186b38 100755 --- a/templates/repo/modelarts/trainjob/index.tmpl +++ b/templates/repo/modelarts/trainjob/index.tmpl @@ -200,6 +200,7 @@ {{template "repo/header" .}}
+ {{template "base/alert" .}} -
+
- + diff --git a/templates/repo/modelarts/trainjob/show.tmpl b/templates/repo/modelarts/trainjob/show.tmpl index d1fc781d4..d00ce52b1 100755 --- a/templates/repo/modelarts/trainjob/show.tmpl +++ b/templates/repo/modelarts/trainjob/show.tmpl @@ -25,8 +25,8 @@
From d836678d834a482f07648c1120b76b79e27261fa Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Mon, 1 Nov 2021 17:46:20 +0800 Subject: [PATCH 9/9] fix-659 --- routers/repo/modelarts.go | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index 86287e0b6..b37af704d 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -528,6 +528,15 @@ func TrainJobIndex(ctx *context.Context) { } func TrainJobNew(ctx *context.Context) { + err := trainJobNewDataPrepare(ctx) + if err != nil { + ctx.ServerError("get new train-job info failed", err) + return + } + ctx.HTML(200, tplModelArtsTrainJobNew) +} + +func trainJobNewDataPrepare(ctx *context.Context) error { ctx.Data["PageIsCloudBrain"] = true //can, err := canUserCreateTrainJob(ctx.User.ID) @@ -549,35 +558,35 @@ func TrainJobNew(ctx *context.Context) { attachs, err := models.GetModelArtsUserAttachments(ctx.User.ID) if err != nil { ctx.ServerError("GetAllUserAttachments failed:", err) - return + return err } ctx.Data["attachments"] = attachs var resourcePools modelarts.ResourcePool if err = json.Unmarshal([]byte(setting.ResourcePools), &resourcePools); err != nil { ctx.ServerError("json.Unmarshal failed:", err) - return + return err } ctx.Data["resource_pools"] = resourcePools.Info var engines modelarts.Engine if err = json.Unmarshal([]byte(setting.Engines), &engines); err != nil { ctx.ServerError("json.Unmarshal failed:", err) - return + return err } ctx.Data["engines"] = engines.Info var versionInfos modelarts.VersionInfo if err = json.Unmarshal([]byte(setting.EngineVersions), &versionInfos); err != nil { ctx.ServerError("json.Unmarshal failed:", err) - return + return err } ctx.Data["engine_versions"] = versionInfos.Version var flavorInfos modelarts.Flavor if err = json.Unmarshal([]byte(setting.TrainJobFLAVORINFOS), &flavorInfos); err != nil { ctx.ServerError("json.Unmarshal failed:", err) - return + return err } ctx.Data["flavor_infos"] = flavorInfos.Info @@ -587,12 +596,12 @@ func TrainJobNew(ctx *context.Context) { configList, err := getConfigList(modelarts.PerPage, 1, modelarts.SortByCreateTime, "desc", "", modelarts.ConfigTypeCustom) if err != nil { ctx.ServerError("getConfigList failed:", err) - return + return err } ctx.Data["config_list"] = configList.ParaConfigs - ctx.HTML(200, tplModelArtsTrainJobNew) + return nil } func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) { @@ -629,12 +638,14 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) //param check if err := paramCheckCreateTrainJob(form); err != nil { log.Error("paramCheckCreateTrainJob failed:(%v)", err) + trainJobNewDataPrepare(ctx) ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobNew, &form) return } if err := git.Clone(repo.RepoPath(), codeLocalPath, git.CloneRepoOptions{}); err != nil { log.Error("Failed to clone repository: %s (%v)", repo.FullName(), err) + trainJobNewDataPrepare(ctx) ctx.RenderWithErr("Failed to clone repository", tplModelArtsTrainJobNew, &form) return } @@ -642,18 +653,21 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) //todo: upload code (send to file_server todo this work?) if err := obsMkdir(setting.CodePathPrefix + jobName + modelarts.OutputPath); err != nil { log.Error("Failed to obsMkdir_output: %s (%v)", repo.FullName(), err) + trainJobNewDataPrepare(ctx) ctx.RenderWithErr("Failed to obsMkdir_output", tplModelArtsTrainJobNew, &form) return } if err := obsMkdir(setting.CodePathPrefix + jobName + modelarts.LogPath); err != nil { log.Error("Failed to obsMkdir_log: %s (%v)", repo.FullName(), err) + trainJobNewDataPrepare(ctx) ctx.RenderWithErr("Failed to obsMkdir_log", tplModelArtsTrainJobNew, &form) return } if err := uploadCodeToObs(codeLocalPath, jobName, ""); err != nil { log.Error("Failed to uploadCodeToObs: %s (%v)", repo.FullName(), err) + trainJobNewDataPrepare(ctx) ctx.RenderWithErr("Failed to uploadCodeToObs", tplModelArtsTrainJobNew, &form) return } @@ -673,6 +687,7 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) err := json.Unmarshal([]byte(params), ¶meters) if err != nil { log.Error("Failed to Unmarshal params: %s (%v)", params, err) + trainJobNewDataPrepare(ctx) ctx.RenderWithErr("运行参数错误", tplModelArtsTrainJobNew, &form) return } @@ -691,6 +706,7 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) if isSaveParam == "on" { if form.ParameterTemplateName == "" { log.Error("ParameterTemplateName is empty") + trainJobNewDataPrepare(ctx) ctx.RenderWithErr("保存作业参数时,作业参数名称不能为空", tplModelArtsTrainJobNew, &form) return } @@ -714,6 +730,7 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) if err != nil { log.Error("Failed to CreateTrainJobConfig: %v", err) + trainJobNewDataPrepare(ctx) ctx.RenderWithErr("保存作业参数失败:"+err.Error(), tplModelArtsTrainJobNew, &form) return } @@ -738,6 +755,7 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) err := modelarts.GenerateTrainJob(ctx, req) if err != nil { log.Error("GenerateTrainJob failed:%v", err.Error()) + trainJobNewDataPrepare(ctx) ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobNew, &form) return }