From a2ecaf7570b9eb32958b1975fb944ea888b37397 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Thu, 17 Mar 2022 12:33:34 +0800 Subject: [PATCH 01/27] #1627 update --- options/locale/locale_en-US.ini | 12 ++++++ options/locale/locale_zh-CN.ini | 13 ++++++ .../repo/cloudbrain/benchmark/index.tmpl | 40 +++++++++---------- templates/repo/debugjob/index.tmpl | 10 ++--- .../repo/modelarts/inferencejob/index.tmpl | 34 ++++++++-------- templates/repo/modelarts/trainjob/index.tmpl | 34 ++++++++-------- 6 files changed, 84 insertions(+), 59 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index cb8fd7e15..a0acb05ec 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -984,6 +984,18 @@ modelarts.infer_job.model_version = Model/Version modelarts.infer_job.select_model = Select Model modelarts.infer_job.tooltip = The model has been deleted and cannot be viewed. + +debug_task_not_created = Debug task has not been created +train_task_not_created = Train task has not been created +inference_job_not_created = Inference job has not been created +model_Evaluation_not_created = Model evaluation has not been created +repo_not_initialized = Code version: You have not initialized the code repository, please initialized first ; +debug_task_running_limit =Running time: no more than 4 hours, it will automatically stop if it exceeds 4 hours; +dataset_desc = Dataset: Cloud Brain 1 provides CPU/GPU,Cloud Brain 2 provides Ascend NPU.Dataset also needs to be uploaded to the corresponding environment; +platform_instructions = Instructions for use: You can refer to the Xiaobai training camp course of Qizhi AI collaboration platform. +model_not_exist = Model file: You do not have a model file yet, please generate and export the model through the training task first ; +benchmark_leaderboards = Benchmark leaderboards + model.manage.import_new_model=Import New Model model.manage.create_error=Equal Name and Version has existed. model.manage.model_name = Model Name diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index b356e0d5b..fd5cde4d1 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -993,6 +993,18 @@ modelarts.infer_job.select_model = 选择模型 modelarts.infer_job.boot_file_helper=启动文件是您程序执行的入口文件,必须是以.py结尾的文件。比如inference.py、main.py、example/inference.py、case/main.py。 modelarts.infer_job.tooltip = 该模型已删除,无法查看。 + +debug_task_not_created = 未创建过调试任务 +train_task_not_created = 未创建过训练任务 +inference_job_not_created = 未创建过推理任务 +model_Evaluation_not_created = 未创建过评测任务 +repo_not_initialized = 代码版本:您还没有初始化代码仓库,请先创建代码版本; +debug_task_running_limit = 运行时长:最长不超过4个小时,超过4个小时将自动停止; +dataset_desc = 数据集:云脑1提供 CPU / GPU 资源,云脑2提供 Ascend NPU 资源,调试使用的数据集也需要上传到对应的环境; +platform_instructions = 使用说明:可以参考启智AI协作平台小白训练营课程。 +model_not_exist = 模型文件:您还没有模型文件,请先通过训练任务产生并 导出模型 ; +benchmark_leaderboards = 基准测试排行榜 + model.manage.import_new_model=导入新模型 model.manage.create_error=相同的名称和版本的模型已经存在。 model.manage.model_name = 模型名称 @@ -2825,3 +2837,4 @@ snn4imagenet_path = snn4imagenet脚本存放路径 brainscore_path = brainscore脚本存放路径 start_command = 启动命令 choose_mirror = 选择镜像或输入镜像地址 + diff --git a/templates/repo/cloudbrain/benchmark/index.tmpl b/templates/repo/cloudbrain/benchmark/index.tmpl index f66b94f20..902a04fac 100755 --- a/templates/repo/cloudbrain/benchmark/index.tmpl +++ b/templates/repo/cloudbrain/benchmark/index.tmpl @@ -39,8 +39,8 @@
- 基准测试排行榜 - {{if .Permission.CanWrite $.UnitTypeCloudBrain}} + {{$.i18n.Tr "repo.benchmark_leaderboards"}} + {{if .Permission.CanWrite $.UnitTypeCloudBrain}} {{$.i18n.Tr "repo.modelarts.evaluate_job.new_job"}} {{else}} {{$.i18n.Tr "repo.modelarts.evaluate_job.new_job"}} @@ -50,12 +50,12 @@ {{if eq 0 (len .Tasks)}}
-
未创建过评测任务
+
{{$.i18n.Tr "repo.model_Evaluation_not_created"}}
{{if $.RepoIsEmpty}} -
代码版本:您还没有初始化代码仓库,请先创建代码版本;
+
{{$.i18n.Tr "repo.repo_not_initialized" .RepoLink | Safe}}
{{end}} -
使用说明:可以参考启智AI协作平台小白训练营课程。
+
{{$.i18n.Tr "repo.platform_instructions" | Safe}}
{{else}} @@ -85,21 +85,21 @@ {{$.i18n.Tr "repo.cloudbrain_status_runtime"}}
- {{$.i18n.Tr "repo.modelarts.computing_resources"}} + {{$.i18n.Tr "repo.modelarts.computing_resources"}}
- {{$.i18n.Tr "repo.cloudbrain_creator"}} + {{$.i18n.Tr "repo.cloudbrain_creator"}}
{{$.i18n.Tr "repo.cloudbrain_operate"}}
- - + + {{range .Tasks}}
diff --git a/templates/repo/debugjob/index.tmpl b/templates/repo/debugjob/index.tmpl index ddc924df9..1b6f0ffc6 100755 --- a/templates/repo/debugjob/index.tmpl +++ b/templates/repo/debugjob/index.tmpl @@ -242,14 +242,14 @@ {{if eq 0 (len .Tasks)}}
-
未创建过调试任务
+
{{$.i18n.Tr "repo.debug_task_not_created"}}
{{if $.RepoIsEmpty}} -
代码版本:您还没有初始化代码仓库,请先创建代码版本
+
{{$.i18n.Tr "repo.repo_not_initialized" .RepoLink | Safe}}
{{end}} -
运行时长:最长不超过4个小时,超过4个小时将自动停止;
-
数据集:云脑1提供 CPU / GPU 资源,云脑2提供 Ascend NPU 资源,调试使用的数据集也需要上传到对应的环境;
-
使用说明:可以参考启智AI协作平台小白训练营课程。
+
{{$.i18n.Tr "repo.debug_task_running_limit"}}
+
{{$.i18n.Tr "repo.dataset_desc"}}
+
{{$.i18n.Tr "repo.platform_instructions" | Safe}}
{{else}} diff --git a/templates/repo/modelarts/inferencejob/index.tmpl b/templates/repo/modelarts/inferencejob/index.tmpl index 68ba3c831..5e2ecd730 100644 --- a/templates/repo/modelarts/inferencejob/index.tmpl +++ b/templates/repo/modelarts/inferencejob/index.tmpl @@ -39,7 +39,7 @@
- {{if .Permission.CanWrite $.UnitTypeCloudBrain}} + {{if .Permission.CanWrite $.UnitTypeCloudBrain}} {{$.i18n.Tr "repo.modelarts.train_job.new_infer"}} {{else}} {{$.i18n.Tr "repo.modelarts.train_job.new_infer"}} @@ -49,16 +49,16 @@ {{if eq 0 (len .Tasks)}}
-
未创建过推理任务
+
{{$.i18n.Tr "repo.inference_job_not_created"}}
{{if $.RepoIsEmpty}} -
代码版本:您还没有初始化代码仓库,请先创建代码版本;
+
{{$.i18n.Tr "repo.repo_not_initialized" .RepoLink | Safe}}
{{end}} {{if eq 0 $.MODEL_COUNT}} -
模型文件:您还没有模型文件,请先通过训练任务产生并 导出模型
+
{{$.i18n.Tr "repo.model_not_exist" .RepoLink .RepoLink | Safe}}
{{end}} -
数据集:云脑1提供 CPU / GPU 资源,云脑2提供 Ascend NPU 资源,调试使用的数据集也需要上传到对应的环境;
-
使用说明:可以参考启智AI协作平台小白训练营课程。
+
{{$.i18n.Tr "repo.dataset_desc"}}
+
{{$.i18n.Tr "repo.platform_instructions" | Safe}}
{{else}} @@ -88,32 +88,32 @@ {{$.i18n.Tr "repo.cloudbrain_status_runtime"}}
- {{$.i18n.Tr "repo.cloudbrain_creator"}} + {{$.i18n.Tr "repo.cloudbrain_creator"}}
{{$.i18n.Tr "repo.cloudbrain_operate"}}
- - + + {{range .Tasks}}
- + -
- {{.ModelName}}  {{.ModelVersion}} +
+ {{.ModelName}}  {{.ModelVersion}}
@@ -126,12 +126,12 @@ {{TimeSinceUnix .Cloudbrain.CreatedUnix $.Lang}}
-
- {{.TrainJobDuration}} +
+ {{.TrainJobDuration}}
diff --git a/templates/repo/modelarts/trainjob/index.tmpl b/templates/repo/modelarts/trainjob/index.tmpl index ed94c0598..db077bebc 100755 --- a/templates/repo/modelarts/trainjob/index.tmpl +++ b/templates/repo/modelarts/trainjob/index.tmpl @@ -39,7 +39,7 @@
- {{if .Permission.CanWrite $.UnitTypeCloudBrain}} + {{if .Permission.CanWrite $.UnitTypeCloudBrain}} {{$.i18n.Tr "repo.modelarts.train_job.new_train"}} {{else}} {{$.i18n.Tr "repo.modelarts.train_job.new_train"}} @@ -49,13 +49,13 @@ {{if eq 0 (len .Tasks)}}
-
未创建过训练任务
+
{{$.i18n.Tr "repo.train_task_not_created"}}
{{if $.RepoIsEmpty}} -
代码版本:您还没有初始化代码仓库,请先创建代码版本;
+
{{$.i18n.Tr "repo.repo_not_initialized" .RepoLink | Safe}}
{{end}} -
数据集:云脑1提供 CPU / GPU 资源,云脑2提供 Ascend NPU 资源,调试使用的数据集也需要上传到对应的环境;
-
使用说明:可以参考启智AI协作平台小白训练营课程。
+
{{$.i18n.Tr "repo.dataset_desc"}}
+
{{$.i18n.Tr "repo.platform_instructions" | Safe}}
{{else}} @@ -85,31 +85,31 @@ {{$.i18n.Tr "repo.cloudbrain_status_runtime"}}
- {{$.i18n.Tr "repo.modelarts.computing_resources"}} + {{$.i18n.Tr "repo.modelarts.computing_resources"}}
- {{$.i18n.Tr "repo.cloudbrain_creator"}} + {{$.i18n.Tr "repo.cloudbrain_creator"}}
{{$.i18n.Tr "repo.cloudbrain_operate"}}
-
-
+
+ {{range .Tasks}}
- + -
- {{.VersionCount}} +
+ {{.VersionCount}}
@@ -122,12 +122,12 @@ {{TimeSinceUnix .Cloudbrain.CreatedUnix $.Lang}}
-
- {{.TrainJobDuration}} +
+ {{.TrainJobDuration}}
- {{.ComputeResource}} + {{.ComputeResource}}
@@ -205,4 +205,4 @@
-{{template "base/footer" .}} \ No newline at end of file +{{template "base/footer" .}} From edf4ff3815ed931a36469daea3e89a9b8babc7fc Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Fri, 18 Mar 2022 19:22:53 +0800 Subject: [PATCH 02/27] #1627 update --- options/locale/locale_en-US.ini | 30 ++++- options/locale/locale_zh-CN.ini | 24 ++++ templates/admin/cloudbrain/list.tmpl | 46 +++---- templates/explore/repo_left.tmpl | 28 ++-- templates/explore/repo_list.tmpl | 4 +- .../repo/cloudbrain/benchmark/index.tmpl | 8 +- templates/repo/cloudbrain/benchmark/new.tmpl | 30 ++--- templates/repo/cloudbrain/benchmark/show.tmpl | 86 ++++++------ templates/repo/cloudbrain/new.tmpl | 4 +- templates/repo/debugjob/index.tmpl | 8 +- .../repo/modelarts/inferencejob/index.tmpl | 8 +- .../repo/modelarts/inferencejob/new.tmpl | 46 +++---- .../repo/modelarts/inferencejob/show.tmpl | 118 ++++++++--------- templates/repo/modelarts/trainjob/index.tmpl | 8 +- templates/repo/modelarts/trainjob/new.tmpl | 42 +++--- .../repo/modelarts/trainjob/para_manage.tmpl | 30 ++--- templates/repo/modelarts/trainjob/show.tmpl | 122 +++++++++--------- .../repo/modelarts/trainjob/version_new.tmpl | 42 +++--- templates/repo/modelmanage/index.tmpl | 22 ++-- 19 files changed, 378 insertions(+), 328 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index a0acb05ec..aba6bfbf3 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -273,6 +273,20 @@ code_search_results = Search results for '%s' code_last_indexed_at = Last indexed %s save=Save cancel=Cancel +hot_repo=Hot Repositories +active_repo=Active Repositories +all_fields = All fields +large_model = Large model +ai_development_tools = AI tools +computer_version = Computer version +natural_language_processing = NLP +machine_learning = Machine learning +neural_networks = Neural networks +autopilot = Autopilot +robot = Robot +federated_learning = Federated learning +data_mining = Data mining +RISC-V_development = RISC-V development [auth] create_new_account = Register Account @@ -982,6 +996,7 @@ modelarts.infer_job_model_file = Model File modelarts.infer_job = Inference Job modelarts.infer_job.model_version = Model/Version modelarts.infer_job.select_model = Select Model +modelarts.infer_job.boot_file_helper=The startup file is the entry file for your program execution and must end in.py.Such as inference.py, main.py, example/inference. Py, case/main.py. modelarts.infer_job.tooltip = The model has been deleted and cannot be viewed. @@ -991,7 +1006,7 @@ inference_job_not_created = Inference job has not been created model_Evaluation_not_created = Model evaluation has not been created repo_not_initialized = Code version: You have not initialized the code repository, please initialized first ; debug_task_running_limit =Running time: no more than 4 hours, it will automatically stop if it exceeds 4 hours; -dataset_desc = Dataset: Cloud Brain 1 provides CPU/GPU,Cloud Brain 2 provides Ascend NPU.Dataset also needs to be uploaded to the corresponding environment; +dataset_desc = Dataset: Cloud Brain 1 provides CPU/GPU,Cloud Brain 2 provides Ascend NPU.And dataset also needs to be uploaded to the corresponding environment; platform_instructions = Instructions for use: You can refer to the Xiaobai training camp course of Qizhi AI collaboration platform. model_not_exist = Model file: You do not have a model file yet, please generate and export the model through the training task first ; benchmark_leaderboards = Benchmark leaderboards @@ -2828,4 +2843,15 @@ benchmark_path = Benchmark script path snn4imagenet_path = Snn4imagenet script path brainscore_path = Brainscore script path start_command = Start command -choose_mirror = select mirror +choose_mirror = select mirror or enter mirror path + +job_name_rule = Please enter letters, numbers, _ and - up to 64 characters and cannot end with a dash (-). +dataset_path_rule = The dataset location is stored in the environment variable data_url, and the training output path is stored in the environment variable train_url. +view_sample = View sample +inference_output_path_rule = The inference output path is stored in the environment variable result_url. +model_file_path_rule=The model file location is stored in the environment variable ckpt_url + +delete_task = Delete task +task_delete_confirm = Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered. +operate_confirm = confirm +operate_cancel = cancel diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index fd5cde4d1..5a86801d0 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -275,6 +275,20 @@ code_search_results=“%s” 的搜索结果是 code_last_indexed_at=最后索引于 %s save=保存 cancel=取消 +hot_repo=热门项目 +active_repo=活跃项目 +all_fields = 全部领域 +large_model = 大模型 +ai_development_tools = AI开发工具 +computer_version = 计算机视觉 +natural_language_processing = 自然语言处理 +machine_learning = 机器学习 +neural_networks = 神经网络 +autopilot = 自动驾驶 +robot = 机器人 +federated_learning = 联邦学习 +data_mining = 数据挖掘 +RISC-V_development = RISC-V开发 [auth] create_new_account=注册帐号 @@ -2838,3 +2852,13 @@ brainscore_path = brainscore脚本存放路径 start_command = 启动命令 choose_mirror = 选择镜像或输入镜像地址 +job_name_rule = 请输入字母、数字、_和-,最长64个字符,且不能以中划线(-)结尾。 +dataset_path_rule = 数据集位置存储在环境变量data_url中,训练输出路径存储在环境变量train_url中。 +view_sample = 查看样例 +inference_output_path_rule = 推理输出路径存储在环境变量result_url中。 +model_file_path_rule = 模型文件位置存储在环境变量ckpt_url中。 + +delete_task = 删除任务 +task_delete_confirm = 你确认删除该任务么?此任务一旦删除不可恢复。 +operate_confirm = 确定操作 +operate_cancel = 取消操作 diff --git a/templates/admin/cloudbrain/list.tmpl b/templates/admin/cloudbrain/list.tmpl index 9aac97e70..39b2c21de 100644 --- a/templates/admin/cloudbrain/list.tmpl +++ b/templates/admin/cloudbrain/list.tmpl @@ -43,26 +43,26 @@ {{$.i18n.Tr "repo.cloudbrain_status_runtime"}}
- {{$.i18n.Tr "repo.modelarts.computing_resources"}} + {{$.i18n.Tr "repo.modelarts.computing_resources"}}
- {{$.i18n.Tr "repo.cloudbrain_creator"}} + {{$.i18n.Tr "repo.cloudbrain_creator"}}
- {{$.i18n.Tr "repository"}} + {{$.i18n.Tr "repository"}}
- {{.i18n.Tr "admin.cloudbrain.cloudbrain_name"}} + {{.i18n.Tr "admin.cloudbrain.cloudbrain_name"}}
{{$.i18n.Tr "repo.cloudbrain_operate"}}
-
- + + {{range .Tasks}} {{if .Repo}}
-
+
{{$JobID := '0'}} {{if eq .JobType "DEBUG" "SNN4IMAGENET" "BRAINSCORE" "BENCHMARK"}} @@ -91,8 +91,8 @@ {{end}}
-
- {{.JobType}} +
+ {{.JobType}}
@@ -105,12 +105,12 @@ {{TimeSinceUnix1 .Cloudbrain.CreatedUnix}}
-
- {{if .TrainJobDuration}}{{.TrainJobDuration}}{{else}}--{{end}} +
+ {{if .TrainJobDuration}}{{.TrainJobDuration}}{{else}}--{{end}}
- {{if .ComputeResource}}{{.ComputeResource}}{{else}}--{{end}} + {{if .ComputeResource}}{{.ComputeResource}}{{else}}--{{end}}
@@ -178,7 +178,7 @@ {{$JobID = .JobID}} {{end}}
-
+
{{if eq .JobType "DEBUG"}} @@ -200,8 +200,8 @@ {{end}}
-
- {{.JobType}} +
+ {{.JobType}}
@@ -214,12 +214,12 @@ {{TimeSinceUnix1 .Cloudbrain.CreatedUnix}}
-
- {{if .TrainJobDuration}}{{.TrainJobDuration}}{{else}}--{{end}} +
+ {{if .TrainJobDuration}}{{.TrainJobDuration}}{{else}}--{{end}}
- {{if .ComputeResource}}{{.ComputeResource}}{{else}}--{{end}} + {{if .ComputeResource}}{{.ComputeResource}}{{else}}--{{end}}
@@ -296,18 +296,18 @@
diff --git a/templates/explore/repo_left.tmpl b/templates/explore/repo_left.tmpl index ca6a3b3dd..66c46e1ba 100755 --- a/templates/explore/repo_left.tmpl +++ b/templates/explore/repo_left.tmpl @@ -4,73 +4,73 @@ - 全部领域 + {{.i18n.Tr "explore.all_fields"}} - 大模型 + {{.i18n.Tr "explore.large_model"}} - AI开发工具 + {{.i18n.Tr "explore.ai_development_tools"}} - 计算机视觉 + {{.i18n.Tr "explore.computer_version"}} - 自然语言处理 + {{.i18n.Tr "explore.natural_language_processing"}} - 机器学习 + {{.i18n.Tr "explore.machine_learning"}} - 神经网络 + {{.i18n.Tr "explore.neural_networks"}} - 自动驾驶 + {{.i18n.Tr "explore.autopilot"}} - 机器人 + {{.i18n.Tr "explore.robot"}} - 联邦学习 + {{.i18n.Tr "explore.federated_learning"}} - 数据挖掘 + {{.i18n.Tr "explore.data_mining"}} - RISC-V开发 - + {{.i18n.Tr "explore.RISC-V_development"}} +
-
\ No newline at end of file +
diff --git a/templates/explore/repo_list.tmpl b/templates/explore/repo_list.tmpl index 0e01186b0..b6bb49da9 100755 --- a/templates/explore/repo_list.tmpl +++ b/templates/explore/repo_list.tmpl @@ -44,13 +44,13 @@ - 热门{{.i18n.Tr "explore.repos"}} + {{.i18n.Tr "explore.hot_repo"}} - 活跃{{.i18n.Tr "explore.repos"}} + {{.i18n.Tr "explore.active_repo"}} {{end}} diff --git a/templates/repo/cloudbrain/benchmark/index.tmpl b/templates/repo/cloudbrain/benchmark/index.tmpl index 902a04fac..a816a3e2b 100755 --- a/templates/repo/cloudbrain/benchmark/index.tmpl +++ b/templates/repo/cloudbrain/benchmark/index.tmpl @@ -204,18 +204,18 @@
@@ -217,7 +217,7 @@ setChildType(); } } - + function validate(){ $('.ui.form') .form({ @@ -239,7 +239,7 @@ // $('.ui.page.dimmer').dimmer('show') document.getElementById("mask").style.display = "block" }, - onFailure: function(e){ + onFailure: function(e){ return false; } }) @@ -247,6 +247,6 @@ $('.ui.create_train_job.green.button').click(function(e) { - validate() + validate() }) - \ No newline at end of file + diff --git a/templates/repo/cloudbrain/benchmark/show.tmpl b/templates/repo/cloudbrain/benchmark/show.tmpl index a6c529597..3c8f91528 100755 --- a/templates/repo/cloudbrain/benchmark/show.tmpl +++ b/templates/repo/cloudbrain/benchmark/show.tmpl @@ -82,7 +82,7 @@ vertical-align: inherit; } .ti-text-form-label { - + padding-bottom: 20px; padding-right: 20px; color: #8a8e99; @@ -152,7 +152,7 @@ td, th { opacity: .45 !important; } .pad20{ - + border:0px !important; } .model_file_bread{ @@ -196,14 +196,14 @@ td, th {
- {{TimeSinceUnix1 .CreatedUnix}} - + {{TimeSinceUnix1 .CreatedUnix}} + {{$.i18n.Tr "repo.modelarts.status"}}: {{.Status}} {{$.i18n.Tr "repo.modelarts.train_job.dura_time"}}: {{$.duration}} - +
@@ -244,12 +244,12 @@ td, th {
- + - {{$.i18n.Tr "repo.modelarts.train_job.start_time"}} + {{$.i18n.Tr "repo.modelarts.train_job.start_time"}} - +
{{TimeSinceUnix1 .CreatedUnix}} @@ -258,9 +258,9 @@ td, th { - {{$.i18n.Tr "repo.modelarts.train_job.dura_time"}} + {{$.i18n.Tr "repo.modelarts.train_job.dura_time"}} - +
{{$.duration}} @@ -269,9 +269,9 @@ td, th { - 镜像 + 镜像 - +
{{.Image}} @@ -280,30 +280,30 @@ td, th { - 类型 + 类型 - +
{{$.BenchmarkTypeName}}
- - + +
- - + + - + - + - + - + - + - + - + - + --> - + - + - + - + - + - + - + - + - + - + - + - + - + " html += "" html += "" - + } html += "" html += "
训练程序
train.py @@ -314,19 +314,19 @@ td, th {
测试程序
test.py
- {{$.i18n.Tr "repo.modelarts.train_job.description"}} + {{$.i18n.Tr "repo.modelarts.train_job.description"}}
{{.Description}} @@ -336,9 +336,9 @@ td, th {
- {{$.i18n.Tr "repo.modelarts.train_job.standard"}} + {{$.i18n.Tr "repo.modelarts.train_job.standard"}}
{{$.resource_spec}} @@ -348,9 +348,9 @@ td, th {
- 创建者 + 创建者
{{.User.Name}} @@ -359,9 +359,9 @@ td, th {
- 子类型 + 子类型
{{$.BenchmarkChildTypeName}} @@ -373,7 +373,7 @@ td, th {
- +
@@ -386,11 +386,11 @@ td, th {

                             
- + - + - + @@ -400,24 +400,24 @@ td, th {
- - + + {{template "base/footer" .}} @@ -430,7 +430,7 @@ td, th { $(document).ready(function(){ $('.secondary.menu .item').tab(); }); - + let userName let repoPath let jobName @@ -454,5 +454,5 @@ td, th { document.getElementById("mask").style.display = "none" }); } - - \ No newline at end of file + + diff --git a/templates/repo/cloudbrain/new.tmpl b/templates/repo/cloudbrain/new.tmpl index 6b5388b5a..53ec56f8a 100755 --- a/templates/repo/cloudbrain/new.tmpl +++ b/templates/repo/cloudbrain/new.tmpl @@ -147,12 +147,12 @@
- +
- {{if .is_snn4imagenet_enabled}} diff --git a/templates/repo/debugjob/index.tmpl b/templates/repo/debugjob/index.tmpl index 1b6f0ffc6..ab6e266af 100755 --- a/templates/repo/debugjob/index.tmpl +++ b/templates/repo/debugjob/index.tmpl @@ -458,18 +458,18 @@
diff --git a/templates/repo/modelarts/inferencejob/index.tmpl b/templates/repo/modelarts/inferencejob/index.tmpl index 5e2ecd730..b9724d3d8 100644 --- a/templates/repo/modelarts/inferencejob/index.tmpl +++ b/templates/repo/modelarts/inferencejob/index.tmpl @@ -205,18 +205,18 @@
diff --git a/templates/repo/modelarts/inferencejob/new.tmpl b/templates/repo/modelarts/inferencejob/new.tmpl index 5bb7aee6d..6f174bbbb 100644 --- a/templates/repo/modelarts/inferencejob/new.tmpl +++ b/templates/repo/modelarts/inferencejob/new.tmpl @@ -68,9 +68,9 @@
- 请输入字母、数字、_和-,最长64个字符,且不能以中划线(-)结尾。 + {{.i18n.Tr "cloudbrain.job_name_rule"}}
- +
   @@ -107,7 +107,7 @@ - +
@@ -123,10 +123,10 @@
- +
- +
@@ -181,7 +181,7 @@ {{end}} - + @@ -195,9 +195,9 @@ - 查看样例 + {{.i18n.Tr "cloudbrain.view_sample"}} - +
   @@ -222,7 +222,7 @@ {{end}}
- + - 推理输出路径存储在环境变量result_url中。 + {{.i18n.Tr "cloudbrain.inference_output_path_rule"}}
@@ -255,7 +255,7 @@ {{.i18n.Tr "repo.cloudbrain.new"}} {{.i18n.Tr "repo.cloudbrain.cancel"}} -
+ @@ -283,7 +283,7 @@ $("#select_model").dropdown('set text',nameList[0]) $("#select_model").dropdown('set value',nameList[0],nameList[0]) } - + $('#select_model').removeClass("loading") }) // 根据选中的模型名称获取相应的模型版本 @@ -323,7 +323,7 @@ if(!element.IsDir && loadCheckpointFile.includes(ckptSuffix[ckptSuffix.length-1])){ html += `
${element.FileName}
` } - + }) $('#model_checkpoint').append(html) $("#select_model_checkpoint").removeClass("loading") @@ -332,7 +332,7 @@ $("#select_model_checkpoint").dropdown('set text',initVersionText) $("#select_model_checkpoint").dropdown('set value',initVersionValue,initVersionText,$('#model_name_version div.item:first-child')) }) - + $("input#ai_model_version").val(text) $("input#ai_model_label").val(label) @@ -348,15 +348,15 @@ } $('.question.circle.icon').hover(function(){ - $(this).popup('show') + $(this).popup('show') }); // 参数增加、删除、修改、保存 function Add_parameter(i){ value = '
' + - '
' + - ' ' + - '
' + + '
' + + ' ' + + '
' + '
' + '' + '
'+ @@ -366,7 +366,7 @@ '' + '
' $(".dynamic.field").append(value) - } + } $('#add_run_para').click(function(){ var len = $(".dynamic.field .two.fields").length @@ -459,7 +459,7 @@ onSuccess: function(){ document.getElementById("mask").style.display = "block" }, - onFailure: function(e){ + onFailure: function(e){ return false; } }) @@ -470,8 +470,8 @@ } } $('.ui.create_train_job.green.button').click(function(e) { - send_run_para() + send_run_para() get_name() validate() }) - \ No newline at end of file + diff --git a/templates/repo/modelarts/inferencejob/show.tmpl b/templates/repo/modelarts/inferencejob/show.tmpl index 4e221acd4..e11919b71 100644 --- a/templates/repo/modelarts/inferencejob/show.tmpl +++ b/templates/repo/modelarts/inferencejob/show.tmpl @@ -82,7 +82,7 @@ vertical-align: inherit; } .ti-text-form-label { - + padding-bottom: 20px; padding-right: 20px; color: #8a8e99; @@ -152,7 +152,7 @@ td, th { opacity: .45 !important; } .pad20{ - + border:0px !important; } .model_file_bread{ @@ -180,12 +180,12 @@ td, th { {{with .task}}
{{$.i18n.Tr "repo.modelarts.run_version"}}
{{.VersionName}} @@ -227,9 +227,9 @@ td, th {
- {{$.i18n.Tr "repo.modelarts.train_job.start_time"}} + {{$.i18n.Tr "repo.modelarts.train_job.start_time"}}
{{TimeSinceUnix1 .CreatedUnix}} @@ -238,9 +238,9 @@ td, th {
- {{$.i18n.Tr "repo.modelarts.train_job.dura_time"}} + {{$.i18n.Tr "repo.modelarts.train_job.dura_time"}}
{{.TrainJobDuration}} @@ -248,23 +248,23 @@ td, th {
- {{$.i18n.Tr "repo.modelarts.train_job.AI_driver"}} + {{$.i18n.Tr "repo.modelarts.train_job.AI_driver"}}
{{.EngineName}}
{{$.i18n.Tr "repo.model.manage.description"}}
{{if .Description}} @@ -279,7 +279,7 @@ td, th {
创建人
{{$.userName}} @@ -288,7 +288,7 @@ td, th {
- {{$.i18n.Tr "repo.modelarts.train_job.compute_node"}} + {{$.i18n.Tr "repo.modelarts.train_job.compute_node"}}
@@ -304,19 +304,19 @@ td, th {
- {{$.i18n.Tr "repo.modelarts.infer_job_model"}} + {{$.i18n.Tr "repo.modelarts.infer_job_model"}}
{{.ModelName}}   {{$.i18n.Tr "repo.modelarts.version"}}:{{.ModelVersion}}   - +
- {{$.i18n.Tr "repo.modelarts.infer_job_model_file"}} + {{$.i18n.Tr "repo.modelarts.infer_job_model_file"}}
@@ -328,10 +328,10 @@ td, th {
{{$.i18n.Tr "repo.modelarts.model_label"}}
- + {{if .LabelName}} {{range $.labelName}} {{.}} @@ -342,7 +342,7 @@ td, th {
{{$.i18n.Tr "repo.modelarts.code_version"}} @@ -358,7 +358,7 @@ td, th { {{$.i18n.Tr "repo.modelarts.train_job.start_file"}}
{{.BootFile}} @@ -367,9 +367,9 @@ td, th {
- {{$.i18n.Tr "repo.modelarts.infer_dataset"}} + {{$.i18n.Tr "repo.modelarts.infer_dataset"}}
{{.DatasetName}} @@ -378,9 +378,9 @@ td, th {
- {{$.i18n.Tr "repo.modelarts.train_job.run_parameter"}} + {{$.i18n.Tr "repo.modelarts.train_job.run_parameter"}}
{{if .Parameters}} @@ -393,9 +393,9 @@ td, th {
- {{$.i18n.Tr "repo.modelarts.train_job.standard"}} + {{$.i18n.Tr "repo.modelarts.train_job.standard"}}
{{.FlavorName}} @@ -407,10 +407,10 @@ td, th {
- + - +
- +
- +
@@ -434,34 +434,34 @@ td, th {
- +
- + {{end}} - - - - - + + + + +
@@ -493,7 +493,7 @@ function loadLog(version_name){ }); } function logScroll(version_name) { - + let container = document.querySelector(`#log${version_name}`) let scrollTop = container.scrollTop let scrollHeight = container.scrollHeight @@ -506,7 +506,7 @@ function logScroll(version_name) { $(`.message${version_name} #header`).text('您已翻阅至日志底部') $(`.message${version_name}`).css('display', 'block') setTimeout(function(){ - $(`.message${version_name}`).css('display', 'none') + $(`.message${version_name}`).css('display', 'none') }, 1000) }else{ if(end_line===data.EndLine){ @@ -514,9 +514,9 @@ function logScroll(version_name) { } else{ $(`#log${version_name} input[name=end_line]`).val(data.EndLine) - $(`#log${version_name}`).append('
' + data.Content) 
+                    $(`#log${version_name}`).append('
' + data.Content)
                 }
-                
+
             }
         }).fail(function(err) {
             console.log(err);
@@ -529,7 +529,7 @@ function logScroll(version_name) {
                 $(`.message${version_name} #header`).text('您已翻阅至日志顶部')
                 $(`.message${version_name}`).css('display', 'block')
                 setTimeout(function(){
-                    $(`.message${version_name}`).css('display', 'none')     
+                    $(`.message${version_name}`).css('display', 'none')
                 }, 1000)
             }else{
                 $(`#log${version_name} input[name=start_line]`).val(data.StartLine)   //如果变动就改变所对应的值
@@ -557,7 +557,7 @@ function loadModelFile(version_name,parents,filename,init){
     filename = filename || ''
     init = init || ''
     $.get(`/api/v1/repos/${userName}/${repoPath}/modelarts/inference-job/${jobID}/result_list?version_name=${version_name}&parentDir=${parents}`, (data) => {
-            $(`#dir_list${version_name}`).empty() 
+            $(`#dir_list${version_name}`).empty()
             renderDir(data,version_name)
             if(init==="init"){
                 $(`input[name=model${version_name}]`).val("")
@@ -565,7 +565,7 @@ function loadModelFile(version_name,parents,filename,init){
                 $(`#file_breadcrumb${version_name}`).empty()
                 let htmlBread = ""
                 htmlBread += `
result
` - htmlBread += "
/
" + htmlBread += "
/
" $(`#file_breadcrumb${version_name}`).append(htmlBread) }else{ renderBrend(version_name,parents,filename,init) @@ -573,7 +573,7 @@ function loadModelFile(version_name,parents,filename,init){ }).fail(function(err) { console.log(err,version_name); }); - + } function renderBrend(version_name,parents,filename,init){ if(init=="folder"){ @@ -586,9 +586,9 @@ function renderBrend(version_name,parents,filename,init){ }else{ $(`#file_breadcrumb${version_name} .active.section`).replaceWith(`${sectionName}`) } - + htmlBrend += `
${filename}
` - htmlBrend += "
/
" + htmlBrend += "
/
" $(`#file_breadcrumb${version_name}`).append(htmlBrend) $(`input[name=model${version_name}]`).val(parents) $(`input[name=modelback${version_name}]`).val(filename) @@ -599,7 +599,7 @@ function renderBrend(version_name,parents,filename,init){ $(`#file_breadcrumb${version_name} a.section:contains(${filename})`).replaceWith(`
${filename}
`) $(`#file_breadcrumb${version_name} div.section:contains(${filename})`).append("
/
") } - + } function renderDir(data,version_name){ let html="" @@ -638,14 +638,14 @@ function renderDir(data,version_name){ }else{ html += ""+ `${dirs_size}` + "" } - + html += "
" html += "" + data.Dirs[i].ModTime + "" html += "
" @@ -655,4 +655,4 @@ function renderDir(data,version_name){ html += "
" $(`#dir_list${version_name}`).append(html) } - \ No newline at end of file + diff --git a/templates/repo/modelarts/trainjob/index.tmpl b/templates/repo/modelarts/trainjob/index.tmpl index db077bebc..19c6b3841 100755 --- a/templates/repo/modelarts/trainjob/index.tmpl +++ b/templates/repo/modelarts/trainjob/index.tmpl @@ -188,18 +188,18 @@
diff --git a/templates/repo/modelarts/trainjob/new.tmpl b/templates/repo/modelarts/trainjob/new.tmpl index 0854f487c..6ec48bc7d 100755 --- a/templates/repo/modelarts/trainjob/new.tmpl +++ b/templates/repo/modelarts/trainjob/new.tmpl @@ -81,9 +81,9 @@
- 请输入字母、数字、_和-,最长64个字符,且不能以中划线(-)结尾。 + {{.i18n.Tr "cloudbrain.job_name_rule"}}
- +
@@ -91,7 +91,7 @@

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

- +
@@ -147,7 +147,7 @@ - 查看样例 + {{.i18n.Tr "cloudbrain.view_sample"}}
@@ -160,9 +160,9 @@ {{end}} - 数据集位置存储在环境变量data_url中,训练输出路径存储在环境变量train_url中。 + {{.i18n.Tr "cloudbrain.dataset_path_rule"}}
- +
{{.i18n.Tr "repo.modelarts.train_job.add_run_parameter"}} @@ -223,24 +223,24 @@
- +
- +
- +
{{.i18n.Tr "repo.cloudbrain.cancel"}}
- + - +
@@ -272,9 +272,9 @@ // 参数增加、删除、修改、保存 function Add_parameter(i){ value = '
' + - '
' + - ' ' + - '
' + + '
' + + ' ' + + '
' + '
' + '' + '
'+ @@ -284,7 +284,7 @@ '' + '
' $(".dynamic.field").append(value) - } + } $('#add_run_para').click(function(){ var len = $(".dynamic.field .two.fields").length @@ -310,7 +310,7 @@ $(this).find('input').each(function(){ parameters.push($(this).text()) }) - + }); $('.ui.parameter.modal') .modal('hide'); @@ -353,9 +353,9 @@ onChange: function(){ if ($('.ui.save.checkbox').checkbox('is checked')){ $('#save_para').removeClass("disabled") - + }else{ - $('#save_para').addClass("disabled") + $('#save_para').addClass("disabled") } } }); @@ -421,7 +421,7 @@ // $('.ui.page.dimmer').dimmer('show') document.getElementById("mask").style.display = "block" }, - onFailure: function(e){ + onFailure: function(e){ return false; } }) @@ -453,6 +453,6 @@ $('.ui.create_train_job.green.button').click(function(e) { get_name() send_run_para() - validate() + validate() }) - \ No newline at end of file + diff --git a/templates/repo/modelarts/trainjob/para_manage.tmpl b/templates/repo/modelarts/trainjob/para_manage.tmpl index e7e48f13b..64e769fa0 100755 --- a/templates/repo/modelarts/trainjob/para_manage.tmpl +++ b/templates/repo/modelarts/trainjob/para_manage.tmpl @@ -2,11 +2,11 @@
{{template "repo/header" .}} -
+
- {{template "repo/modelarts/navbar" .}} + {{template "repo/modelarts/navbar" .}} -
+

{{.i18n.Tr "repo.modelarts.train_job_para_admin"}}

@@ -29,7 +29,7 @@
- +
{{range .Tasks}} @@ -38,12 +38,12 @@ - - + +
{{.Status}}
@@ -59,7 +59,7 @@ 编辑
- +
@@ -69,7 +69,7 @@
- +
{{end}} {{template "base/paginate" .}} @@ -78,7 +78,7 @@
-
+
@@ -86,18 +86,18 @@
@@ -105,7 +105,7 @@
{{template "base/footer" .}} - \ No newline at end of file + diff --git a/templates/repo/modelarts/trainjob/version_new.tmpl b/templates/repo/modelarts/trainjob/version_new.tmpl index 0af0778ba..ed7334cac 100644 --- a/templates/repo/modelarts/trainjob/version_new.tmpl +++ b/templates/repo/modelarts/trainjob/version_new.tmpl @@ -97,7 +97,7 @@ {{end}}
- +
@@ -105,7 +105,7 @@

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

- +
@@ -119,7 +119,7 @@ {{end}} {{end}} - +
@@ -160,7 +160,7 @@ - 查看样例 + {{.i18n.Tr "cloudbrain.view_sample"}}
@@ -175,9 +175,9 @@ {{end}} {{end}} - 数据集位置存储在环境变量data_url中,训练输出路径存储在环境变量train_url中。 + {{.i18n.Tr "cloudbrain.dataset_path_rule"}}
- +
{{.i18n.Tr "repo.modelarts.train_job.add_run_parameter"}} @@ -243,24 +243,24 @@
- +
- +
- +
{{.i18n.Tr "repo.cloudbrain.cancel"}}
- + - +
@@ -298,9 +298,9 @@ // 参数增加、删除、修改、保存 function Add_parameter(i){ value = '
' + - '
' + - ' ' + - '
' + + '
' + + ' ' + + '
' + '
' + '' + '
'+ @@ -310,7 +310,7 @@ '' + '
' $(".dynamic.field").append(value) - } + } $('#add_run_para').click(function(){ var len = $(".dynamic.field .two.fields").length @@ -336,7 +336,7 @@ $(this).find('input').each(function(){ parameters.push($(this).text()) }) - + }); $('.ui.parameter.modal') .modal('hide'); @@ -379,9 +379,9 @@ onChange: function(){ if ($('.ui.save.checkbox').checkbox('is checked')){ $('#save_para').removeClass("disabled") - + }else{ - $('#save_para').addClass("disabled") + $('#save_para').addClass("disabled") } } }); @@ -535,7 +535,7 @@ // $('.ui.page.dimmer').dimmer('show') document.getElementById("mask").style.display = "block" }, - onFailure: function(e){ + onFailure: function(e){ return false; } }) @@ -569,6 +569,6 @@ $('.ui.create_train_job.green.button').click(function(e) { get_name() send_run_para() - validate() + validate() }) - \ No newline at end of file + diff --git a/templates/repo/modelmanage/index.tmpl b/templates/repo/modelmanage/index.tmpl index 66d66ef16..e270da017 100644 --- a/templates/repo/modelmanage/index.tmpl +++ b/templates/repo/modelmanage/index.tmpl @@ -38,7 +38,7 @@
训练任务:您还没创建过训练任务,请先创建训练任务
{{end}}
使用说明:可以参考启智AI协作平台小白训练营课程。
- +
@@ -79,10 +79,10 @@
- 取消操作 + {{.i18n.Tr "cloudbrain.operate_cancel"}}
- 确定操作 + {{.i18n.Tr "cloudbrain.operate_confirm"}}
@@ -99,7 +99,7 @@
-
+
@@ -149,8 +149,8 @@
- - + + @@ -179,7 +179,7 @@ $("#job-name").empty() createModelName() loadTrainList() - + }, onHide:function(){ document.getElementById("formId").reset(); @@ -188,7 +188,7 @@ $('.ui.dimmer').css({"background-color":""}) $('.ui.error.message').text() $('.ui.error.message').css('display','none') - + } }) .modal('show') @@ -233,7 +233,7 @@ $('#choice_model .default.text').text(data[0].DisplayJobName) $('#choice_model input[name="JobId"]').val(data[0].JobID) loadTrainVersion() - + }) } function loadTrainVersion(value){ @@ -251,7 +251,7 @@ $('#choice_version .default.text').text(data[0].VersionName) $('#choice_version input[name="VersionName"]').val(data[0].VersionName) } - + }) } From 7d1db8224353a483617c38b52361842c4fb5a7e3 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Mon, 21 Mar 2022 11:11:43 +0800 Subject: [PATCH 03/27] #1627 update --- options/locale/locale_en-US.ini | 11 ++++++- options/locale/locale_zh-CN.ini | 11 +++++++ .../repo/cloudbrain/benchmark/index.tmpl | 2 +- templates/repo/cloudbrain/benchmark/new.tmpl | 4 +-- templates/repo/cloudbrain/new.tmpl | 6 ++-- templates/repo/modelarts/notebook/new.tmpl | 32 +++++++++---------- 6 files changed, 43 insertions(+), 23 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index aba6bfbf3..6a6005bec 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -869,7 +869,7 @@ gpu_type_all=All model_download=Model Download submit_image=Submit Image download=Download - +score=score cloudbrain=Cloudbrain cloudbrain.new=New cloudbrain @@ -2844,6 +2844,10 @@ snn4imagenet_path = Snn4imagenet script path brainscore_path = Brainscore script path start_command = Start command choose_mirror = select mirror or enter mirror path +select_dataset = select dataset +specification = specification +select_specification = select specification +description = description job_name_rule = Please enter letters, numbers, _ and - up to 64 characters and cannot end with a dash (-). dataset_path_rule = The dataset location is stored in the environment variable data_url, and the training output path is stored in the environment variable train_url. @@ -2855,3 +2859,8 @@ delete_task = Delete task task_delete_confirm = Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered. operate_confirm = confirm operate_cancel = cancel + +gpu_num = GPU +cpu_num = CPU +memory = Memory +shared_memory = Shared Memory diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 5a86801d0..9a01ae4c8 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -874,6 +874,7 @@ gpu_type_all=全部 model_download=结果下载 submit_image=提交镜像 download=模型下载 +score=评分 cloudbrain=云脑 cloudbrain.new=新建任务 @@ -2851,6 +2852,10 @@ snn4imagenet_path = snn4imagenet脚本存放路径 brainscore_path = brainscore脚本存放路径 start_command = 启动命令 choose_mirror = 选择镜像或输入镜像地址 +select_dataset = 选择数据集 +specification = 规格 +select_specification = 选择资源规格 +description = 描述 job_name_rule = 请输入字母、数字、_和-,最长64个字符,且不能以中划线(-)结尾。 dataset_path_rule = 数据集位置存储在环境变量data_url中,训练输出路径存储在环境变量train_url中。 @@ -2862,3 +2867,9 @@ delete_task = 删除任务 task_delete_confirm = 你确认删除该任务么?此任务一旦删除不可恢复。 operate_confirm = 确定操作 operate_cancel = 取消操作 + +gpu_num = GPU数 +cpu_num = CPU数 +memory = 内存 +shared_memory = 共享内存 + diff --git a/templates/repo/cloudbrain/benchmark/index.tmpl b/templates/repo/cloudbrain/benchmark/index.tmpl index a816a3e2b..989e3bfd2 100755 --- a/templates/repo/cloudbrain/benchmark/index.tmpl +++ b/templates/repo/cloudbrain/benchmark/index.tmpl @@ -155,7 +155,7 @@ {{end}} - 评分 + {{$.i18n.Tr "repo.stop"}} diff --git a/templates/repo/cloudbrain/benchmark/new.tmpl b/templates/repo/cloudbrain/benchmark/new.tmpl index da04f4be1..e7b1f0a77 100755 --- a/templates/repo/cloudbrain/benchmark/new.tmpl +++ b/templates/repo/cloudbrain/benchmark/new.tmpl @@ -140,9 +140,9 @@
- {{range .benchmark_resource_specs}} - + {{end}}
diff --git a/templates/repo/cloudbrain/new.tmpl b/templates/repo/cloudbrain/new.tmpl index 53ec56f8a..7ef6d25e8 100755 --- a/templates/repo/cloudbrain/new.tmpl +++ b/templates/repo/cloudbrain/new.tmpl @@ -203,7 +203,7 @@
- {{range .attachments}} @@ -213,9 +213,9 @@
- {{range .resource_specs}} - + {{end}}
diff --git a/templates/repo/modelarts/notebook/new.tmpl b/templates/repo/modelarts/notebook/new.tmpl index 17e7ba569..a91d98af1 100755 --- a/templates/repo/modelarts/notebook/new.tmpl +++ b/templates/repo/modelarts/notebook/new.tmpl @@ -30,7 +30,7 @@
- +
- +
- - {{range .images}} {{end}} @@ -61,8 +61,8 @@
- - + + {{range .attachments}} @@ -80,7 +80,7 @@
-->
- +
-->
- +
@@ -118,8 +118,8 @@ form.onsubmit = function(e){ let value_task = $("input[name='display_job_name']").val() - - + + let re = /^[a-z0-9][a-z0-9-_]{1,36}$/ let flag = re.test(value_task) if(!flag){ @@ -128,12 +128,12 @@ $('#messageInfo p').text(str) return false } - + let min_value_task = value_task.toLowerCase() - + $("input[name='display_job_name']").attr("value",min_value_task) document.getElementById("mask").style.display = "block" - + } // 点击按钮后遮罩层显示 // function showmask() { @@ -169,10 +169,10 @@ for (let i=0;i \ No newline at end of file + From c37d41c2f5e04f56d0863cdac5a184c83ebb8cd5 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Mon, 21 Mar 2022 11:39:01 +0800 Subject: [PATCH 04/27] #1627 update --- options/locale/locale_en-US.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 6a6005bec..e01eddcd4 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -862,6 +862,7 @@ model_noright=No right model_rename=Duplicate model name, please modify model name. debug=Debug +debug_again=Restart stop=Stop delete=Delete more=More From 436d91b700816f24653a6cadc3795176ca7c6276 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Mon, 21 Mar 2022 14:57:57 +0800 Subject: [PATCH 05/27] fix issue --- templates/repo/debugjob/index.tmpl | 2 +- web_src/js/features/cloudrbanin.js | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/templates/repo/debugjob/index.tmpl b/templates/repo/debugjob/index.tmpl index ab6e266af..ddcccc926 100755 --- a/templates/repo/debugjob/index.tmpl +++ b/templates/repo/debugjob/index.tmpl @@ -208,7 +208,7 @@ {{template "repo/header" .}} {{template "base/alert" .}} - +
diff --git a/web_src/js/features/cloudrbanin.js b/web_src/js/features/cloudrbanin.js index d069c6840..216226e14 100644 --- a/web_src/js/features/cloudrbanin.js +++ b/web_src/js/features/cloudrbanin.js @@ -1,4 +1,6 @@ export default async function initCloudrain() { + let debug_button = $('.cloudbrain_debug').data('debug') + let debug_again_button = $('.cloudbrain_debug').data('debug-again') let timeid = window.setInterval(loadJobStatus, 15000); $(document).ready(loadJobStatus); function loadJobStatus() { @@ -24,7 +26,7 @@ export default async function initCloudrain() { finalState.includes(status) && $('#' + ID + '-stop').removeClass('blue').addClass('disabled') } if(status==="RUNNING"){ - $('#ai-debug-'+ID).removeClass('disabled').addClass('blue').text('调试').css("margin","0 1rem") + $('#ai-debug-'+ID).removeClass('disabled').addClass('blue').text(debug_button).css("margin","0 1rem") $('#model-image-'+ID).removeClass('disabled').addClass('blue') } if(status!=="RUNNING"){ @@ -36,7 +38,7 @@ export default async function initCloudrain() { $('#ai-debug-'+ID).removeClass('blue').addClass('disabled') } if(['STOPPED','FAILED','START_FAILED','CREATE_FAILED','SUCCEEDED'].includes(status)){ - $('#ai-debug-'+ID).removeClass('disabled').addClass('blue').text('再次调试').css("margin","0") + $('#ai-debug-'+ID).removeClass('disabled').addClass('blue').text(debug_again_button).css("margin","0") } if(["RUNNING","WAITING"].includes(status)){ $('#ai-stop-'+ID).removeClass('disabled').addClass('blue') @@ -114,7 +116,7 @@ export default async function initCloudrain() { $('#' + ID+'-icon').removeClass().addClass(res.status) $('#' + ID+ '-text').text(res.status) if(res.status==="STOPPED"){ - $('#ai-debug-'+ID).removeClass('disabled').addClass('blue').text("再次调试").css("margin","0") + $('#ai-debug-'+ID).removeClass('disabled').addClass('blue').text(debug_again_button).css("margin","0") $('#ai-image-'+ID).removeClass('blue').addClass('disabled') $('#ai-model-debug-'+ID).removeClass('blue').addClass('disabled') $('#ai-delete-'+ID).removeClass('disabled').addClass('blue') @@ -214,7 +216,7 @@ export default async function initCloudrain() { $('#' + ID+ '-text').text(res.status) $('#ai-debug-'+ID).removeClass('blue').addClass('disabled') $('#ai-delete-'+ID).removeClass('blue').addClass('disabled') - $('#ai-debug-'+ID).text("调试").css("margin","0 1rem") + $('#ai-debug-'+ID).text(debug_button).css("margin","0 1rem") } }else{ $('.alert').html(res.error_msg).removeClass('alert-success').addClass('alert-danger').show().delay(2000).fadeOut(); From a4ad2cb7c834c1121bb39c163f94f89cf8dc1284 Mon Sep 17 00:00:00 2001 From: wangjr Date: Mon, 21 Mar 2022 15:10:03 +0800 Subject: [PATCH 06/27] =?UTF-8?q?fix-1657=20=E5=89=8D=E7=AB=AF=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=B1=95=E7=A4=BA=E6=96=B0=E5=A2=9E=E5=8A=A0=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web_src/js/components/ProAnalysis.vue | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/web_src/js/components/ProAnalysis.vue b/web_src/js/components/ProAnalysis.vue index 88ea67d94..d92eb6df9 100755 --- a/web_src/js/components/ProAnalysis.vue +++ b/web_src/js/components/ProAnalysis.vue @@ -148,6 +148,31 @@ prop="contributor" label="贡献者数" align="center"> + + + + + + + + +
@@ -1140,6 +1165,17 @@ return "
" +value.user+ "" } + }, + transformTimestamp(timestamp){ + let a = new Date(timestamp*1000); + const date = new Date(a); + const Y = date.getFullYear() + '/'; + const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '/'; + const D = (date.getDate() < 10 ? '0'+date.getDate() : date.getDate()) + ' '; + const h = (date.getHours() < 10 ? '0'+date.getHours() : date.getHours()) + ':'; + const m = (date.getMinutes() <10 ? '0'+date.getMinutes() : date.getMinutes()); + const dateString = Y + M + D + h + m ;//+ s; + return dateString; }, }, From 8e11b7bef37661393998a4f9c327844a78301f40 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Mon, 21 Mar 2022 15:13:36 +0800 Subject: [PATCH 07/27] #1627 update --- options/locale/locale_en-US.ini | 2 ++ options/locale/locale_zh-CN.ini | 2 +- routers/repo/cloudbrain.go | 25 ++++++++++++++----------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index e01eddcd4..dbe9c8985 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -992,6 +992,8 @@ cloudbrain.benchmark.evaluate_child_type=Child Type cloudbrain.benchmark.evaluate_mirror=Mirror cloudbrain.benchmark.evaluate_train=Train Script cloudbrain.benchmark.evaluate_test=Test Script +cloudbrain.benchmark.types={"type":[{"id":1,"first":"Target detection","second":[{"id":1,"value":"None","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"yangzhx","repo_name":"detection_benchmark_script"}]},{"id":2,"first":"Target Re-identification","second":[{"id":1,"value":"Vehicle re-identification","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"},{"id":2,"value":"Image-based person re-identification","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"}]}]} + modelarts.infer_job_model = Model modelarts.infer_job_model_file = Model File modelarts.infer_job = Inference Job diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 9a01ae4c8..09cf839c7 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -998,7 +998,7 @@ cloudbrain.benchmark.evaluate_child_type=子类型 cloudbrain.benchmark.evaluate_mirror=镜像 cloudbrain.benchmark.evaluate_train=训练程序 cloudbrain.benchmark.evaluate_test=测试程序 - +cloudbrain.benchmark.types={"type":[{"id":1,"first":"目标检测","second":[{"id":1,"value":"无","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"yangzhx","repo_name":"detection_benchmark_script"}]},{"id":2,"first":"目标重识别","second":[{"id":1,"value":"车辆重识别","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"},{"id":2,"value":"基于图像的行人重识别","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"}]}]} modelarts.infer_job_model = 模型名称 modelarts.infer_job_model_file = 模型文件 diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 6e88b266d..78ea8ea72 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + "github.com/unknwon/i18n" "io" "net/http" "os" @@ -45,6 +46,8 @@ var ( benchmarkResourceSpecs *models.ResourceSpecs ) +const BENCHMARK_TYPE_CODE = "repo.cloudbrain.benchmark.types" + var jobNamePattern = regexp.MustCompile(`^[a-z0-9][a-z0-9-_]{1,34}[a-z0-9-]$`) // MustEnableDataset check if repository enable internal cb @@ -131,8 +134,8 @@ func cloudBrainNewDataPrepare(ctx *context.Context) error { ctx.Data["benchmark_categories"] = categories.Category if benchmarkTypes == nil { - if err := json.Unmarshal([]byte(setting.BenchmarkTypes), &benchmarkTypes); err != nil { - log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", setting.BenchmarkTypes, err, ctx.Data["MsgID"]) + if err := json.Unmarshal([]byte(i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE)), &benchmarkTypes); err != nil { + log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE), err, ctx.Data["MsgID"]) } } ctx.Data["benchmark_types"] = benchmarkTypes.BenchmarkType @@ -340,8 +343,8 @@ func CloudBrainRestart(ctx *context.Context) { func CloudBrainBenchMarkShow(ctx *context.Context) { if benchmarkTypes == nil { - if err := json.Unmarshal([]byte(setting.BenchmarkTypes), &benchmarkTypes); err != nil { - log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", setting.BenchmarkTypes, err, ctx.Data["MsgID"]) + if err := json.Unmarshal([]byte(i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE)), &benchmarkTypes); err != nil { + log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE), err, ctx.Data["MsgID"]) ctx.ServerError(err.Error(), err) return } @@ -1060,7 +1063,7 @@ func CloudBrainBenchmarkIndex(ctx *context.Context) { } if benchmarkTypes == nil { - if err := json.Unmarshal([]byte(setting.BenchmarkTypes), &benchmarkTypes); err != nil { + if err := json.Unmarshal([]byte(i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE)), &benchmarkTypes); err != nil { ctx.ServerError("Get BenchmarkTypes faild:", err) return } @@ -1103,8 +1106,8 @@ func GetChildTypes(ctx *context.Context) { re := make(map[string]interface{}) for { if benchmarkTypes == nil { - if err := json.Unmarshal([]byte(setting.BenchmarkTypes), &benchmarkTypes); err != nil { - log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", setting.BenchmarkTypes, err, ctx.Data["MsgID"]) + if err := json.Unmarshal([]byte(i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE)), &benchmarkTypes); err != nil { + log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE), err, ctx.Data["MsgID"]) re["errMsg"] = "system error" break } @@ -1141,11 +1144,11 @@ func CloudBrainBenchmarkNew(ctx *context.Context) { ctx.HTML(200, tplCloudBrainBenchmarkNew) } -func getBenchmarkAttachment(benchmarkTypeID, benchmarkChildTypeID int) (*models.BenchmarkDataset, error) { +func getBenchmarkAttachment(benchmarkTypeID, benchmarkChildTypeID int, ctx *context.Context) (*models.BenchmarkDataset, error) { var childInfo *models.BenchmarkDataset if benchmarkTypes == nil { - if err := json.Unmarshal([]byte(setting.BenchmarkTypes), &benchmarkTypes); err != nil { - log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", setting.BenchmarkTypes, err) + if err := json.Unmarshal([]byte(i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE)), &benchmarkTypes); err != nil { + log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE), err) return childInfo, err } } @@ -1265,7 +1268,7 @@ func CloudBrainBenchmarkCreate(ctx *context.Context, form auth.CreateCloudBrainF return } - childInfo, err := getBenchmarkAttachment(benchmarkTypeID, benchmarkChildTypeID) + childInfo, err := getBenchmarkAttachment(benchmarkTypeID, benchmarkChildTypeID, ctx) if err != nil { log.Error("getBenchmarkAttachment failed:%v", err, ctx.Data["MsgID"]) cloudBrainNewDataPrepare(ctx) From 71e43839eab41dbaa3476336151e83fb4de7a524 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Mon, 21 Mar 2022 15:22:52 +0800 Subject: [PATCH 08/27] #1627 update --- templates/repo/modelarts/inferencejob/new.tmpl | 4 ++-- templates/repo/modelarts/trainjob/new.tmpl | 4 ++-- templates/repo/modelarts/trainjob/version_new.tmpl | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/templates/repo/modelarts/inferencejob/new.tmpl b/templates/repo/modelarts/inferencejob/new.tmpl index 6f174bbbb..27d047783 100644 --- a/templates/repo/modelarts/inferencejob/new.tmpl +++ b/templates/repo/modelarts/inferencejob/new.tmpl @@ -171,12 +171,12 @@
     - {{if $.uuid}} {{end}} {{range .attachments}} - + {{end}} diff --git a/templates/repo/modelarts/trainjob/new.tmpl b/templates/repo/modelarts/trainjob/new.tmpl index 6ec48bc7d..8366f8a37 100755 --- a/templates/repo/modelarts/trainjob/new.tmpl +++ b/templates/repo/modelarts/trainjob/new.tmpl @@ -151,12 +151,12 @@
- {{if $.uuid}} {{end}} {{range .attachments}} - + {{end}} diff --git a/templates/repo/modelarts/trainjob/version_new.tmpl b/templates/repo/modelarts/trainjob/version_new.tmpl index ed7334cac..e69709a7c 100644 --- a/templates/repo/modelarts/trainjob/version_new.tmpl +++ b/templates/repo/modelarts/trainjob/version_new.tmpl @@ -164,12 +164,12 @@
- {{if .dataset_name}} {{end}} {{range .attachments}} - + {{if ne $.uuid .UUID}} {{end}} From e4390b601f51d3f00d7dceb9fc2122128d0bc5ea Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Mon, 21 Mar 2022 15:28:59 +0800 Subject: [PATCH 09/27] #1627 update --- templates/repo/modelarts/inferencejob/new.tmpl | 2 +- templates/repo/modelarts/trainjob/new.tmpl | 2 +- templates/repo/modelarts/trainjob/version_new.tmpl | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/repo/modelarts/inferencejob/new.tmpl b/templates/repo/modelarts/inferencejob/new.tmpl index 27d047783..5e7347abf 100644 --- a/templates/repo/modelarts/inferencejob/new.tmpl +++ b/templates/repo/modelarts/inferencejob/new.tmpl @@ -176,7 +176,7 @@ {{end}} {{range .attachments}} - + {{end}} diff --git a/templates/repo/modelarts/trainjob/new.tmpl b/templates/repo/modelarts/trainjob/new.tmpl index 8366f8a37..afa09cf29 100755 --- a/templates/repo/modelarts/trainjob/new.tmpl +++ b/templates/repo/modelarts/trainjob/new.tmpl @@ -156,7 +156,7 @@ {{end}} {{range .attachments}} - + {{end}} diff --git a/templates/repo/modelarts/trainjob/version_new.tmpl b/templates/repo/modelarts/trainjob/version_new.tmpl index e69709a7c..b7fcd36ad 100644 --- a/templates/repo/modelarts/trainjob/version_new.tmpl +++ b/templates/repo/modelarts/trainjob/version_new.tmpl @@ -169,7 +169,7 @@ {{end}} {{range .attachments}} - + {{if ne $.uuid .UUID}} {{end}} From 5db959d68f9ada7b50a1751b8391abdedbf31d83 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Mon, 21 Mar 2022 15:40:49 +0800 Subject: [PATCH 10/27] #1627 update --- 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 dbe9c8985..0b486117e 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -992,7 +992,7 @@ cloudbrain.benchmark.evaluate_child_type=Child Type cloudbrain.benchmark.evaluate_mirror=Mirror cloudbrain.benchmark.evaluate_train=Train Script cloudbrain.benchmark.evaluate_test=Test Script -cloudbrain.benchmark.types={"type":[{"id":1,"first":"Target detection","second":[{"id":1,"value":"None","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"yangzhx","repo_name":"detection_benchmark_script"}]},{"id":2,"first":"Target Re-identification","second":[{"id":1,"value":"Vehicle re-identification","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"},{"id":2,"value":"Image-based person re-identification","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"}]}]} +cloudbrain.benchmark.types={"type":[{"id":1,"rank_link":"https://git.openi.org.cn/benchmark/?username=admin&algType=detection","first":"Target detection","second":[{"id":1,"value":"None","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"yangzhx","repo_name":"detection_benchmark_script"}]},{"id":2,"rank_link":"https://git.openi.org.cn/benchmark/?username=admin&algType=reid","first":"Target re-identification","second":[{"id":1,"value":"Vehicle re-identification","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"},{"id":2,"value":"Image-based person re-identification","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"}]},{"id":3,"rank_link":"https://git.openi.org.cn/benchmark/?username=admin&algType=tracking","first":"Multi-target tracking","second":[{"id":1,"value":"None","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"lix07","repo_name":"MOT_benchmark_script"}]}]} modelarts.infer_job_model = Model modelarts.infer_job_model_file = Model File diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 09cf839c7..5ef5cb8e6 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -998,7 +998,7 @@ cloudbrain.benchmark.evaluate_child_type=子类型 cloudbrain.benchmark.evaluate_mirror=镜像 cloudbrain.benchmark.evaluate_train=训练程序 cloudbrain.benchmark.evaluate_test=测试程序 -cloudbrain.benchmark.types={"type":[{"id":1,"first":"目标检测","second":[{"id":1,"value":"无","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"yangzhx","repo_name":"detection_benchmark_script"}]},{"id":2,"first":"目标重识别","second":[{"id":1,"value":"车辆重识别","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"},{"id":2,"value":"基于图像的行人重识别","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"}]}]} +cloudbrain.benchmark.types={"type":[{"id":1,"rank_link":"https://git.openi.org.cn/benchmark/?username=admin&algType=detection","first":"目标检测","second":[{"id":1,"value":"无","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"yangzhx","repo_name":"detection_benchmark_script"}]},{"id":2,"rank_link":"https://git.openi.org.cn/benchmark/?username=admin&algType=reid","first":"目标重识别","second":[{"id":1,"value":"车辆重识别","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"},{"id":2,"value":"基于图像的行人重识别","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"}]},{"id":3,"rank_link":"https://git.openi.org.cn/benchmark/?username=admin&algType=tracking","first":"多目标跟踪","second":[{"id":1,"value":"无","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"lix07","repo_name":"MOT_benchmark_script"}]}]} modelarts.infer_job_model = 模型名称 modelarts.infer_job_model_file = 模型文件 From 4af02f5997955cea87ece96563213f0a234a250d Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Mon, 21 Mar 2022 16:23:33 +0800 Subject: [PATCH 11/27] #1627 fix bug --- routers/repo/cloudbrain.go | 58 ++++++++++++++------------------------ 1 file changed, 21 insertions(+), 37 deletions(-) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 78ea8ea72..65db818a0 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -48,6 +48,8 @@ var ( const BENCHMARK_TYPE_CODE = "repo.cloudbrain.benchmark.types" +var benchmarkTypesMap = make(map[string]*models.BenchmarkTypes, 0) + var jobNamePattern = regexp.MustCompile(`^[a-z0-9][a-z0-9-_]{1,34}[a-z0-9-]$`) // MustEnableDataset check if repository enable internal cb @@ -133,12 +135,7 @@ func cloudBrainNewDataPrepare(ctx *context.Context) error { } ctx.Data["benchmark_categories"] = categories.Category - if benchmarkTypes == nil { - if err := json.Unmarshal([]byte(i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE)), &benchmarkTypes); err != nil { - log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE), err, ctx.Data["MsgID"]) - } - } - ctx.Data["benchmark_types"] = benchmarkTypes.BenchmarkType + ctx.Data["benchmark_types"] = GetBenchmarkTypes(ctx).BenchmarkType if gpuInfos == nil { json.Unmarshal([]byte(setting.GpuTypes), &gpuInfos) @@ -342,13 +339,6 @@ func CloudBrainRestart(ctx *context.Context) { } func CloudBrainBenchMarkShow(ctx *context.Context) { - if benchmarkTypes == nil { - if err := json.Unmarshal([]byte(i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE)), &benchmarkTypes); err != nil { - log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE), err, ctx.Data["MsgID"]) - ctx.ServerError(err.Error(), err) - return - } - } cloudBrainShow(ctx, tplCloudBrainBenchmarkShow) } @@ -415,7 +405,7 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName) { duration = int64(task.UpdatedUnix) - int64(task.CreatedUnix) } if task.BenchmarkTypeID > 0 { - for _, benchmarkType := range benchmarkTypes.BenchmarkType { + for _, benchmarkType := range GetBenchmarkTypes(ctx).BenchmarkType { if task.BenchmarkTypeID == benchmarkType.Id { ctx.Data["BenchmarkTypeName"] = benchmarkType.First for _, benchmarkChildType := range benchmarkType.Second { @@ -1062,13 +1052,6 @@ func CloudBrainBenchmarkIndex(ctx *context.Context) { return } - if benchmarkTypes == nil { - if err := json.Unmarshal([]byte(i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE)), &benchmarkTypes); err != nil { - ctx.ServerError("Get BenchmarkTypes faild:", err) - return - } - } - for i, task := range ciTasks { ciTasks[i].CanDel = cloudbrain.CanDeleteJob(ctx, &task.Cloudbrain) ciTasks[i].Cloudbrain.ComputeResource = task.ComputeResource @@ -1081,7 +1064,7 @@ func CloudBrainBenchmarkIndex(ctx *context.Context) { ciTasks[i].TrainJobDuration = util.AddZero(duration/3600000) + ":" + util.AddZero(duration%3600000/60000) + ":" + util.AddZero(duration%60000/1000) ciTasks[i].BenchmarkTypeName = "" if task.BenchmarkTypeID > 0 { - for _, benchmarkType := range benchmarkTypes.BenchmarkType { + for _, benchmarkType := range GetBenchmarkTypes(ctx).BenchmarkType { if task.BenchmarkTypeID == benchmarkType.Id { ciTasks[i].BenchmarkTypeRankLink = benchmarkType.RankLink ciTasks[i].BenchmarkTypeName = benchmarkType.First @@ -1105,15 +1088,8 @@ func GetChildTypes(ctx *context.Context) { benchmarkTypeID := ctx.QueryInt("benchmark_type_id") re := make(map[string]interface{}) for { - if benchmarkTypes == nil { - if err := json.Unmarshal([]byte(i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE)), &benchmarkTypes); err != nil { - log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE), err, ctx.Data["MsgID"]) - re["errMsg"] = "system error" - break - } - } var isExist bool - for _, benchmarkType := range benchmarkTypes.BenchmarkType { + for _, benchmarkType := range GetBenchmarkTypes(ctx).BenchmarkType { if benchmarkTypeID == benchmarkType.Id { isExist = true re["child_types"] = benchmarkType.Second @@ -1146,15 +1122,9 @@ func CloudBrainBenchmarkNew(ctx *context.Context) { func getBenchmarkAttachment(benchmarkTypeID, benchmarkChildTypeID int, ctx *context.Context) (*models.BenchmarkDataset, error) { var childInfo *models.BenchmarkDataset - if benchmarkTypes == nil { - if err := json.Unmarshal([]byte(i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE)), &benchmarkTypes); err != nil { - log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE), err) - return childInfo, err - } - } var isExist bool - for _, benchmarkType := range benchmarkTypes.BenchmarkType { + for _, benchmarkType := range GetBenchmarkTypes(ctx).BenchmarkType { if benchmarkType.Id == benchmarkTypeID { for _, childType := range benchmarkType.Second { if childType.Id == benchmarkChildTypeID { @@ -1398,3 +1368,17 @@ func BenchmarkDel(ctx *context.Context) { ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/cloudbrain/benchmark") } } + +func GetBenchmarkTypes(ctx *context.Context) *models.BenchmarkTypes { + var lang = ctx.Locale.Language() + if benchmarkTypesMap[lang] == nil { + var val = i18n.Tr(lang, BENCHMARK_TYPE_CODE) + var tempType *models.BenchmarkTypes + if err := json.Unmarshal([]byte(val), &tempType); err != nil { + log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", val, err, ctx.Data["MsgID"]) + return &models.BenchmarkTypes{} + } + benchmarkTypesMap[lang] = tempType + } + return benchmarkTypesMap[lang] +} From d78c61488282d3801ae3c05effaf13448c1dab5d Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Mon, 21 Mar 2022 16:32:23 +0800 Subject: [PATCH 12/27] fix-1694 --- models/cloudbrain.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/cloudbrain.go b/models/cloudbrain.go index 06c2e98b4..f501d8e91 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -1117,7 +1117,7 @@ func Cloudbrains(opts *CloudbrainsOptions) ([]*CloudbrainInfo, int64, error) { } else { lowerKeyWord := strings.ToLower(opts.Keyword) - cond = cond.And(builder.Or(builder.Like{"LOWER(cloudbrain.job_name)", lowerKeyWord}, builder.Like{"`user`.lower_name", lowerKeyWord})) + cond = cond.And(builder.Or(builder.Like{"LOWER(cloudbrain.job_name)", lowerKeyWord}, builder.Like{"LOWER(cloudbrain.display_job_name)", lowerKeyWord}, builder.Like{"`user`.lower_name", lowerKeyWord})) count, err = sess.Table(&Cloudbrain{}).Where(cond). Join("left", "`user`", condition).Count(new(CloudbrainInfo)) From a63a22ea1c984078bdcc2080f35dd5edd250e5eb Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Tue, 22 Mar 2022 17:17:55 +0800 Subject: [PATCH 13/27] #1654 add task duration --- models/cloudbrain.go | 18 ++++++++++++++++-- routers/api/v1/repo/cloudbrain.go | 5 +++++ routers/repo/cloudbrain.go | 24 +++++++++++++++++++++++- routers/repo/modelarts.go | 5 +++++ 4 files changed, 49 insertions(+), 3 deletions(-) diff --git a/models/cloudbrain.go b/models/cloudbrain.go index f501d8e91..a7a0cbd98 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -150,6 +150,19 @@ type Cloudbrain struct { Repo *Repository `xorm:"-"` BenchmarkTypeName string `xorm:"-"` BenchmarkTypeRankLink string `xorm:"-"` + StartTime timeutil.TimeStamp + EndTime timeutil.TimeStamp +} + +func (task *Cloudbrain) ComputeDuration() int64 { + if task.StartTime == 0 || task.EndTime == 0 { + return 0 + } + d := task.EndTime.AsTime().Unix() - task.StartTime.AsTime().Unix() + if d < 0 { + d = 0 + } + return d } type CloudbrainInfo struct { @@ -1019,6 +1032,7 @@ type GetTrainJobResult struct { NasShareAddr string `json:"nas_share_addr"` DatasetName string ModelMetricList string `json:"model_metric_list"` //列表里包含f1_score,recall,precision,accuracy,若有的话 + StartTime int64 `json:"start_time"` //训练作业开始时间。 } type GetTrainJobLogResult struct { @@ -1327,13 +1341,13 @@ func GetCloudbrainByJobIDAndIsLatestVersion(jobID string, isLatestVersion string func GetCloudbrainsNeededStopByUserID(userID int64) ([]*Cloudbrain, error) { cloudBrains := make([]*Cloudbrain, 0) - err := x.Cols("job_id", "status", "type", "job_type", "version_id").Where("user_id=? AND status !=?", userID, string(JobStopped)).Find(&cloudBrains) + err := x.Cols("job_id", "status", "type", "job_type", "version_id", "start_time").Where("user_id=? AND status !=?", userID, string(JobStopped)).Find(&cloudBrains) return cloudBrains, err } func GetCloudbrainsNeededStopByRepoID(repoID int64) ([]*Cloudbrain, error) { cloudBrains := make([]*Cloudbrain, 0) - err := x.Cols("job_id", "status", "type", "job_type", "version_id").Where("repo_id=? AND status !=?", repoID, string(JobStopped)).Find(&cloudBrains) + err := x.Cols("job_id", "status", "type", "job_type", "version_id", "start_time").Where("repo_id=? AND status !=?", repoID, string(JobStopped)).Find(&cloudBrains) return cloudBrains, err } diff --git a/routers/api/v1/repo/cloudbrain.go b/routers/api/v1/repo/cloudbrain.go index f92259c3d..53a3d9545 100755 --- a/routers/api/v1/repo/cloudbrain.go +++ b/routers/api/v1/repo/cloudbrain.go @@ -6,6 +6,7 @@ package repo import ( + "code.gitea.io/gitea/modules/timeutil" "net/http" "sort" "time" @@ -77,6 +78,10 @@ func GetCloudbrainTask(ctx *context.APIContext) { job.ContainerIp = taskRes.TaskStatuses[0].ContainerIP job.ContainerID = taskRes.TaskStatuses[0].ContainerID job.Status = taskRes.TaskStatuses[0].State + + if job.StartTime == 0 { + job.StartTime = timeutil.TimeStamp(taskRes.TaskStatuses[0].StartAt.Unix()) + } } if result.JobStatus.State != string(models.JobWaiting) { diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 6e88b266d..86f111641 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -2,6 +2,7 @@ package repo import ( "bufio" + "code.gitea.io/gitea/modules/timeutil" "encoding/json" "errors" "fmt" @@ -380,6 +381,9 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName) { task.Status = taskRes.TaskStatuses[0].State task.ContainerID = taskRes.TaskStatuses[0].ContainerID task.ContainerIp = taskRes.TaskStatuses[0].ContainerIP + if task.StartTime == 0 { + task.StartTime = timeutil.TimeStamp(taskRes.TaskStatuses[0].StartAt.Unix()) + } err = models.UpdateJob(task) if err != nil { ctx.Data["error"] = err.Error() @@ -489,6 +493,8 @@ func CloudBrainStop(ctx *context.Context) { } task.Status = string(models.JobStopped) + task.EndTime = timeutil.TimeStampNow() + task.Duration = task.ComputeDuration() err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob(%s) failed:%v", task.JobName, err, ctx.Data["msgID"]) @@ -582,6 +588,8 @@ func logErrorAndUpdateJobStatus(err error, taskInfo *models.Cloudbrain) { log.Warn("Failed to stop cloudBrain job:"+taskInfo.JobID, err) } else { taskInfo.Status = string(models.JobStopped) + taskInfo.EndTime = timeutil.TimeStampNow() + taskInfo.Duration = taskInfo.ComputeDuration() err = models.UpdateJob(taskInfo) if err != nil { log.Warn("UpdateJob failed", err) @@ -953,6 +961,13 @@ func SyncCloudbrainStatus() { task.Status = taskRes.TaskStatuses[0].State if task.Status != string(models.JobWaiting) { task.Duration = time.Now().Unix() - taskRes.TaskStatuses[0].StartAt.Unix() + if task.StartTime == 0 { + task.StartTime = timeutil.TimeStamp(taskRes.TaskStatuses[0].StartAt.Unix()) + } + //if task.Status == string(models.JobFailed) { + // task.EndTime = timeutil.TimeStampNow() + // task.Duration = task.ComputeDuration() + //} err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob(%s) failed:%v", task.JobName, err) @@ -973,6 +988,8 @@ func SyncCloudbrainStatus() { continue } task.Status = string(models.JobStopped) + task.EndTime = timeutil.TimeStampNow() + task.Duration = task.ComputeDuration() err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob(%s) failed:%v", task.JobName, err) @@ -991,7 +1008,9 @@ func SyncCloudbrainStatus() { if result != nil { task.Status = result.Status - + if task.StartTime == 0 { + task.StartTime = timeutil.TimeStamp(result.Lease.CreateTime / 1000) + } err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob(%s) failed:%v", task.JobName, err) @@ -1010,6 +1029,9 @@ func SyncCloudbrainStatus() { task.Duration = result.Duration task.TrainJobDuration = result.TrainJobDuration + if task.StartTime == 0 { + task.StartTime = timeutil.TimeStamp(result.StartTime) + } if result.Duration != 0 { task.TrainJobDuration = util.AddZero(result.Duration/3600000) + ":" + util.AddZero(result.Duration%3600000/60000) + ":" + util.AddZero(result.Duration%60000/1000) diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index 9c670e203..6b5eeffbf 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -2,6 +2,7 @@ package repo import ( "archive/zip" + "code.gitea.io/gitea/modules/timeutil" "encoding/json" "errors" "io" @@ -408,6 +409,10 @@ func NotebookManage(ctx *context.Context) { } task.Status = res.Status + if task.Status == string(models.ModelArtsStopped) { + task.EndTime = timeutil.TimeStampNow() + task.Duration = task.ComputeDuration() + } err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob(%s) failed:%v", task.JobName, err.Error(), ctx.Data["MsgID"]) From e46903c41424b4d72bfb2d740e3c6001a9436489 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Tue, 22 Mar 2022 17:56:42 +0800 Subject: [PATCH 14/27] #1654 update --- routers/api/v1/repo/modelarts.go | 9 ++++++++- routers/repo/cloudbrain.go | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/routers/api/v1/repo/modelarts.go b/routers/api/v1/repo/modelarts.go index 893f2a32c..cc311c446 100755 --- a/routers/api/v1/repo/modelarts.go +++ b/routers/api/v1/repo/modelarts.go @@ -6,6 +6,7 @@ package repo import ( + "code.gitea.io/gitea/modules/timeutil" "net/http" "strconv" "strings" @@ -67,8 +68,14 @@ func GetModelArtsNotebook2(ctx *context.APIContext) { ctx.NotFound(err) return } - + if job.StartTime == 0 { + job.StartTime = timeutil.TimeStamp(result.Lease.CreateTime / 1000) + } job.Status = result.Status + if job.EndTime == 0 && job.Status == string(models.ModelArtsStopped) { + job.EndTime = timeutil.TimeStampNow() + job.Duration = job.ComputeDuration() + } err = models.UpdateJob(job) if err != nil { log.Error("UpdateJob failed:", err) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 86f111641..9225433cf 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -1011,6 +1011,10 @@ func SyncCloudbrainStatus() { if task.StartTime == 0 { task.StartTime = timeutil.TimeStamp(result.Lease.CreateTime / 1000) } + if task.EndTime == 0 && task.Status == string(models.ModelArtsStopped) { + task.EndTime = timeutil.TimeStampNow() + task.Duration = task.ComputeDuration() + } err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob(%s) failed:%v", task.JobName, err) From 89f38638483b36c094b2e8b121d4a9c0c88b6a25 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Wed, 23 Mar 2022 09:29:22 +0800 Subject: [PATCH 15/27] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=88=97=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/api/v1/repo/repo_dashbord.go | 38 ++++++++++++++-------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/routers/api/v1/repo/repo_dashbord.go b/routers/api/v1/repo/repo_dashbord.go index b1f344d55..2c42f8a16 100644 --- a/routers/api/v1/repo/repo_dashbord.go +++ b/routers/api/v1/repo/repo_dashbord.go @@ -292,41 +292,41 @@ func getFileName(ctx *context.Context, beginTime time.Time, endTime time.Time, p func allProjectsPeroidHeader(ctx *context.Context) map[string]string { - return map[string]string{"A1": ctx.Tr("admin.repos.id"), "B1": ctx.Tr("admin.repos.projectName"), "C1": ctx.Tr("repo.owner"), "D1": ctx.Tr("admin.repos.isPrivate"), "E1": ctx.Tr("admin.repos.isFork"), "F1": ctx.Tr("admin.repos.isMirror"), "G1": ctx.Tr("admin.repos.openi"), "H1": ctx.Tr("admin.repos.visit"), "I1": ctx.Tr("admin.repos.download"), "J1": ctx.Tr("admin.repos.pr"), "K1": ctx.Tr("admin.repos.commit"), - "L1": ctx.Tr("admin.repos.watches"), "M1": ctx.Tr("admin.repos.stars"), "N1": ctx.Tr("admin.repos.forks"), "O1": ctx.Tr("admin.repos.issues"), "P1": ctx.Tr("admin.repos.closedIssues"), "Q1": ctx.Tr("admin.repos.contributor"), "R1": ctx.Tr("admin.repos.create")} + return map[string]string{"A1": ctx.Tr("admin.repos.id"), "B1": ctx.Tr("admin.repos.projectName"), "C1": ctx.Tr("repo.owner"), "D1": ctx.Tr("admin.repos.isPrivate"), "E1": ctx.Tr("admin.repos.openi"), "F1": ctx.Tr("admin.repos.visit"), "G1": ctx.Tr("admin.repos.download"), "H1": ctx.Tr("admin.repos.pr"), "I1": ctx.Tr("admin.repos.commit"), + "J1": ctx.Tr("admin.repos.watches"), "K1": ctx.Tr("admin.repos.stars"), "L1": ctx.Tr("admin.repos.forks"), "M1": ctx.Tr("admin.repos.issues"), "N1": ctx.Tr("admin.repos.closedIssues"), "O1": ctx.Tr("admin.repos.contributor"), "P1": ctx.Tr("admin.repos.isFork"), "Q1": ctx.Tr("admin.repos.isMirror"), "R1": ctx.Tr("admin.repos.create")} } func allProjectsPeroidValues(row int, rs *models.RepoStatistic, ctx *context.Context) map[string]string { - return map[string]string{getCellName("A", row): strconv.FormatInt(rs.RepoID, 10), getCellName("B", row): rs.DisplayName(), getCellName("C", row): rs.OwnerName, getCellName("D", row): getBoolDisplay(rs.IsPrivate, ctx), getCellName("E", row): getBoolDisplay(rs.IsFork, ctx), getCellName("F", row): getBoolDisplay(rs.IsMirror, ctx), getCellName("G", row): strconv.FormatFloat(rs.RadarTotal, 'f', 2, 64), - getCellName("H", row): strconv.FormatInt(rs.NumVisits, 10), getCellName("I", row): strconv.FormatInt(rs.NumDownloads, 10), getCellName("J", row): strconv.FormatInt(rs.NumPulls, 10), getCellName("K", row): strconv.FormatInt(rs.NumCommits, 10), - getCellName("L", row): strconv.FormatInt(rs.NumWatches, 10), getCellName("M", row): strconv.FormatInt(rs.NumStars, 10), getCellName("N", row): strconv.FormatInt(rs.NumForks, 10), getCellName("O", row): strconv.FormatInt(rs.NumIssues, 10), - getCellName("P", row): strconv.FormatInt(rs.NumClosedIssues, 10), getCellName("Q", row): strconv.FormatInt(rs.NumContributor, 10), getCellName("R", row): time.Unix(int64(rs.RepoCreatedUnix), 0).Format(CREATE_TIME_FORMAT), + return map[string]string{getCellName("A", row): strconv.FormatInt(rs.RepoID, 10), getCellName("B", row): rs.DisplayName(), getCellName("C", row): rs.OwnerName, getCellName("D", row): getBoolDisplay(rs.IsPrivate, ctx), getCellName("E", row): strconv.FormatFloat(rs.RadarTotal, 'f', 2, 64), + getCellName("F", row): strconv.FormatInt(rs.NumVisits, 10), getCellName("G", row): strconv.FormatInt(rs.NumDownloads, 10), getCellName("H", row): strconv.FormatInt(rs.NumPulls, 10), getCellName("I", row): strconv.FormatInt(rs.NumCommits, 10), + getCellName("J", row): strconv.FormatInt(rs.NumWatches, 10), getCellName("K", row): strconv.FormatInt(rs.NumStars, 10), getCellName("L", row): strconv.FormatInt(rs.NumForks, 10), getCellName("M", row): strconv.FormatInt(rs.NumIssues, 10), + getCellName("N", row): strconv.FormatInt(rs.NumClosedIssues, 10), getCellName("O", row): strconv.FormatInt(rs.NumContributor, 10), getCellName("P", row): getBoolDisplay(rs.IsFork, ctx), getCellName("Q", row): getBoolDisplay(rs.IsMirror, ctx), getCellName("R", row): time.Unix(int64(rs.RepoCreatedUnix), 0).Format(CREATE_TIME_FORMAT), } } func allProjectsOpenIHeader() map[string]string { - return map[string]string{"A1": "ID", "B1": "项目名称", "C1": "拥有者", "D1": "私有", "E1": "迁移", "F1": "镜像", "G1": "OpenI指数", - "H1": "影响力", "I1": "成熟度", "J1": "活跃度", "K1": "项目健康度", "L1": "团队健康度", "M1": "项目发展趋势", - "N1": "关注数", "O1": "点赞数", "P1": "派生数", "Q1": "代码下载量", "R1": "评论数", "S1": "浏览量", "T1": "已解决任务数", "U1": "版本发布数量", "V1": "有效开发年龄", - "W1": "数据集", "X1": "模型数", "Y1": "百科页面数量", "Z1": "提交数", "AA1": "任务数", "AB1": "PR数", "AC1": "版本发布数量", "AD1": "任务完成比例", "AE1": "贡献者数", "AF1": "关键贡献者数", - "AG1": "新人增长量", "AH1": "代码规模增长量", "AI1": "任务增长量", "AJ1": "新人增长量", "AK1": "提交增长量", "AL1": "评论增长量", "AM1": "项目创建时间", + return map[string]string{"A1": "ID", "B1": "项目名称", "C1": "拥有者", "D1": "私有", "E1": "OpenI指数", + "F1": "影响力", "G1": "成熟度", "H1": "活跃度", "I1": "项目健康度", "J1": "团队健康度", "K1": "项目发展趋势", + "L1": "关注数", "M1": "点赞数", "N1": "派生数", "O1": "代码下载量", "P1": "评论数", "Q1": "浏览量", "R1": "已解决任务数", "S1": "版本发布数量", "T1": "有效开发年龄", + "U1": "数据集", "V1": "模型数", "W1": "百科页面数量", "X1": "提交数", "Y1": "任务数", "Z1": "PR数", "AA1": "版本发布数量", "AB1": "任务完成比例", "AC1": "贡献者数", "AD1": "关键贡献者数", + "AE1": "新人增长量", "AF1": "代码规模增长量", "AG1": "任务增长量", "AH1": "新人增长量", "AI1": "提交增长量", "AJ1": "评论增长量", "AK1": "迁移", "AL1": "镜像", "AM1": "项目创建时间", } } func allProjectsOpenIValues(row int, rs *models.RepoStatistic, ctx *context.Context) map[string]string { - return map[string]string{getCellName("A", row): strconv.FormatInt(rs.RepoID, 10), getCellName("B", row): rs.DisplayName(), getCellName("C", row): rs.OwnerName, getCellName("D", row): getBoolDisplay(rs.IsPrivate, ctx), getCellName("E", row): getBoolDisplay(rs.IsFork, ctx), getCellName("F", row): getBoolDisplay(rs.IsMirror, ctx), getCellName("G", row): strconv.FormatFloat(rs.RadarTotal, 'f', 2, 64), - getCellName("H", row): strconv.FormatFloat(rs.Impact, 'f', 2, 64), getCellName("I", row): strconv.FormatFloat(rs.Completeness, 'f', 2, 64), getCellName("J", row): strconv.FormatFloat(rs.Liveness, 'f', 2, 64), getCellName("K", row): strconv.FormatFloat(rs.ProjectHealth, 'f', 2, 64), getCellName("L", row): strconv.FormatFloat(rs.TeamHealth, 'f', 2, 64), getCellName("M", row): strconv.FormatFloat(rs.Growth, 'f', 2, 64), - getCellName("N", row): strconv.FormatInt(rs.NumWatches, 10), getCellName("O", row): strconv.FormatInt(rs.NumStars, 10), getCellName("P", row): strconv.FormatInt(rs.NumForks, 10), getCellName("Q", row): strconv.FormatInt(rs.NumDownloads, 10), + return map[string]string{getCellName("A", row): strconv.FormatInt(rs.RepoID, 10), getCellName("B", row): rs.DisplayName(), getCellName("C", row): rs.OwnerName, getCellName("D", row): getBoolDisplay(rs.IsPrivate, ctx), getCellName("E", row): strconv.FormatFloat(rs.RadarTotal, 'f', 2, 64), + getCellName("F", row): strconv.FormatFloat(rs.Impact, 'f', 2, 64), getCellName("G", row): strconv.FormatFloat(rs.Completeness, 'f', 2, 64), getCellName("H", row): strconv.FormatFloat(rs.Liveness, 'f', 2, 64), getCellName("I", row): strconv.FormatFloat(rs.ProjectHealth, 'f', 2, 64), getCellName("J", row): strconv.FormatFloat(rs.TeamHealth, 'f', 2, 64), getCellName("K", row): strconv.FormatFloat(rs.Growth, 'f', 2, 64), + getCellName("L", row): strconv.FormatInt(rs.NumWatches, 10), getCellName("M", row): strconv.FormatInt(rs.NumStars, 10), getCellName("N", row): strconv.FormatInt(rs.NumForks, 10), getCellName("O", row): strconv.FormatInt(rs.NumDownloads, 10), - getCellName("R", row): strconv.FormatInt(rs.NumComments, 10), getCellName("S", row): strconv.FormatInt(rs.NumVisits, 10), getCellName("T", row): strconv.FormatInt(rs.NumClosedIssues, 10), getCellName("U", row): strconv.FormatInt(rs.NumVersions, 10), - getCellName("V", row): strconv.FormatInt(rs.NumDevMonths, 10), getCellName("W", row): strconv.FormatInt(rs.DatasetSize, 10), getCellName("X", row): strconv.FormatInt(rs.NumModels, 10), getCellName("Y", row): strconv.FormatInt(rs.NumWikiViews, 10), - getCellName("Z", row): strconv.FormatInt(rs.NumCommits, 10), getCellName("AA", row): strconv.FormatInt(rs.NumIssues, 10), getCellName("AB", row): strconv.FormatInt(rs.NumPulls, 10), getCellName("AC", row): strconv.FormatInt(rs.NumVersions, 10), - getCellName("AD", row): strconv.FormatFloat(float64(rs.IssueFixedRate), 'f', 2, 64), getCellName("AE", row): strconv.FormatInt(rs.NumContributor, 10), getCellName("AF", row): strconv.FormatInt(rs.NumKeyContributor, 10), getCellName("AG", row): strconv.FormatInt(rs.NumContributorsGrowth, 10), - getCellName("AH", row): strconv.FormatInt(rs.NumCommitLinesGrowth, 10), getCellName("AI", row): strconv.FormatInt(rs.NumIssuesGrowth, 10), getCellName("AJ", row): strconv.FormatInt(rs.NumContributorsGrowth, 10), getCellName("AK", row): strconv.FormatInt(rs.NumCommitsGrowth, 10), getCellName("AL", row): strconv.FormatInt(rs.NumCommentsGrowth, 10), getCellName("AM", row): time.Unix(int64(rs.RepoCreatedUnix), 0).Format(CREATE_TIME_FORMAT), + getCellName("P", row): strconv.FormatInt(rs.NumComments, 10), getCellName("Q", row): strconv.FormatInt(rs.NumVisits, 10), getCellName("R", row): strconv.FormatInt(rs.NumClosedIssues, 10), getCellName("S", row): strconv.FormatInt(rs.NumVersions, 10), + getCellName("T", row): strconv.FormatInt(rs.NumDevMonths, 10), getCellName("U", row): strconv.FormatInt(rs.DatasetSize, 10), getCellName("V", row): strconv.FormatInt(rs.NumModels, 10), getCellName("W", row): strconv.FormatInt(rs.NumWikiViews, 10), + getCellName("X", row): strconv.FormatInt(rs.NumCommits, 10), getCellName("Y", row): strconv.FormatInt(rs.NumIssues, 10), getCellName("Z", row): strconv.FormatInt(rs.NumPulls, 10), getCellName("AA", row): strconv.FormatInt(rs.NumVersions, 10), + getCellName("AB", row): strconv.FormatFloat(float64(rs.IssueFixedRate), 'f', 2, 64), getCellName("AC", row): strconv.FormatInt(rs.NumContributor, 10), getCellName("AD", row): strconv.FormatInt(rs.NumKeyContributor, 10), getCellName("AE", row): strconv.FormatInt(rs.NumContributorsGrowth, 10), + getCellName("AF", row): strconv.FormatInt(rs.NumCommitLinesGrowth, 10), getCellName("AG", row): strconv.FormatInt(rs.NumIssuesGrowth, 10), getCellName("AH", row): strconv.FormatInt(rs.NumContributorsGrowth, 10), getCellName("AI", row): strconv.FormatInt(rs.NumCommitsGrowth, 10), getCellName("AJ", row): strconv.FormatInt(rs.NumCommentsGrowth, 10), getCellName("AK", row): getBoolDisplay(rs.IsFork, ctx), getCellName("AL", row): getBoolDisplay(rs.IsMirror, ctx), getCellName("AM", row): time.Unix(int64(rs.RepoCreatedUnix), 0).Format(CREATE_TIME_FORMAT), } } From f8d2c82f3f06eef4477db26e7f2e63fa6b252e95 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Wed, 23 Mar 2022 10:29:23 +0800 Subject: [PATCH 16/27] #1654 update --- models/cloudbrain.go | 4 ++++ routers/api/v1/repo/modelarts.go | 4 +++- routers/repo/cloudbrain.go | 5 ++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/models/cloudbrain.go b/models/cloudbrain.go index a7a0cbd98..4ee0b7b33 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -165,6 +165,10 @@ func (task *Cloudbrain) ComputeDuration() int64 { return d } +func IsTrainJobTerminal(status string) bool { + return status == string(ModelArtsTrainJobCompleted) || status == string(ModelArtsTrainJobFailed) || status == string(ModelArtsTrainJobKilled) +} + type CloudbrainInfo struct { Cloudbrain `xorm:"extends"` User `xorm:"extends"` diff --git a/routers/api/v1/repo/modelarts.go b/routers/api/v1/repo/modelarts.go index cc311c446..4d0e94160 100755 --- a/routers/api/v1/repo/modelarts.go +++ b/routers/api/v1/repo/modelarts.go @@ -140,7 +140,9 @@ func GetModelArtsTrainJobVersion(ctx *context.APIContext) { ctx.NotFound(err) return } - + if job.StartTime == 0 { + job.StartTime = timeutil.TimeStamp(result.StartTime / 1000) + } job.Status = modelarts.TransTrainJobStatus(result.IntStatus) job.Duration = result.Duration job.TrainJobDuration = result.TrainJobDuration diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 9225433cf..dae8506f0 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -1034,7 +1034,7 @@ func SyncCloudbrainStatus() { task.TrainJobDuration = result.TrainJobDuration if task.StartTime == 0 { - task.StartTime = timeutil.TimeStamp(result.StartTime) + task.StartTime = timeutil.TimeStamp(result.StartTime / 1000) } if result.Duration != 0 { task.TrainJobDuration = util.AddZero(result.Duration/3600000) + ":" + util.AddZero(result.Duration%3600000/60000) + ":" + util.AddZero(result.Duration%60000/1000) @@ -1042,6 +1042,9 @@ func SyncCloudbrainStatus() { } else { task.TrainJobDuration = "00:00:00" } + if models.IsTrainJobTerminal(task.Status) { + task.EndTime = task.StartTime.Add(task.Duration / 1000) + } err = models.UpdateJob(task) if err != nil { From 39b5f6291ca5a563a768d610cf168fb2647f03a1 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Wed, 23 Mar 2022 10:33:46 +0800 Subject: [PATCH 17/27] #1654 update --- routers/api/v1/repo/modelarts.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/routers/api/v1/repo/modelarts.go b/routers/api/v1/repo/modelarts.go index 4d0e94160..618f6c48d 100755 --- a/routers/api/v1/repo/modelarts.go +++ b/routers/api/v1/repo/modelarts.go @@ -154,6 +154,10 @@ func GetModelArtsTrainJobVersion(ctx *context.APIContext) { job.TrainJobDuration = "00:00:00" } + if models.IsTrainJobTerminal(job.Status) { + job.EndTime = job.StartTime.Add(job.Duration / 1000) + } + err = models.UpdateTrainJobVersion(job) if err != nil { log.Error("UpdateJob failed:", err) From 594b059a73e785e6bb2464f1935f39071a59acae Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Wed, 23 Mar 2022 10:43:41 +0800 Subject: [PATCH 18/27] #1654 update --- models/cloudbrain.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/cloudbrain.go b/models/cloudbrain.go index 4ee0b7b33..11368f076 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -1395,7 +1395,7 @@ func UpdateTrainJobVersion(job *Cloudbrain) error { func updateJobTrainVersion(e Engine, job *Cloudbrain) error { var sess *xorm.Session sess = e.Where("job_id = ? AND version_name=?", job.JobID, job.VersionName) - _, err := sess.Cols("status", "train_job_duration").Update(job) + _, err := sess.Cols("status", "train_job_duration", "start_time", "end_time").Update(job) return err } From 796af34cc1cd669bc76288c74f0aaa87d12eb436 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Wed, 23 Mar 2022 11:09:24 +0800 Subject: [PATCH 19/27] #1654 add train job endtime --- models/cloudbrain.go | 6 +++--- routers/api/v1/repo/modelarts.go | 15 ++++++++++----- routers/repo/cloudbrain.go | 4 ++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/models/cloudbrain.go b/models/cloudbrain.go index 11368f076..87a2ebd2c 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -102,7 +102,7 @@ type Cloudbrain struct { ContainerIp string CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` - Duration int64 + Duration int64 //运行时长 单位秒 TrainJobDuration string Image string //镜像名称 GpuQueue string //GPU类型即GPU队列 @@ -1395,7 +1395,7 @@ func UpdateTrainJobVersion(job *Cloudbrain) error { func updateJobTrainVersion(e Engine, job *Cloudbrain) error { var sess *xorm.Session sess = e.Where("job_id = ? AND version_name=?", job.JobID, job.VersionName) - _, err := sess.Cols("status", "train_job_duration", "start_time", "end_time").Update(job) + _, err := sess.Cols("status", "train_job_duration", "duration", "start_time", "end_time").Update(job) return err } @@ -1475,7 +1475,7 @@ func UpdateInferenceJob(job *Cloudbrain) error { func updateInferenceJob(e Engine, job *Cloudbrain) error { var sess *xorm.Session sess = e.Where("job_id = ?", job.JobID) - _, err := sess.Cols("status", "train_job_duration").Update(job) + _, err := sess.Cols("status", "train_job_duration", "duration", "start_time", "end_time").Update(job) return err } func RestartCloudbrain(old *Cloudbrain, new *Cloudbrain) (err error) { diff --git a/routers/api/v1/repo/modelarts.go b/routers/api/v1/repo/modelarts.go index 618f6c48d..28756699c 100755 --- a/routers/api/v1/repo/modelarts.go +++ b/routers/api/v1/repo/modelarts.go @@ -144,11 +144,11 @@ func GetModelArtsTrainJobVersion(ctx *context.APIContext) { job.StartTime = timeutil.TimeStamp(result.StartTime / 1000) } job.Status = modelarts.TransTrainJobStatus(result.IntStatus) - job.Duration = result.Duration + job.Duration = result.Duration / 1000 job.TrainJobDuration = result.TrainJobDuration if result.Duration != 0 { - job.TrainJobDuration = util.AddZero(result.Duration/3600000) + ":" + util.AddZero(result.Duration%3600000/60000) + ":" + util.AddZero(result.Duration%60000/1000) + job.TrainJobDuration = util.AddZero(result.Duration/3600) + ":" + util.AddZero(result.Duration%3600/60) + ":" + util.AddZero(result.Duration%60) } else { job.TrainJobDuration = "00:00:00" @@ -379,17 +379,22 @@ func GetModelArtsInferenceJob(ctx *context.APIContext) { ctx.NotFound(err) return } - + if job.StartTime == 0 { + job.StartTime = timeutil.TimeStamp(result.StartTime / 1000) + } job.Status = modelarts.TransTrainJobStatus(result.IntStatus) - job.Duration = result.Duration + job.Duration = result.Duration / 1000 job.TrainJobDuration = result.TrainJobDuration if result.Duration != 0 { - job.TrainJobDuration = util.AddZero(result.Duration/3600000) + ":" + util.AddZero(result.Duration%3600000/60000) + ":" + util.AddZero(result.Duration%60000/1000) + job.TrainJobDuration = util.AddZero(result.Duration/3600) + ":" + util.AddZero(result.Duration%3600/60) + ":" + util.AddZero(result.Duration%60) } else { job.TrainJobDuration = "00:00:00" } + if models.IsTrainJobTerminal(job.Status) { + job.EndTime = job.StartTime.Add(job.Duration / 1000) + } err = models.UpdateInferenceJob(job) if err != nil { diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index dae8506f0..7f907dd52 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -1030,14 +1030,14 @@ func SyncCloudbrainStatus() { if result != nil { task.Status = modelarts.TransTrainJobStatus(result.IntStatus) - task.Duration = result.Duration + task.Duration = result.Duration / 1000 task.TrainJobDuration = result.TrainJobDuration if task.StartTime == 0 { task.StartTime = timeutil.TimeStamp(result.StartTime / 1000) } if result.Duration != 0 { - task.TrainJobDuration = util.AddZero(result.Duration/3600000) + ":" + util.AddZero(result.Duration%3600000/60000) + ":" + util.AddZero(result.Duration%60000/1000) + task.TrainJobDuration = util.AddZero(result.Duration/3600) + ":" + util.AddZero(result.Duration%3600/60) + ":" + util.AddZero(result.Duration%60) } else { task.TrainJobDuration = "00:00:00" From 8ad955372d71298467ddb652b0f065273030e727 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Wed, 23 Mar 2022 14:16:32 +0800 Subject: [PATCH 20/27] #1654 fix bug --- routers/api/v1/repo/modelarts.go | 4 ++-- routers/repo/cloudbrain.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/routers/api/v1/repo/modelarts.go b/routers/api/v1/repo/modelarts.go index 28756699c..5476f7bf2 100755 --- a/routers/api/v1/repo/modelarts.go +++ b/routers/api/v1/repo/modelarts.go @@ -155,7 +155,7 @@ func GetModelArtsTrainJobVersion(ctx *context.APIContext) { } if models.IsTrainJobTerminal(job.Status) { - job.EndTime = job.StartTime.Add(job.Duration / 1000) + job.EndTime = job.StartTime.Add(job.Duration) } err = models.UpdateTrainJobVersion(job) @@ -393,7 +393,7 @@ func GetModelArtsInferenceJob(ctx *context.APIContext) { job.TrainJobDuration = "00:00:00" } if models.IsTrainJobTerminal(job.Status) { - job.EndTime = job.StartTime.Add(job.Duration / 1000) + job.EndTime = job.StartTime.Add(job.Duration) } err = models.UpdateInferenceJob(job) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 7f907dd52..39780f8fb 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -1043,7 +1043,7 @@ func SyncCloudbrainStatus() { task.TrainJobDuration = "00:00:00" } if models.IsTrainJobTerminal(task.Status) { - task.EndTime = task.StartTime.Add(task.Duration / 1000) + task.EndTime = task.StartTime.Add(task.Duration) } err = models.UpdateJob(task) From 95329d8f074adfc8c64dccc48e4f33f0ac3b3e0f Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Wed, 23 Mar 2022 15:06:45 +0800 Subject: [PATCH 21/27] #1654 fix bug --- routers/api/v1/repo/modelarts.go | 4 ++-- routers/repo/cloudbrain.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/routers/api/v1/repo/modelarts.go b/routers/api/v1/repo/modelarts.go index 5476f7bf2..5675ed20a 100755 --- a/routers/api/v1/repo/modelarts.go +++ b/routers/api/v1/repo/modelarts.go @@ -148,7 +148,7 @@ func GetModelArtsTrainJobVersion(ctx *context.APIContext) { job.TrainJobDuration = result.TrainJobDuration if result.Duration != 0 { - job.TrainJobDuration = util.AddZero(result.Duration/3600) + ":" + util.AddZero(result.Duration%3600/60) + ":" + util.AddZero(result.Duration%60) + job.TrainJobDuration = util.AddZero(job.Duration/3600) + ":" + util.AddZero(job.Duration%3600/60) + ":" + util.AddZero(job.Duration%60) } else { job.TrainJobDuration = "00:00:00" @@ -387,7 +387,7 @@ func GetModelArtsInferenceJob(ctx *context.APIContext) { job.TrainJobDuration = result.TrainJobDuration if result.Duration != 0 { - job.TrainJobDuration = util.AddZero(result.Duration/3600) + ":" + util.AddZero(result.Duration%3600/60) + ":" + util.AddZero(result.Duration%60) + job.TrainJobDuration = util.AddZero(job.Duration/3600) + ":" + util.AddZero(job.Duration%3600/60) + ":" + util.AddZero(job.Duration%60) } else { job.TrainJobDuration = "00:00:00" diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 39780f8fb..cdaa8b515 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -1037,7 +1037,7 @@ func SyncCloudbrainStatus() { task.StartTime = timeutil.TimeStamp(result.StartTime / 1000) } if result.Duration != 0 { - task.TrainJobDuration = util.AddZero(result.Duration/3600) + ":" + util.AddZero(result.Duration%3600/60) + ":" + util.AddZero(result.Duration%60) + task.TrainJobDuration = util.AddZero(task.Duration/3600) + ":" + util.AddZero(task.Duration%3600/60) + ":" + util.AddZero(task.Duration%60) } else { task.TrainJobDuration = "00:00:00" From e0b49c1a6319e92cf4fda635651b981259dee50b Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Wed, 23 Mar 2022 16:12:48 +0800 Subject: [PATCH 22/27] #1654 fix bug --- routers/api/v1/repo/cloudbrain.go | 2 +- routers/api/v1/repo/modelarts.go | 6 +++--- routers/repo/cloudbrain.go | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/routers/api/v1/repo/cloudbrain.go b/routers/api/v1/repo/cloudbrain.go index 53a3d9545..48013de84 100755 --- a/routers/api/v1/repo/cloudbrain.go +++ b/routers/api/v1/repo/cloudbrain.go @@ -79,7 +79,7 @@ func GetCloudbrainTask(ctx *context.APIContext) { job.ContainerID = taskRes.TaskStatuses[0].ContainerID job.Status = taskRes.TaskStatuses[0].State - if job.StartTime == 0 { + if job.StartTime == 0 && !taskRes.TaskStatuses[0].StartAt.IsZero() { job.StartTime = timeutil.TimeStamp(taskRes.TaskStatuses[0].StartAt.Unix()) } } diff --git a/routers/api/v1/repo/modelarts.go b/routers/api/v1/repo/modelarts.go index 5675ed20a..c6e2892ea 100755 --- a/routers/api/v1/repo/modelarts.go +++ b/routers/api/v1/repo/modelarts.go @@ -68,7 +68,7 @@ func GetModelArtsNotebook2(ctx *context.APIContext) { ctx.NotFound(err) return } - if job.StartTime == 0 { + if job.StartTime == 0 && result.Lease.CreateTime > 0 { job.StartTime = timeutil.TimeStamp(result.Lease.CreateTime / 1000) } job.Status = result.Status @@ -140,7 +140,7 @@ func GetModelArtsTrainJobVersion(ctx *context.APIContext) { ctx.NotFound(err) return } - if job.StartTime == 0 { + if job.StartTime == 0 && result.StartTime > 0 { job.StartTime = timeutil.TimeStamp(result.StartTime / 1000) } job.Status = modelarts.TransTrainJobStatus(result.IntStatus) @@ -379,7 +379,7 @@ func GetModelArtsInferenceJob(ctx *context.APIContext) { ctx.NotFound(err) return } - if job.StartTime == 0 { + if job.StartTime == 0 && result.StartTime > 0 { job.StartTime = timeutil.TimeStamp(result.StartTime / 1000) } job.Status = modelarts.TransTrainJobStatus(result.IntStatus) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index cdaa8b515..9ff299ba9 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -381,7 +381,7 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName) { task.Status = taskRes.TaskStatuses[0].State task.ContainerID = taskRes.TaskStatuses[0].ContainerID task.ContainerIp = taskRes.TaskStatuses[0].ContainerIP - if task.StartTime == 0 { + if task.StartTime == 0 && !taskRes.TaskStatuses[0].StartAt.IsZero() { task.StartTime = timeutil.TimeStamp(taskRes.TaskStatuses[0].StartAt.Unix()) } err = models.UpdateJob(task) @@ -961,7 +961,7 @@ func SyncCloudbrainStatus() { task.Status = taskRes.TaskStatuses[0].State if task.Status != string(models.JobWaiting) { task.Duration = time.Now().Unix() - taskRes.TaskStatuses[0].StartAt.Unix() - if task.StartTime == 0 { + if task.StartTime == 0 && !taskRes.TaskStatuses[0].StartAt.IsZero() { task.StartTime = timeutil.TimeStamp(taskRes.TaskStatuses[0].StartAt.Unix()) } //if task.Status == string(models.JobFailed) { @@ -1008,7 +1008,7 @@ func SyncCloudbrainStatus() { if result != nil { task.Status = result.Status - if task.StartTime == 0 { + if task.StartTime == 0 && result.Lease.CreateTime > 0 { task.StartTime = timeutil.TimeStamp(result.Lease.CreateTime / 1000) } if task.EndTime == 0 && task.Status == string(models.ModelArtsStopped) { @@ -1033,7 +1033,7 @@ func SyncCloudbrainStatus() { task.Duration = result.Duration / 1000 task.TrainJobDuration = result.TrainJobDuration - if task.StartTime == 0 { + if task.StartTime == 0 && result.StartTime > 0 { task.StartTime = timeutil.TimeStamp(result.StartTime / 1000) } if result.Duration != 0 { From ed979526e3cbfd53053d67ef2eeca26696abf67f Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Wed, 23 Mar 2022 16:35:26 +0800 Subject: [PATCH 23/27] fix 1650 --- routers/repo/attachment.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index 668169110..a60bed2a6 100755 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -241,14 +241,20 @@ func GetAttachment(ctx *context.Context) { } if dataSet != nil { - isPermit, err := models.GetUserDataSetPermission(dataSet, ctx.User) - if err != nil { - ctx.Error(http.StatusInternalServerError, "GetUserDataSetPermission", err.Error()) - return - } - if !isPermit { - ctx.Error(http.StatusNotFound) + if !ctx.IsSigned { + ctx.SetCookie("redirect_to", setting.AppSubURL+ctx.Req.URL.RequestURI(), 0, setting.AppSubURL) + ctx.Redirect(setting.AppSubURL + "/user/login") return + } else { + isPermit, err := models.GetUserDataSetPermission(dataSet, ctx.User) + if err != nil { + ctx.Error(http.StatusInternalServerError, "GetUserDataSetPermission", err.Error()) + return + } + if !isPermit { + ctx.Error(http.StatusNotFound) + return + } } } From 996d386eddf1e23fc205da075dd61893600d1869 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Wed, 23 Mar 2022 17:20:21 +0800 Subject: [PATCH 24/27] #1654 fix bug --- models/cloudbrain.go | 8 ++++++++ routers/api/v1/repo/cloudbrain.go | 4 ++++ routers/api/v1/repo/modelarts.go | 6 +++--- routers/repo/cloudbrain.go | 30 ++++++++++++++++++------------ 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/models/cloudbrain.go b/models/cloudbrain.go index 87a2ebd2c..759732aec 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -169,6 +169,14 @@ func IsTrainJobTerminal(status string) bool { return status == string(ModelArtsTrainJobCompleted) || status == string(ModelArtsTrainJobFailed) || status == string(ModelArtsTrainJobKilled) } +func IsModelArtsDebugJobTerminal(status string) bool { + return status == string(ModelArtsStopped) +} + +func IsCloudBrainOneDebugJobTerminal(status string) bool { + return status == string(JobStopped) || status == string(JobFailed) +} + type CloudbrainInfo struct { Cloudbrain `xorm:"extends"` User `xorm:"extends"` diff --git a/routers/api/v1/repo/cloudbrain.go b/routers/api/v1/repo/cloudbrain.go index 48013de84..fcee51b1e 100755 --- a/routers/api/v1/repo/cloudbrain.go +++ b/routers/api/v1/repo/cloudbrain.go @@ -85,6 +85,10 @@ func GetCloudbrainTask(ctx *context.APIContext) { } if result.JobStatus.State != string(models.JobWaiting) { + if job.EndTime == 0 && models.IsCloudBrainOneDebugJobTerminal(job.Status) { + job.EndTime = timeutil.TimeStampNow() + job.Duration = job.ComputeDuration() + } err = models.UpdateJob(job) if err != nil { log.Error("UpdateJob failed:", err) diff --git a/routers/api/v1/repo/modelarts.go b/routers/api/v1/repo/modelarts.go index c6e2892ea..402868bb0 100755 --- a/routers/api/v1/repo/modelarts.go +++ b/routers/api/v1/repo/modelarts.go @@ -72,7 +72,7 @@ func GetModelArtsNotebook2(ctx *context.APIContext) { job.StartTime = timeutil.TimeStamp(result.Lease.CreateTime / 1000) } job.Status = result.Status - if job.EndTime == 0 && job.Status == string(models.ModelArtsStopped) { + if job.EndTime == 0 && models.IsModelArtsDebugJobTerminal(job.Status) { job.EndTime = timeutil.TimeStampNow() job.Duration = job.ComputeDuration() } @@ -154,7 +154,7 @@ func GetModelArtsTrainJobVersion(ctx *context.APIContext) { job.TrainJobDuration = "00:00:00" } - if models.IsTrainJobTerminal(job.Status) { + if job.EndTime == 0 && models.IsTrainJobTerminal(job.Status) && job.StartTime > 0 { job.EndTime = job.StartTime.Add(job.Duration) } @@ -392,7 +392,7 @@ func GetModelArtsInferenceJob(ctx *context.APIContext) { } else { job.TrainJobDuration = "00:00:00" } - if models.IsTrainJobTerminal(job.Status) { + if job.EndTime == 0 && models.IsTrainJobTerminal(job.Status) && job.StartTime > 0 { job.EndTime = job.StartTime.Add(job.Duration) } diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 9ff299ba9..864eb8cb6 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -493,8 +493,10 @@ func CloudBrainStop(ctx *context.Context) { } task.Status = string(models.JobStopped) - task.EndTime = timeutil.TimeStampNow() - task.Duration = task.ComputeDuration() + if task.EndTime == 0 { + task.EndTime = timeutil.TimeStampNow() + task.Duration = task.ComputeDuration() + } err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob(%s) failed:%v", task.JobName, err, ctx.Data["msgID"]) @@ -588,8 +590,10 @@ func logErrorAndUpdateJobStatus(err error, taskInfo *models.Cloudbrain) { log.Warn("Failed to stop cloudBrain job:"+taskInfo.JobID, err) } else { taskInfo.Status = string(models.JobStopped) - taskInfo.EndTime = timeutil.TimeStampNow() - taskInfo.Duration = taskInfo.ComputeDuration() + if taskInfo.EndTime == 0 { + taskInfo.EndTime = timeutil.TimeStampNow() + taskInfo.Duration = taskInfo.ComputeDuration() + } err = models.UpdateJob(taskInfo) if err != nil { log.Warn("UpdateJob failed", err) @@ -964,10 +968,10 @@ func SyncCloudbrainStatus() { if task.StartTime == 0 && !taskRes.TaskStatuses[0].StartAt.IsZero() { task.StartTime = timeutil.TimeStamp(taskRes.TaskStatuses[0].StartAt.Unix()) } - //if task.Status == string(models.JobFailed) { - // task.EndTime = timeutil.TimeStampNow() - // task.Duration = task.ComputeDuration() - //} + if task.EndTime == 0 && models.IsCloudBrainOneDebugJobTerminal(task.Status) { + task.EndTime = timeutil.TimeStampNow() + task.Duration = task.ComputeDuration() + } err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob(%s) failed:%v", task.JobName, err) @@ -988,8 +992,10 @@ func SyncCloudbrainStatus() { continue } task.Status = string(models.JobStopped) - task.EndTime = timeutil.TimeStampNow() - task.Duration = task.ComputeDuration() + if task.EndTime == 0 { + task.EndTime = timeutil.TimeStampNow() + task.Duration = task.ComputeDuration() + } err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob(%s) failed:%v", task.JobName, err) @@ -1011,7 +1017,7 @@ func SyncCloudbrainStatus() { if task.StartTime == 0 && result.Lease.CreateTime > 0 { task.StartTime = timeutil.TimeStamp(result.Lease.CreateTime / 1000) } - if task.EndTime == 0 && task.Status == string(models.ModelArtsStopped) { + if task.EndTime == 0 && models.IsModelArtsDebugJobTerminal(task.Status) { task.EndTime = timeutil.TimeStampNow() task.Duration = task.ComputeDuration() } @@ -1042,7 +1048,7 @@ func SyncCloudbrainStatus() { } else { task.TrainJobDuration = "00:00:00" } - if models.IsTrainJobTerminal(task.Status) { + if task.EndTime == 0 && models.IsTrainJobTerminal(task.Status) && task.StartTime > 0 { task.EndTime = task.StartTime.Add(task.Duration) } From bc2161bd84b2aeaf00b760454b4800ca348d64d0 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Wed, 23 Mar 2022 18:00:37 +0800 Subject: [PATCH 25/27] #1654 update --- routers/repo/modelarts.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index 6b5eeffbf..c2043fb49 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -409,7 +409,7 @@ func NotebookManage(ctx *context.Context) { } task.Status = res.Status - if task.Status == string(models.ModelArtsStopped) { + if task.EndTime == 0 && models.IsModelArtsDebugJobTerminal(task.Status) { task.EndTime = timeutil.TimeStampNow() task.Duration = task.ComputeDuration() } From 330df70dbea11beb26585a47251e0dc15d64bf7b Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Thu, 24 Mar 2022 14:17:01 +0800 Subject: [PATCH 26/27] #1654 update --- models/cloudbrain.go | 44 ++++++++++++++++++++----------- routers/api/v1/repo/cloudbrain.go | 2 +- routers/api/v1/repo/modelarts.go | 17 +++--------- routers/repo/cloudbrain.go | 32 +++++++++++----------- routers/repo/modelarts.go | 2 +- 5 files changed, 49 insertions(+), 48 deletions(-) diff --git a/models/cloudbrain.go b/models/cloudbrain.go index 759732aec..ea6d0338e 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -1,6 +1,7 @@ package models import ( + "code.gitea.io/gitea/modules/util" "encoding/json" "fmt" "strconv" @@ -102,15 +103,15 @@ type Cloudbrain struct { ContainerIp string CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` - Duration int64 //运行时长 单位秒 - TrainJobDuration string - Image string //镜像名称 - GpuQueue string //GPU类型即GPU队列 - ResourceSpecId int //GPU规格id - DeletedAt time.Time `xorm:"deleted"` - CanDebug bool `xorm:"-"` - CanDel bool `xorm:"-"` - CanModify bool `xorm:"-"` + Duration int64 `xorm:"DEFAULT 0"` //运行时长 单位秒 + TrainJobDuration string `xorm:"DEFAULT '00:00:00'"` + Image string //镜像名称 + GpuQueue string //GPU类型即GPU队列 + ResourceSpecId int //GPU规格id + DeletedAt time.Time `xorm:"deleted"` + CanDebug bool `xorm:"-"` + CanDel bool `xorm:"-"` + CanModify bool `xorm:"-"` Type int BenchmarkTypeID int BenchmarkChildTypeID int @@ -154,15 +155,28 @@ type Cloudbrain struct { EndTime timeutil.TimeStamp } -func (task *Cloudbrain) ComputeDuration() int64 { - if task.StartTime == 0 || task.EndTime == 0 { - return 0 +func (task *Cloudbrain) ComputeAndSetDuration() { + var d int64 + if task.StartTime == 0 { + d = 0 + } else if task.EndTime == 0 { + d = time.Now().Unix() - task.StartTime.AsTime().Unix() + } else { + d = task.EndTime.AsTime().Unix() - task.StartTime.AsTime().Unix() } - d := task.EndTime.AsTime().Unix() - task.StartTime.AsTime().Unix() + if d < 0 { d = 0 } - return d + task.Duration = d + task.TrainJobDuration = ConvertDurationToStr(d) +} + +func ConvertDurationToStr(duration int64) string { + if duration == 0 { + return "00:00:00" + } + return util.AddZero(duration/3600) + ":" + util.AddZero(duration%3600/60) + ":" + util.AddZero(duration%60) } func IsTrainJobTerminal(status string) bool { @@ -174,7 +188,7 @@ func IsModelArtsDebugJobTerminal(status string) bool { } func IsCloudBrainOneDebugJobTerminal(status string) bool { - return status == string(JobStopped) || status == string(JobFailed) + return status == string(JobStopped) || status == string(JobFailed) || status == string(JobSucceeded) } type CloudbrainInfo struct { diff --git a/routers/api/v1/repo/cloudbrain.go b/routers/api/v1/repo/cloudbrain.go index fcee51b1e..b2f529dfb 100755 --- a/routers/api/v1/repo/cloudbrain.go +++ b/routers/api/v1/repo/cloudbrain.go @@ -87,8 +87,8 @@ func GetCloudbrainTask(ctx *context.APIContext) { if result.JobStatus.State != string(models.JobWaiting) { if job.EndTime == 0 && models.IsCloudBrainOneDebugJobTerminal(job.Status) { job.EndTime = timeutil.TimeStampNow() - job.Duration = job.ComputeDuration() } + job.ComputeAndSetDuration() err = models.UpdateJob(job) if err != nil { log.Error("UpdateJob failed:", err) diff --git a/routers/api/v1/repo/modelarts.go b/routers/api/v1/repo/modelarts.go index 402868bb0..d7d011e07 100755 --- a/routers/api/v1/repo/modelarts.go +++ b/routers/api/v1/repo/modelarts.go @@ -11,8 +11,6 @@ import ( "strconv" "strings" - "code.gitea.io/gitea/modules/util" - "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/log" @@ -74,8 +72,8 @@ func GetModelArtsNotebook2(ctx *context.APIContext) { job.Status = result.Status if job.EndTime == 0 && models.IsModelArtsDebugJobTerminal(job.Status) { job.EndTime = timeutil.TimeStampNow() - job.Duration = job.ComputeDuration() } + job.ComputeAndSetDuration() err = models.UpdateJob(job) if err != nil { log.Error("UpdateJob failed:", err) @@ -147,12 +145,7 @@ func GetModelArtsTrainJobVersion(ctx *context.APIContext) { job.Duration = result.Duration / 1000 job.TrainJobDuration = result.TrainJobDuration - if result.Duration != 0 { - job.TrainJobDuration = util.AddZero(job.Duration/3600) + ":" + util.AddZero(job.Duration%3600/60) + ":" + util.AddZero(job.Duration%60) - - } else { - job.TrainJobDuration = "00:00:00" - } + job.TrainJobDuration = models.ConvertDurationToStr(job.Duration) if job.EndTime == 0 && models.IsTrainJobTerminal(job.Status) && job.StartTime > 0 { job.EndTime = job.StartTime.Add(job.Duration) @@ -386,12 +379,8 @@ func GetModelArtsInferenceJob(ctx *context.APIContext) { job.Duration = result.Duration / 1000 job.TrainJobDuration = result.TrainJobDuration - if result.Duration != 0 { - job.TrainJobDuration = util.AddZero(job.Duration/3600) + ":" + util.AddZero(job.Duration%3600/60) + ":" + util.AddZero(job.Duration%60) + job.TrainJobDuration = models.ConvertDurationToStr(result.Duration) - } else { - job.TrainJobDuration = "00:00:00" - } if job.EndTime == 0 && models.IsTrainJobTerminal(job.Status) && job.StartTime > 0 { job.EndTime = job.StartTime.Add(job.Duration) } diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index f7e36c1ac..85ce02c75 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -488,8 +488,8 @@ func CloudBrainStop(ctx *context.Context) { task.Status = string(models.JobStopped) if task.EndTime == 0 { task.EndTime = timeutil.TimeStampNow() - task.Duration = task.ComputeDuration() } + task.ComputeAndSetDuration() err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob(%s) failed:%v", task.JobName, err, ctx.Data["msgID"]) @@ -585,8 +585,8 @@ func logErrorAndUpdateJobStatus(err error, taskInfo *models.Cloudbrain) { taskInfo.Status = string(models.JobStopped) if taskInfo.EndTime == 0 { taskInfo.EndTime = timeutil.TimeStampNow() - taskInfo.Duration = taskInfo.ComputeDuration() } + taskInfo.ComputeAndSetDuration() err = models.UpdateJob(taskInfo) if err != nil { log.Warn("UpdateJob failed", err) @@ -963,8 +963,8 @@ func SyncCloudbrainStatus() { } if task.EndTime == 0 && models.IsCloudBrainOneDebugJobTerminal(task.Status) { task.EndTime = timeutil.TimeStampNow() - task.Duration = task.ComputeDuration() } + task.ComputeAndSetDuration() err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob(%s) failed:%v", task.JobName, err) @@ -987,8 +987,8 @@ func SyncCloudbrainStatus() { task.Status = string(models.JobStopped) if task.EndTime == 0 { task.EndTime = timeutil.TimeStampNow() - task.Duration = task.ComputeDuration() } + task.ComputeAndSetDuration() err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob(%s) failed:%v", task.JobName, err) @@ -1012,8 +1012,8 @@ func SyncCloudbrainStatus() { } if task.EndTime == 0 && models.IsModelArtsDebugJobTerminal(task.Status) { task.EndTime = timeutil.TimeStampNow() - task.Duration = task.ComputeDuration() } + task.ComputeAndSetDuration() err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob(%s) failed:%v", task.JobName, err) @@ -1035,12 +1035,7 @@ func SyncCloudbrainStatus() { if task.StartTime == 0 && result.StartTime > 0 { task.StartTime = timeutil.TimeStamp(result.StartTime / 1000) } - if result.Duration != 0 { - task.TrainJobDuration = util.AddZero(task.Duration/3600) + ":" + util.AddZero(task.Duration%3600/60) + ":" + util.AddZero(task.Duration%60) - - } else { - task.TrainJobDuration = "00:00:00" - } + task.TrainJobDuration = models.ConvertDurationToStr(task.Duration) if task.EndTime == 0 && models.IsTrainJobTerminal(task.Status) && task.StartTime > 0 { task.EndTime = task.StartTime.Add(task.Duration) } @@ -1090,13 +1085,16 @@ func CloudBrainBenchmarkIndex(ctx *context.Context) { for i, task := range ciTasks { ciTasks[i].CanDel = cloudbrain.CanDeleteJob(ctx, &task.Cloudbrain) ciTasks[i].Cloudbrain.ComputeResource = task.ComputeResource - var duration int64 - if task.Status == string(models.JobRunning) { - duration = time.Now().Unix() - int64(task.Cloudbrain.CreatedUnix) - } else { - duration = int64(task.Cloudbrain.UpdatedUnix) - int64(task.Cloudbrain.CreatedUnix) + if ciTasks[i].TrainJobDuration == "" { + var duration int64 + if task.Status == string(models.JobRunning) { + duration = time.Now().Unix() - int64(task.Cloudbrain.CreatedUnix) + } else { + duration = int64(task.Cloudbrain.UpdatedUnix) - int64(task.Cloudbrain.CreatedUnix) + } + ciTasks[i].TrainJobDuration = models.ConvertDurationToStr(duration) } - ciTasks[i].TrainJobDuration = util.AddZero(duration/3600000) + ":" + util.AddZero(duration%3600000/60000) + ":" + util.AddZero(duration%60000/1000) + ciTasks[i].BenchmarkTypeName = "" if task.BenchmarkTypeID > 0 { for _, benchmarkType := range GetBenchmarkTypes(ctx).BenchmarkType { diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index c2043fb49..690a878e9 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -411,8 +411,8 @@ func NotebookManage(ctx *context.Context) { task.Status = res.Status if task.EndTime == 0 && models.IsModelArtsDebugJobTerminal(task.Status) { task.EndTime = timeutil.TimeStampNow() - task.Duration = task.ComputeDuration() } + task.ComputeAndSetDuration() err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob(%s) failed:%v", task.JobName, err.Error(), ctx.Data["MsgID"]) From 2a325ff93f97fef0c2e953add821924f7e1e6179 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Thu, 24 Mar 2022 14:58:05 +0800 Subject: [PATCH 27/27] #1654 update --- routers/repo/cloudbrain.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 85ce02c75..d444ea73f 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -402,12 +402,6 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName) { task.User = user } - var duration int64 - if task.Status == string(models.JobRunning) { - duration = time.Now().Unix() - int64(task.CreatedUnix) - } else { - duration = int64(task.UpdatedUnix) - int64(task.CreatedUnix) - } if task.BenchmarkTypeID > 0 { for _, benchmarkType := range GetBenchmarkTypes(ctx).BenchmarkType { if task.BenchmarkTypeID == benchmarkType.Id { @@ -422,8 +416,16 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName) { } } } - - ctx.Data["duration"] = util.AddZero(duration/3600000) + ":" + util.AddZero(duration%3600000/60000) + ":" + util.AddZero(duration%60000/1000) + if task.TrainJobDuration == "" { + var duration int64 + if task.Status == string(models.JobRunning) { + duration = time.Now().Unix() - int64(task.CreatedUnix) + } else { + duration = int64(task.UpdatedUnix) - int64(task.CreatedUnix) + } + task.TrainJobDuration = models.ConvertDurationToStr(duration) + } + ctx.Data["duration"] = task.TrainJobDuration ctx.Data["task"] = task ctx.Data["jobName"] = task.JobName ctx.Data["displayJobName"] = task.DisplayJobName