From a143994177224cf461faf8cdf2152cbfd10d4c62 Mon Sep 17 00:00:00 2001 From: chenshihai Date: Wed, 20 Jul 2022 11:09:12 +0800 Subject: [PATCH 01/49] add kanban file --- public/kanban/index.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 public/kanban/index.html diff --git a/public/kanban/index.html b/public/kanban/index.html new file mode 100644 index 000000000..0e44d84a3 --- /dev/null +++ b/public/kanban/index.html @@ -0,0 +1,12 @@ + + + + + + + + + +
kanban
+ + From 1cc7f47767e7611374faa926699719df87a373b4 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Wed, 20 Jul 2022 14:21:56 +0800 Subject: [PATCH 02/49] #2477 add kanban index route --- routers/kanban/kanban.go | 24 ++++++++++++++++++++++++ routers/routes/routes.go | 2 ++ 2 files changed, 26 insertions(+) create mode 100644 routers/kanban/kanban.go diff --git a/routers/kanban/kanban.go b/routers/kanban/kanban.go new file mode 100644 index 000000000..d6bb743bb --- /dev/null +++ b/routers/kanban/kanban.go @@ -0,0 +1,24 @@ +package kanban + +import ( + "code.gitea.io/gitea/modules/base" + "code.gitea.io/gitea/modules/context" + "code.gitea.io/gitea/modules/setting" + "net/http" + "os" + "path" + "time" +) + +func Index(ctx *context.Context) { + file := path.Join(setting.StaticRootPath, "public/kanban/index.html") + name := "index.html" + f, err := os.Open(file) + if err != nil { + ctx.HTML(http.StatusNotFound, base.TplName("status/404")) + return + } + defer f.Close() + ctx.Resp.Header().Set("Content-Type", "text/html") + http.ServeContent(ctx.Resp, ctx.Req.Request, name, time.Now(), f) +} diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 35a26f585..bdad93572 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -6,6 +6,7 @@ package routes import ( "bytes" + "code.gitea.io/gitea/routers/kanban" "encoding/gob" "net/http" "path" @@ -327,6 +328,7 @@ func RegisterRoutes(m *macaron.Macaron) { }) m.Get("/", routers.Home) m.Get("/dashboard", routers.Dashboard) + m.Get("/kanban/index", kanban.Index) go routers.SocketManager.Run() m.Get("/action/notification", routers.ActionNotification) m.Get("/recommend/home", routers.RecommendHomeInfo) From 3bbe2b5de6b21baf00e7fa8dc03c04d738fb438f Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Wed, 20 Jul 2022 14:29:13 +0800 Subject: [PATCH 03/49] #2477 update kanban index route --- routers/routes/routes.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/routes/routes.go b/routers/routes/routes.go index bdad93572..e4481d3c1 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -328,7 +328,7 @@ func RegisterRoutes(m *macaron.Macaron) { }) m.Get("/", routers.Home) m.Get("/dashboard", routers.Dashboard) - m.Get("/kanban/index", kanban.Index) + m.Get("/panel", kanban.Index) go routers.SocketManager.Run() m.Get("/action/notification", routers.ActionNotification) m.Get("/recommend/home", routers.RecommendHomeInfo) From 7c6824c3a2f51c8ebe2147dbd263b1ee6366e8dc Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Wed, 20 Jul 2022 16:06:51 +0800 Subject: [PATCH 04/49] fix issue --- templates/admin/dataset/list.tmpl | 4 +-- templates/explore/dataset_list.tmpl | 13 +++++--- templates/repo/cloudbrain/benchmark/show.tmpl | 10 +++++- templates/repo/cloudbrain/inference/show.tmpl | 10 +++++- templates/repo/cloudbrain/show.tmpl | 10 +++++- templates/repo/cloudbrain/trainjob/show.tmpl | 10 +++++- templates/repo/debugjob/index.tmpl | 4 +-- templates/repo/modelarts/notebook/show.tmpl | 10 +++++- templates/repo/modelarts/trainjob/show.tmpl | 2 +- templates/user/dashboard/cloudbrains.tmpl | 2 +- web_src/js/features/clipboard.js | 38 ++++++++++++++------- web_src/less/_dataset.less | 48 +++++++++++++++------------ web_src/less/openi.less | 1 + 13 files changed, 113 insertions(+), 49 deletions(-) diff --git a/templates/admin/dataset/list.tmpl b/templates/admin/dataset/list.tmpl index 9e4e72b68..9712f2e7b 100644 --- a/templates/admin/dataset/list.tmpl +++ b/templates/admin/dataset/list.tmpl @@ -35,7 +35,7 @@ {{range .Datasets}} {{.ID}} - {{.Title}}{{if .Recommend}}{{end}} + {{.Title}}{{if .Recommend}}{{end}} {{.CreatedUnix.FormatShort}} {{if .Recommend}}{{$.i18n.Tr "admin.datasets.unrecommend"}}{{else}}{{$.i18n.Tr "admin.datasets.recommend"}}{{end}} @@ -48,4 +48,4 @@ {{template "base/paginate" .}} -{{template "base/footer" .}} +{{template "base/footer" .}} \ No newline at end of file diff --git a/templates/explore/dataset_list.tmpl b/templates/explore/dataset_list.tmpl index 1d22b62ec..a0f171195 100755 --- a/templates/explore/dataset_list.tmpl +++ b/templates/explore/dataset_list.tmpl @@ -24,9 +24,9 @@
{{range .Datasets}}
-
- - {{.Repo.OwnerName}} / {{.Repo.Alias}} +
+ + {{.Title}}
{{if .Task}} @@ -40,7 +40,7 @@
{{if .Description}} -

{{.Description}}

+

{{.Description}}

{{else if .Repo.DescriptionHTML}}

{{.Repo.DescriptionHTML}}

{{end}} @@ -53,4 +53,7 @@
{{end}}
-
\ No newline at end of file +
+ \ No newline at end of file diff --git a/templates/repo/cloudbrain/benchmark/show.tmpl b/templates/repo/cloudbrain/benchmark/show.tmpl index ff4e5e7ea..4a73d1973 100755 --- a/templates/repo/cloudbrain/benchmark/show.tmpl +++ b/templates/repo/cloudbrain/benchmark/show.tmpl @@ -353,7 +353,15 @@
- {{.Image}} + + {{.Image}} +
diff --git a/templates/repo/cloudbrain/inference/show.tmpl b/templates/repo/cloudbrain/inference/show.tmpl index 00ad25644..ac11b16a9 100644 --- a/templates/repo/cloudbrain/inference/show.tmpl +++ b/templates/repo/cloudbrain/inference/show.tmpl @@ -381,7 +381,15 @@
- {{.Image}} + + {{.Image}} +
diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index e4769c65c..b43e6e0f5 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -390,7 +390,15 @@
- {{.Image}} + + {{.Image}} +
diff --git a/templates/repo/cloudbrain/trainjob/show.tmpl b/templates/repo/cloudbrain/trainjob/show.tmpl index 20e5cb55d..9a01ea6c8 100644 --- a/templates/repo/cloudbrain/trainjob/show.tmpl +++ b/templates/repo/cloudbrain/trainjob/show.tmpl @@ -384,7 +384,15 @@
- {{.Image}} + + {{.Image}} +
diff --git a/templates/repo/debugjob/index.tmpl b/templates/repo/debugjob/index.tmpl index 043816e9f..bb1d1992a 100755 --- a/templates/repo/debugjob/index.tmpl +++ b/templates/repo/debugjob/index.tmpl @@ -386,7 +386,7 @@ {{$.CsrfTokenHtml}} {{if .CanDel}} {{$.i18n.Tr "repo.stop"}} @@ -405,7 +405,7 @@ {{$.CsrfTokenHtml}} {{if .CanDel}} {{$.i18n.Tr "repo.delete"}} diff --git a/templates/repo/modelarts/notebook/show.tmpl b/templates/repo/modelarts/notebook/show.tmpl index 7d49ace86..cb0be133f 100755 --- a/templates/repo/modelarts/notebook/show.tmpl +++ b/templates/repo/modelarts/notebook/show.tmpl @@ -357,7 +357,15 @@
- {{.Image}} + + {{.Image}} +
diff --git a/templates/repo/modelarts/trainjob/show.tmpl b/templates/repo/modelarts/trainjob/show.tmpl index 7a727cf4c..e61fafcdd 100755 --- a/templates/repo/modelarts/trainjob/show.tmpl +++ b/templates/repo/modelarts/trainjob/show.tmpl @@ -270,7 +270,7 @@ {{end}} {{if .CanDel}} -
-{{template "base/footer" .}} \ No newline at end of file +{{template "base/footer" .}} diff --git a/web_src/js/features/clipboard.js b/web_src/js/features/clipboard.js index bd4a664c7..34513ad27 100644 --- a/web_src/js/features/clipboard.js +++ b/web_src/js/features/clipboard.js @@ -1,23 +1,37 @@ export default async function initClipboard() { - const els = document.querySelectorAll('.clipboard'); + const els = document.querySelectorAll(".clipboard"); if (!els || !els.length) return; - const { default: ClipboardJS } = await import(/* webpackChunkName: "clipboard" */'clipboard'); + const { default: ClipboardJS } = await import( + /* webpackChunkName: "clipboard" */ "clipboard" + ); const clipboard = new ClipboardJS(els); - clipboard.on('success', (e) => { + clipboard.on("success", (e) => { e.clearSelection(); - $(`#${e.trigger.getAttribute('id')}`).popup('destroy'); - e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-success')); - $(`#${e.trigger.getAttribute('id')}`).popup('show'); - e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-original')); + $(`#${e.trigger.getAttribute("id")}`).popup("destroy"); + e.trigger.setAttribute( + "data-content", + e.trigger.getAttribute("data-success") + ); + $(`#${e.trigger.getAttribute("id")}`).popup("show"); + e.trigger.setAttribute( + "data-content", + e.trigger.getAttribute("data-original") + ); }); - clipboard.on('error', (e) => { - $(`#${e.trigger.getAttribute('id')}`).popup('destroy'); - e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-error')); - $(`#${e.trigger.getAttribute('id')}`).popup('show'); - e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-original')); + clipboard.on("error", (e) => { + $(`#${e.trigger.getAttribute("id")}`).popup("destroy"); + e.trigger.setAttribute( + "data-content", + e.trigger.getAttribute("data-error") + ); + $(`#${e.trigger.getAttribute("id")}`).popup("show"); + e.trigger.setAttribute( + "data-content", + e.trigger.getAttribute("data-original") + ); }); } diff --git a/web_src/less/_dataset.less b/web_src/less/_dataset.less index 35a87f89f..fff632d23 100644 --- a/web_src/less/_dataset.less +++ b/web_src/less/_dataset.less @@ -140,27 +140,26 @@ border: 1px solid #ffffff; } } - } + } } .item { - border-bottom: 1px solid rgba(34,36,38,.15); + border-bottom: 1px solid rgba(34, 36, 38, 0.15); .ui.buttons { .button { box-shadow: none !important; } } - } - + .ui.grid > .row { align-items: center; } - + .title { font-size: 16px; font-weight: bold; - margin: 0 6px; + margin: 0 6px; overflow: hidden; padding-right: 15px; white-space: nowrap; @@ -195,7 +194,15 @@ .name { word-break: break-all; } - + .dataset-title-a { + flex: 1; + overflow: hidden; + text-overflow: ellipsis; + min-width: 0; + word-break: inherit !important; + margin-right: 3rem; + white-space: nowrap; + } .metas { color: #888888; font-size: 14px; @@ -222,7 +229,7 @@ } } } -.panel_creator_reponam{ +.panel_creator_reponam { display: inline-block; border-radius: 4px; padding: 4px; @@ -231,29 +238,28 @@ background-color: rgba(161, 220, 255, 0.2); color: #101010; } -.panel_dataset_name{ +.panel_dataset_name { font-size: 15px; - color: #0366D6; + color: #0366d6; text-align: center; margin-left: 1rem; } -.panel_datset_desc{ +.panel_datset_desc { white-space: nowrap; display: inline-block; overflow: hidden; width: 90%; - + text-overflow: ellipsis; } -.el-dialog__body{ - padding-top:0 +.el-dialog__body { + padding-top: 0; } -#dataset-base{ - .active{ - color: #0087f5!important; - border: 1px solid #0087f5!important; +#dataset-base { + .active { + color: #0087f5 !important; + border: 1px solid #0087f5 !important; /* margin: -1px!important; */ - background: #fff!important; - + background: #fff !important; } -} \ No newline at end of file +} diff --git a/web_src/less/openi.less b/web_src/less/openi.less index 0c30d1c92..b9622924f 100644 --- a/web_src/less/openi.less +++ b/web_src/less/openi.less @@ -311,6 +311,7 @@ footer .column { } .FAILED, .START_FAILED, +.DELETED, .CREATE_FAILED { display: inline-block; width: 18px; From e5f416463160b09d7049fb1a8681a785f53a9fe1 Mon Sep 17 00:00:00 2001 From: liuzx Date: Wed, 20 Jul 2022 16:39:57 +0800 Subject: [PATCH 05/49] fix-1968 --- routers/repo/cloudbrain.go | 269 ++++++++++++++++++++++++++++++++++++++++++--- routers/repo/grampus.go | 150 +++++++++++++++++++------ 2 files changed, 369 insertions(+), 50 deletions(-) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 0d20f83f0..18ad02e88 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -218,6 +218,243 @@ func cloudBrainNewDataPrepare(ctx *context.Context) error { return nil } +func cloudBrainTrainJobErrorPrepare(ctx *context.Context, form auth.CreateCloudBrainForm) error { + ctx.Data["PageIsCloudBrain"] = true + + if categories == nil { + json.Unmarshal([]byte(setting.BenchmarkCategory), &categories) + } + ctx.Data["benchmark_categories"] = categories.Category + + ctx.Data["benchmark_types"] = GetBenchmarkTypes(ctx).BenchmarkType + queuesDetail, _ := cloudbrain.GetQueuesDetail() + if queuesDetail != nil { + ctx.Data["QueuesDetail"] = queuesDetail + } + + cloudbrain.InitSpecialPool() + + if gpuInfos == nil { + json.Unmarshal([]byte(setting.GpuTypes), &gpuInfos) + } + ctx.Data["gpu_types"] = gpuInfos.GpuInfo + + if trainGpuInfos == nil { + json.Unmarshal([]byte(setting.TrainGpuTypes), &trainGpuInfos) + } + ctx.Data["train_gpu_types"] = trainGpuInfos.GpuInfo + + if inferenceGpuInfos == nil && setting.InferenceGpuTypes != "" { + json.Unmarshal([]byte(setting.InferenceGpuTypes), &inferenceGpuInfos) + } + if inferenceGpuInfos != nil { + ctx.Data["inference_gpu_types"] = inferenceGpuInfos.GpuInfo + } + + if benchmarkGpuInfos == nil { + json.Unmarshal([]byte(setting.BenchmarkGpuTypes), &benchmarkGpuInfos) + } + ctx.Data["benchmark_gpu_types"] = benchmarkGpuInfos.GpuInfo + + if benchmarkResourceSpecs == nil { + json.Unmarshal([]byte(setting.BenchmarkResourceSpecs), &benchmarkResourceSpecs) + } + ctx.Data["benchmark_resource_specs"] = benchmarkResourceSpecs.ResourceSpec + + if cloudbrain.ResourceSpecs == nil { + json.Unmarshal([]byte(setting.ResourceSpecs), &cloudbrain.ResourceSpecs) + } + ctx.Data["resource_specs"] = cloudbrain.ResourceSpecs.ResourceSpec + + if cloudbrain.TrainResourceSpecs == nil { + json.Unmarshal([]byte(setting.TrainResourceSpecs), &cloudbrain.TrainResourceSpecs) + } + ctx.Data["train_resource_specs"] = cloudbrain.TrainResourceSpecs.ResourceSpec + + if cloudbrain.InferenceResourceSpecs == nil && setting.InferenceResourceSpecs != "" { + json.Unmarshal([]byte(setting.InferenceResourceSpecs), &cloudbrain.InferenceResourceSpecs) + } + if cloudbrain.InferenceResourceSpecs != nil { + ctx.Data["inference_resource_specs"] = cloudbrain.InferenceResourceSpecs.ResourceSpec + } + + if cloudbrain.SpecialPools != nil { + var debugGpuTypes []*models.GpuInfo + var trainGpuTypes []*models.GpuInfo + + for _, pool := range cloudbrain.SpecialPools.Pools { + org, _ := models.GetOrgByName(pool.Org) + if org != nil { + isOrgMember, _ := models.IsOrganizationMember(org.ID, ctx.User.ID) + if isOrgMember { + for _, jobType := range pool.JobType { + if jobType == string(models.JobTypeDebug) { + debugGpuTypes = append(debugGpuTypes, pool.Pool...) + if pool.ResourceSpec != nil { + ctx.Data["resource_specs"] = pool.ResourceSpec + } + } else if jobType == string(models.JobTypeTrain) { + trainGpuTypes = append(trainGpuTypes, pool.Pool...) + if pool.ResourceSpec != nil { + ctx.Data["train_resource_specs"] = pool.ResourceSpec + } + } + } + break + } + } + + } + + if len(debugGpuTypes) > 0 { + ctx.Data["gpu_types"] = debugGpuTypes + } + + if len(trainGpuTypes) > 0 { + ctx.Data["train_gpu_types"] = trainGpuTypes + } + + } + + var Parameters modelarts.Parameters + if err := json.Unmarshal([]byte(form.Params), &Parameters); err != nil { + ctx.ServerError("json.Unmarshal failed:", err) + return err + } + ctx.Data["run_para_list"] = Parameters.Parameter + ctx.Data["boot_file"] = form.BootFile + ctx.Data["attachment"] = form.Attachment + ctx.Data["branch_name"] = form.BranchName + ctx.Data["datasetType"] = models.TypeCloudBrainOne + + ctx.Data["display_job_name"] = form.DisplayJobName + ctx.Data["image"] = form.Image + ctx.Data["job_type"] = form.JobType + ctx.Data["gpu_type"] = form.GpuType + ctx.Data["resource_spec_id"] = form.ResourceSpecId + return nil +} + +func cloudBrainInferenceJobErrorPrepare(ctx *context.Context, form auth.CreateCloudBrainInferencForm) error { + ctx.Data["PageIsCloudBrain"] = true + + if categories == nil { + json.Unmarshal([]byte(setting.BenchmarkCategory), &categories) + } + ctx.Data["benchmark_categories"] = categories.Category + + ctx.Data["benchmark_types"] = GetBenchmarkTypes(ctx).BenchmarkType + queuesDetail, _ := cloudbrain.GetQueuesDetail() + if queuesDetail != nil { + ctx.Data["QueuesDetail"] = queuesDetail + } + + cloudbrain.InitSpecialPool() + + if gpuInfos == nil { + json.Unmarshal([]byte(setting.GpuTypes), &gpuInfos) + } + ctx.Data["gpu_types"] = gpuInfos.GpuInfo + + if trainGpuInfos == nil { + json.Unmarshal([]byte(setting.TrainGpuTypes), &trainGpuInfos) + } + ctx.Data["train_gpu_types"] = trainGpuInfos.GpuInfo + + if inferenceGpuInfos == nil && setting.InferenceGpuTypes != "" { + json.Unmarshal([]byte(setting.InferenceGpuTypes), &inferenceGpuInfos) + } + if inferenceGpuInfos != nil { + ctx.Data["inference_gpu_types"] = inferenceGpuInfos.GpuInfo + } + + if benchmarkGpuInfos == nil { + json.Unmarshal([]byte(setting.BenchmarkGpuTypes), &benchmarkGpuInfos) + } + ctx.Data["benchmark_gpu_types"] = benchmarkGpuInfos.GpuInfo + + if benchmarkResourceSpecs == nil { + json.Unmarshal([]byte(setting.BenchmarkResourceSpecs), &benchmarkResourceSpecs) + } + ctx.Data["benchmark_resource_specs"] = benchmarkResourceSpecs.ResourceSpec + + if cloudbrain.ResourceSpecs == nil { + json.Unmarshal([]byte(setting.ResourceSpecs), &cloudbrain.ResourceSpecs) + } + ctx.Data["resource_specs"] = cloudbrain.ResourceSpecs.ResourceSpec + + if cloudbrain.TrainResourceSpecs == nil { + json.Unmarshal([]byte(setting.TrainResourceSpecs), &cloudbrain.TrainResourceSpecs) + } + ctx.Data["train_resource_specs"] = cloudbrain.TrainResourceSpecs.ResourceSpec + + if cloudbrain.InferenceResourceSpecs == nil && setting.InferenceResourceSpecs != "" { + json.Unmarshal([]byte(setting.InferenceResourceSpecs), &cloudbrain.InferenceResourceSpecs) + } + if cloudbrain.InferenceResourceSpecs != nil { + ctx.Data["inference_resource_specs"] = cloudbrain.InferenceResourceSpecs.ResourceSpec + } + + if cloudbrain.SpecialPools != nil { + var debugGpuTypes []*models.GpuInfo + var trainGpuTypes []*models.GpuInfo + + for _, pool := range cloudbrain.SpecialPools.Pools { + org, _ := models.GetOrgByName(pool.Org) + if org != nil { + isOrgMember, _ := models.IsOrganizationMember(org.ID, ctx.User.ID) + if isOrgMember { + for _, jobType := range pool.JobType { + if jobType == string(models.JobTypeDebug) { + debugGpuTypes = append(debugGpuTypes, pool.Pool...) + if pool.ResourceSpec != nil { + ctx.Data["resource_specs"] = pool.ResourceSpec + } + } else if jobType == string(models.JobTypeTrain) { + trainGpuTypes = append(trainGpuTypes, pool.Pool...) + if pool.ResourceSpec != nil { + ctx.Data["train_resource_specs"] = pool.ResourceSpec + } + } + } + break + } + } + + } + if len(debugGpuTypes) > 0 { + ctx.Data["gpu_types"] = debugGpuTypes + } + + if len(trainGpuTypes) > 0 { + ctx.Data["train_gpu_types"] = trainGpuTypes + } + + } + var Parameters modelarts.Parameters + if err := json.Unmarshal([]byte(form.Params), &Parameters); err != nil { + ctx.ServerError("json.Unmarshal failed:", err) + return err + } + ctx.Data["run_para_list"] = Parameters.Parameter + ctx.Data["boot_file"] = form.BootFile + ctx.Data["attachment"] = form.Attachment + ctx.Data["branch_name"] = form.BranchName + ctx.Data["datasetType"] = models.TypeCloudBrainOne + + ctx.Data["display_job_name"] = form.DisplayJobName + ctx.Data["image"] = form.Image + ctx.Data["job_type"] = form.JobType + ctx.Data["gpu_type"] = form.GpuType + ctx.Data["resource_spec_id"] = form.ResourceSpecId + ctx.Data["label_names"] = form.LabelName + ctx.Data["train_url"] = form.TrainUrl + ctx.Data["ckpt_name"] = form.CkptName + ctx.Data["model_name"] = form.ModelName + ctx.Data["model_version"] = form.ModelVersion + ctx.Data["description"] = form.Description + return nil +} func CloudBrainNew(ctx *context.Context) { err := cloudBrainNewDataPrepare(ctx) @@ -250,28 +487,28 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { if err == nil { if len(tasks) != 0 { log.Error("the job name did already exist", ctx.Data["MsgID"]) - cloudBrainNewDataPrepare(ctx) + cloudBrainTrainJobErrorPrepare(ctx, form) ctx.RenderWithErr("the job name did already exist", tpl, &form) return } } else { if !models.IsErrJobNotExist(err) { log.Error("system error, %v", err, ctx.Data["MsgID"]) - cloudBrainNewDataPrepare(ctx) + cloudBrainTrainJobErrorPrepare(ctx, form) ctx.RenderWithErr("system error", tpl, &form) return } } if !jobNamePattern.MatchString(displayJobName) { - cloudBrainNewDataPrepare(ctx) + cloudBrainTrainJobErrorPrepare(ctx, form) ctx.RenderWithErr(ctx.Tr("repo.cloudbrain_jobname_err"), tpl, &form) return } if jobType != string(models.JobTypeBenchmark) && jobType != string(models.JobTypeDebug) && jobType != string(models.JobTypeTrain) { log.Error("jobtype error:", jobType, ctx.Data["MsgID"]) - cloudBrainNewDataPrepare(ctx) + cloudBrainTrainJobErrorPrepare(ctx, form) ctx.RenderWithErr("jobtype error", tpl, &form) return } @@ -279,13 +516,13 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { count, err := models.GetCloudbrainCountByUserID(ctx.User.ID, jobType) if err != nil { log.Error("GetCloudbrainCountByUserID failed:%v", err, ctx.Data["MsgID"]) - cloudBrainNewDataPrepare(ctx) + cloudBrainTrainJobErrorPrepare(ctx, form) ctx.RenderWithErr("system error", tpl, &form) return } else { if count >= 1 { log.Error("the user already has running or waiting task", ctx.Data["MsgID"]) - cloudBrainNewDataPrepare(ctx) + cloudBrainTrainJobErrorPrepare(ctx, form) ctx.RenderWithErr(ctx.Tr("repo.cloudbrain.morethanonejob"), tpl, &form) return } @@ -294,7 +531,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { datasetInfos, datasetNames, err := models.GetDatasetInfo(uuids) if err != nil { log.Error("GetDatasetInfo failed: %v", err, ctx.Data["MsgID"]) - cloudBrainNewDataPrepare(ctx) + cloudBrainTrainJobErrorPrepare(ctx, form) ctx.RenderWithErr(ctx.Tr("cloudbrain.error.dataset_select"), tpl, &form) return } @@ -315,7 +552,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { errStr := checkCloudBrainSpecialPool(ctx, jobType, gpuQueue, resourceSpecId) if errStr != "" { - cloudBrainNewDataPrepare(ctx) + cloudBrainTrainJobErrorPrepare(ctx, form) ctx.RenderWithErr(errStr, tpl, &form) return } @@ -361,7 +598,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { err = cloudbrain.GenerateTask(req) if err != nil { - cloudBrainNewDataPrepare(ctx) + cloudBrainTrainJobErrorPrepare(ctx, form) ctx.RenderWithErr(err.Error(), tpl, &form) return } @@ -373,7 +610,6 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { } } - func CloudBrainInferenceJobCreate(ctx *context.Context, form auth.CreateCloudBrainInferencForm) { ctx.Data["PageIsCloudBrain"] = true displayJobName := form.DisplayJobName @@ -402,14 +638,14 @@ func CloudBrainInferenceJobCreate(ctx *context.Context, form auth.CreateCloudBra if err == nil { if len(tasks) != 0 { log.Error("the job name did already exist", ctx.Data["MsgID"]) - cloudBrainNewDataPrepare(ctx) + cloudBrainInferenceJobErrorPrepare(ctx, form) ctx.RenderWithErr("the job name did already exist", tpl, &form) return } } else { if !models.IsErrJobNotExist(err) { log.Error("system error, %v", err, ctx.Data["MsgID"]) - cloudBrainNewDataPrepare(ctx) + cloudBrainInferenceJobErrorPrepare(ctx, form) ctx.RenderWithErr("system error", tpl, &form) return } @@ -423,13 +659,13 @@ func CloudBrainInferenceJobCreate(ctx *context.Context, form auth.CreateCloudBra count, err := models.GetCloudbrainCountByUserID(ctx.User.ID, jobType) if err != nil { log.Error("GetCloudbrainCountByUserID failed:%v", err, ctx.Data["MsgID"]) - cloudBrainNewDataPrepare(ctx) + cloudBrainInferenceJobErrorPrepare(ctx, form) ctx.RenderWithErr("system error", tpl, &form) return } else { if count >= 1 { log.Error("the user already has running or waiting task", ctx.Data["MsgID"]) - cloudBrainNewDataPrepare(ctx) + cloudBrainInferenceJobErrorPrepare(ctx, form) ctx.RenderWithErr(ctx.Tr("repo.cloudbrain.morethanonejob"), tpl, &form) return } @@ -449,7 +685,7 @@ func CloudBrainInferenceJobCreate(ctx *context.Context, form auth.CreateCloudBra datasetInfos, datasetNames, err := models.GetDatasetInfo(uuid) if err != nil { log.Error("GetDatasetInfo failed: %v", err, ctx.Data["MsgID"]) - cloudBrainNewDataPrepare(ctx) + cloudBrainInferenceJobErrorPrepare(ctx, form) ctx.RenderWithErr(ctx.Tr("cloudbrain.error.dataset_select"), tpl, &form) return } @@ -486,7 +722,7 @@ func CloudBrainInferenceJobCreate(ctx *context.Context, form auth.CreateCloudBra err = cloudbrain.GenerateTask(req) if err != nil { - cloudBrainNewDataPrepare(ctx) + cloudBrainInferenceJobErrorPrepare(ctx, form) ctx.RenderWithErr(err.Error(), tpl, &form) return } @@ -494,6 +730,7 @@ func CloudBrainInferenceJobCreate(ctx *context.Context, form auth.CreateCloudBra ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/modelarts/inference-job") } + /** 检查用户传输的参数是否符合专属资源池 */ diff --git a/routers/repo/grampus.go b/routers/repo/grampus.go index 978b7462d..fa6e71814 100755 --- a/routers/repo/grampus.go +++ b/routers/repo/grampus.go @@ -1,15 +1,8 @@ package repo import ( - "code.gitea.io/gitea/modules/auth" - "code.gitea.io/gitea/modules/git" - "code.gitea.io/gitea/modules/grampus" - "code.gitea.io/gitea/modules/modelarts" - "code.gitea.io/gitea/modules/timeutil" - "code.gitea.io/gitea/modules/util" "encoding/json" "errors" - "github.com/unknwon/com" "io/ioutil" "net/http" "os" @@ -18,6 +11,14 @@ import ( "strings" "time" + "code.gitea.io/gitea/modules/auth" + "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/grampus" + "code.gitea.io/gitea/modules/modelarts" + "code.gitea.io/gitea/modules/timeutil" + "code.gitea.io/gitea/modules/util" + "github.com/unknwon/com" + "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/cloudbrain" @@ -136,6 +137,87 @@ func grampusTrainJobNewDataPrepare(ctx *context.Context, processType string) err return nil } +func grampusTrainJobErrorPrepare(ctx *context.Context, processType string, form auth.CreateGrampusTrainJobForm) error { + ctx.Data["PageIsCloudBrain"] = true + + //get valid images + images, err := grampus.GetImages(processType) + if err != nil { + log.Error("GetImages failed:", err.Error()) + } else { + ctx.Data["images"] = images.Infos + } + + grampus.InitSpecialPool() + + ctx.Data["GPUEnabled"] = true + ctx.Data["NPUEnabled"] = true + includeCenters := make(map[string]struct{}) + excludeCenters := make(map[string]struct{}) + if grampus.SpecialPools != nil { + for _, pool := range grampus.SpecialPools.Pools { + if pool.IsExclusive { + if !IsUserInOrgPool(ctx.User.ID, pool) { + ctx.Data[pool.Type+"Enabled"] = false + } + } else { + if strings.Contains(strings.ToLower(processType), strings.ToLower(pool.Type)) { + if IsUserInOrgPool(ctx.User.ID, pool) { + for _, center := range pool.Pool { + includeCenters[center.Queue] = struct{}{} + } + } else { + for _, center := range pool.Pool { + excludeCenters[center.Queue] = struct{}{} + } + + } + + } + + } + } + } + + //get valid resource specs + specs, err := grampus.GetResourceSpecs(processType) + + grampusSpecs := getFilterSpecBySpecialPool(specs, includeCenters, excludeCenters) + + if err != nil { + log.Error("GetResourceSpecs failed:", err.Error()) + } else { + ctx.Data["flavor_infos"] = grampusSpecs + } + + if processType == grampus.ProcessorTypeGPU { + ctx.Data["datasetType"] = models.TypeCloudBrainOne + } else if processType == grampus.ProcessorTypeNPU { + ctx.Data["datasetType"] = models.TypeCloudBrainTwo + } + + var Parameters modelarts.Parameters + if err := json.Unmarshal([]byte(form.Params), &Parameters); err != nil { + ctx.ServerError("json.Unmarshal failed:", err) + return err + } + ctx.Data["run_para_list"] = Parameters.Parameter + ctx.Data["boot_file"] = form.BootFile + ctx.Data["attachment"] = form.Attachment + ctx.Data["branch_name"] = form.BranchName + ctx.Data["image_id"] = form.ImageID + + ctx.Data["display_job_name"] = form.DisplayJobName + ctx.Data["image"] = form.Image + ctx.Data["flavor"] = form.FlavorID + ctx.Data["flavor_name"] = form.FlavorName + ctx.Data["description"] = form.Description + ctx.Data["engine_name"] = form.EngineName + ctx.Data["work_server_number"] = form.WorkServerNumber + + return nil +} + func getFilterSpecBySpecialPool(specs *models.GetGrampusResourceSpecsResult, includeCenters map[string]struct{}, excludeCenters map[string]struct{}) []models.GrampusSpec { if len(includeCenters) == 0 && len(excludeCenters) == 0 { return specs.Infos @@ -206,14 +288,14 @@ func GrampusTrainJobGpuCreate(ctx *context.Context, form auth.CreateGrampusTrain image := strings.TrimSpace(form.Image) if !jobNamePattern.MatchString(displayJobName) { - grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) + grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeGPU, form) ctx.RenderWithErr(ctx.Tr("repo.cloudbrain_jobname_err"), tplGrampusTrainJobGPUNew, &form) return } errStr := checkSpecialPool(ctx, "GPU") if errStr != "" { - grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) + grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeGPU, form) ctx.RenderWithErr(errStr, tplGrampusTrainJobGPUNew, &form) return } @@ -222,13 +304,13 @@ func GrampusTrainJobGpuCreate(ctx *context.Context, form auth.CreateGrampusTrain count, err := models.GetGrampusCountByUserID(ctx.User.ID, string(models.JobTypeTrain), models.GPUResource) if err != nil { log.Error("GetGrampusCountByUserID failed:%v", err, ctx.Data["MsgID"]) - grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) + grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeGPU, form) ctx.RenderWithErr("system error", tplGrampusTrainJobGPUNew, &form) return } else { if count >= 1 { log.Error("the user already has running or waiting task", ctx.Data["MsgID"]) - grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) + grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeGPU, form) ctx.RenderWithErr("you have already a running or waiting task, can not create more", tplGrampusTrainJobGPUNew, &form) return } @@ -237,7 +319,7 @@ func GrampusTrainJobGpuCreate(ctx *context.Context, form auth.CreateGrampusTrain //check param if err := grampusParamCheckCreateTrainJob(form); err != nil { log.Error("paramCheckCreateTrainJob failed:(%v)", err, ctx.Data["MsgID"]) - grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) + grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeGPU, form) ctx.RenderWithErr(err.Error(), tplGrampusTrainJobGPUNew, &form) return } @@ -247,14 +329,14 @@ func GrampusTrainJobGpuCreate(ctx *context.Context, form auth.CreateGrampusTrain if err == nil { if len(tasks) != 0 { log.Error("the job name did already exist", ctx.Data["MsgID"]) - grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) + grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeGPU, form) ctx.RenderWithErr("the job name did already exist", tplGrampusTrainJobGPUNew, &form) return } } else { if !models.IsErrJobNotExist(err) { log.Error("system error, %v", err, ctx.Data["MsgID"]) - grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) + grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeGPU, form) ctx.RenderWithErr("system error", tplGrampusTrainJobGPUNew, &form) return } @@ -264,7 +346,7 @@ func GrampusTrainJobGpuCreate(ctx *context.Context, form auth.CreateGrampusTrain attachment, err := models.GetAttachmentByUUID(uuid) if err != nil { log.Error("GetAttachmentByUUID failed:", err.Error(), ctx.Data["MsgID"]) - grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) + grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeGPU, form) ctx.RenderWithErr("dataset is not exist", tplGrampusTrainJobGPUNew, &form) return } @@ -277,7 +359,7 @@ func GrampusTrainJobGpuCreate(ctx *context.Context, form auth.CreateGrampusTrain if err := downloadZipCode(ctx, codeLocalPath, branchName); err != nil { log.Error("downloadZipCode failed, server timed out: %s (%v)", repo.FullName(), err, ctx.Data["MsgID"]) - grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) + grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeGPU, form) ctx.RenderWithErr("Create task failed, internal error", tplGrampusTrainJobGPUNew, &form) return } @@ -286,7 +368,7 @@ func GrampusTrainJobGpuCreate(ctx *context.Context, form auth.CreateGrampusTrain //upload code if err := uploadCodeToMinio(codeLocalPath+"/", jobName, cloudbrain.CodeMountPath+"/"); err != nil { log.Error("Failed to uploadCodeToMinio: %s (%v)", repo.FullName(), err, ctx.Data["MsgID"]) - grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) + grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeGPU, form) ctx.RenderWithErr("Create task failed, internal error", tplGrampusTrainJobGPUNew, &form) return } @@ -294,7 +376,7 @@ func GrampusTrainJobGpuCreate(ctx *context.Context, form auth.CreateGrampusTrain modelPath := setting.JobPath + jobName + cloudbrain.ModelMountPath + "/" if err := mkModelPath(modelPath); err != nil { log.Error("Failed to mkModelPath: %s (%v)", repo.FullName(), err, ctx.Data["MsgID"]) - grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) + grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeGPU, form) ctx.RenderWithErr("Create task failed, internal error", tplGrampusTrainJobGPUNew, &form) return } @@ -302,7 +384,7 @@ func GrampusTrainJobGpuCreate(ctx *context.Context, form auth.CreateGrampusTrain //init model readme if err := uploadCodeToMinio(modelPath, jobName, cloudbrain.ModelMountPath+"/"); err != nil { log.Error("Failed to uploadCodeToMinio: %s (%v)", repo.FullName(), err, ctx.Data["MsgID"]) - grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) + grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeGPU, form) ctx.RenderWithErr("Create task failed, internal error", tplGrampusTrainJobGPUNew, &form) return } @@ -311,7 +393,7 @@ func GrampusTrainJobGpuCreate(ctx *context.Context, form auth.CreateGrampusTrain command, err := generateCommand(repo.Name, grampus.ProcessorTypeGPU, codeMinioPath+cloudbrain.DefaultBranchName+".zip", dataMinioPath, bootFile, params, setting.CBCodePathPrefix+jobName+cloudbrain.ModelMountPath+"/", attachment.Name) if err != nil { log.Error("Failed to generateCommand: %s (%v)", displayJobName, err, ctx.Data["MsgID"]) - grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) + grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeGPU, form) ctx.RenderWithErr("Create task failed, internal error", tplGrampusTrainJobGPUNew, &form) return } @@ -343,7 +425,7 @@ func GrampusTrainJobGpuCreate(ctx *context.Context, form auth.CreateGrampusTrain err = grampus.GenerateTrainJob(ctx, req) if err != nil { log.Error("GenerateTrainJob failed:%v", err.Error(), ctx.Data["MsgID"]) - grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) + grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeGPU, form) ctx.RenderWithErr(err.Error(), tplGrampusTrainJobGPUNew, &form) return } @@ -390,14 +472,14 @@ func GrampusTrainJobNpuCreate(ctx *context.Context, form auth.CreateGrampusTrain engineName := form.EngineName if !jobNamePattern.MatchString(displayJobName) { - grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU) + grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeNPU, form) ctx.RenderWithErr(ctx.Tr("repo.cloudbrain_jobname_err"), tplGrampusTrainJobNPUNew, &form) return } errStr := checkSpecialPool(ctx, "NPU") if errStr != "" { - grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU) + grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeNPU, form) ctx.RenderWithErr(errStr, tplGrampusTrainJobGPUNew, &form) return } @@ -406,13 +488,13 @@ func GrampusTrainJobNpuCreate(ctx *context.Context, form auth.CreateGrampusTrain count, err := models.GetGrampusCountByUserID(ctx.User.ID, string(models.JobTypeTrain), models.NPUResource) if err != nil { log.Error("GetGrampusCountByUserID failed:%v", err, ctx.Data["MsgID"]) - grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU) + grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeNPU, form) ctx.RenderWithErr("system error", tplGrampusTrainJobNPUNew, &form) return } else { if count >= 1 { log.Error("the user already has running or waiting task", ctx.Data["MsgID"]) - grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU) + grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeNPU, form) ctx.RenderWithErr("you have already a running or waiting task, can not create more", tplGrampusTrainJobNPUNew, &form) return } @@ -421,7 +503,7 @@ func GrampusTrainJobNpuCreate(ctx *context.Context, form auth.CreateGrampusTrain //check param if err := grampusParamCheckCreateTrainJob(form); err != nil { log.Error("paramCheckCreateTrainJob failed:(%v)", err) - grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU) + grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeNPU, form) ctx.RenderWithErr(err.Error(), tplGrampusTrainJobNPUNew, &form) return } @@ -431,14 +513,14 @@ func GrampusTrainJobNpuCreate(ctx *context.Context, form auth.CreateGrampusTrain if err == nil { if len(tasks) != 0 { log.Error("the job name did already exist", ctx.Data["MsgID"]) - grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU) + grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeNPU, form) ctx.RenderWithErr("the job name did already exist", tplGrampusTrainJobNPUNew, &form) return } } else { if !models.IsErrJobNotExist(err) { log.Error("system error, %v", err, ctx.Data["MsgID"]) - grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU) + grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeNPU, form) ctx.RenderWithErr("system error", tplGrampusTrainJobNPUNew, &form) return } @@ -448,7 +530,7 @@ func GrampusTrainJobNpuCreate(ctx *context.Context, form auth.CreateGrampusTrain attachment, err := models.GetAttachmentByUUID(uuid) if err != nil { log.Error("GetAttachmentByUUID failed:", err.Error(), ctx.Data["MsgID"]) - grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU) + grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeNPU, form) ctx.RenderWithErr("dataset is not exist", tplGrampusTrainJobNPUNew, &form) return } @@ -461,7 +543,7 @@ func GrampusTrainJobNpuCreate(ctx *context.Context, form auth.CreateGrampusTrain if err := downloadZipCode(ctx, codeLocalPath, branchName); err != nil { log.Error("downloadZipCode failed, server timed out: %s (%v)", repo.FullName(), err) - grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU) + grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeNPU, form) ctx.RenderWithErr("Create task failed, server timed out", tplGrampusTrainJobNPUNew, &form) return } @@ -469,14 +551,14 @@ func GrampusTrainJobNpuCreate(ctx *context.Context, form auth.CreateGrampusTrain //todo: upload code (send to file_server todo this work?) if err := obsMkdir(setting.CodePathPrefix + jobName + modelarts.OutputPath); err != nil { log.Error("Failed to obsMkdir_output: %s (%v)", repo.FullName(), err) - grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU) + grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeNPU, form) ctx.RenderWithErr("Failed to obsMkdir_output", tplGrampusTrainJobNPUNew, &form) return } if err := uploadCodeToObs(codeLocalPath, jobName, ""); err != nil { log.Error("Failed to uploadCodeToObs: %s (%v)", repo.FullName(), err) - grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU) + grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeNPU, form) ctx.RenderWithErr("Failed to uploadCodeToObs", tplGrampusTrainJobNPUNew, &form) return } @@ -485,7 +567,7 @@ func GrampusTrainJobNpuCreate(ctx *context.Context, form auth.CreateGrampusTrain command, err := generateCommand(repo.Name, grampus.ProcessorTypeNPU, codeObsPath+cloudbrain.DefaultBranchName+".zip", dataObsPath+"'"+attachment.Name+"'", bootFile, params, setting.CodePathPrefix+jobName+modelarts.OutputPath, attachment.Name) if err != nil { log.Error("Failed to generateCommand: %s (%v)", displayJobName, err, ctx.Data["MsgID"]) - grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU) + grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeNPU, form) ctx.RenderWithErr("Create task failed, internal error", tplGrampusTrainJobNPUNew, &form) return } @@ -521,7 +603,7 @@ func GrampusTrainJobNpuCreate(ctx *context.Context, form auth.CreateGrampusTrain err = grampus.GenerateTrainJob(ctx, req) if err != nil { log.Error("GenerateTrainJob failed:%v", err.Error()) - grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU) + grampusTrainJobErrorPrepare(ctx, grampus.ProcessorTypeNPU, form) ctx.RenderWithErr(err.Error(), tplGrampusTrainJobNPUNew, &form) return } From 366ffed3e1b709595ef458ac44f842d6e692a52c Mon Sep 17 00:00:00 2001 From: liuzx Date: Wed, 20 Jul 2022 17:31:13 +0800 Subject: [PATCH 06/49] fix-2439 --- routers/api/v1/repo/cloudbrain.go | 1 + routers/api/v1/repo/modelarts.go | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/routers/api/v1/repo/cloudbrain.go b/routers/api/v1/repo/cloudbrain.go index d291024f9..0b1271c5c 100755 --- a/routers/api/v1/repo/cloudbrain.go +++ b/routers/api/v1/repo/cloudbrain.go @@ -99,6 +99,7 @@ func GetCloudbrainTask(ctx *context.APIContext) { "SubState": result.JobStatus.SubState, "CreatedTime": time.Unix(result.JobStatus.CreatedTime/1000, 0).Format("2006-01-02 15:04:05"), "CompletedTime": time.Unix(result.JobStatus.CompletedTime/1000, 0).Format("2006-01-02 15:04:05"), + "JobDuration": job.TrainJobDuration, }) } diff --git a/routers/api/v1/repo/modelarts.go b/routers/api/v1/repo/modelarts.go index 187c16c50..cb8086189 100755 --- a/routers/api/v1/repo/modelarts.go +++ b/routers/api/v1/repo/modelarts.go @@ -87,9 +87,10 @@ func GetModelArtsNotebook2(ctx *context.APIContext) { } ctx.JSON(http.StatusOK, map[string]interface{}{ - "ID": ID, - "JobName": job.JobName, - "JobStatus": result.Status, + "ID": ID, + "JobName": job.JobName, + "JobStatus": result.Status, + "JobDuration": job.TrainJobDuration, }) } From 7dacce149aacd7a3381067a079ac19ad083bf97a Mon Sep 17 00:00:00 2001 From: liuzx Date: Wed, 20 Jul 2022 18:16:33 +0800 Subject: [PATCH 07/49] fix-bug --- routers/repo/cloudbrain.go | 4 ++-- routers/repo/grampus.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 18ad02e88..58087a4f6 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -321,7 +321,7 @@ func cloudBrainTrainJobErrorPrepare(ctx *context.Context, form auth.CreateCloudB ctx.ServerError("json.Unmarshal failed:", err) return err } - ctx.Data["run_para_list"] = Parameters.Parameter + ctx.Data["params"] = Parameters.Parameter ctx.Data["boot_file"] = form.BootFile ctx.Data["attachment"] = form.Attachment ctx.Data["branch_name"] = form.BranchName @@ -436,7 +436,7 @@ func cloudBrainInferenceJobErrorPrepare(ctx *context.Context, form auth.CreateCl ctx.ServerError("json.Unmarshal failed:", err) return err } - ctx.Data["run_para_list"] = Parameters.Parameter + ctx.Data["params"] = Parameters.Parameter ctx.Data["boot_file"] = form.BootFile ctx.Data["attachment"] = form.Attachment ctx.Data["branch_name"] = form.BranchName diff --git a/routers/repo/grampus.go b/routers/repo/grampus.go index fa6e71814..ed37a542b 100755 --- a/routers/repo/grampus.go +++ b/routers/repo/grampus.go @@ -201,7 +201,7 @@ func grampusTrainJobErrorPrepare(ctx *context.Context, processType string, form ctx.ServerError("json.Unmarshal failed:", err) return err } - ctx.Data["run_para_list"] = Parameters.Parameter + ctx.Data["params"] = Parameters.Parameter ctx.Data["boot_file"] = form.BootFile ctx.Data["attachment"] = form.Attachment ctx.Data["branch_name"] = form.BranchName From 56619790a56273d6a8df7de335859393027335e6 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Thu, 21 Jul 2022 08:56:05 +0800 Subject: [PATCH 08/49] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/repo/ai_model_manage.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/routers/repo/ai_model_manage.go b/routers/repo/ai_model_manage.go index 0aef1a70c..d01539a75 100644 --- a/routers/repo/ai_model_manage.go +++ b/routers/repo/ai_model_manage.go @@ -152,6 +152,10 @@ func saveModelByParameters(jobId string, versionName string, name string, versio } func SaveNewNameModel(ctx *context.Context) { + if !ctx.Repo.CanWrite(models.UnitTypeModelManage) { + ctx.Error(403, ctx.Tr("repo.model_noright")) + return + } name := ctx.Query("Name") if name == "" { ctx.Error(500, fmt.Sprintf("name or version is null.")) @@ -169,6 +173,10 @@ func SaveNewNameModel(ctx *context.Context) { } func SaveModel(ctx *context.Context) { + if !ctx.Repo.CanWrite(models.UnitTypeModelManage) { + ctx.Error(403, ctx.Tr("repo.model_noright")) + return + } log.Info("save model start.") JobId := ctx.Query("JobId") VersionName := ctx.Query("VersionName") @@ -177,16 +185,8 @@ func SaveModel(ctx *context.Context) { label := ctx.Query("Label") description := ctx.Query("Description") engine := ctx.QueryInt("Engine") - trainTaskCreate := ctx.QueryBool("trainTaskCreate") modelSelectedFile := ctx.Query("modelSelectedFile") log.Info("engine=" + fmt.Sprint(engine) + " modelSelectedFile=" + modelSelectedFile) - if !trainTaskCreate { - if !ctx.Repo.CanWrite(models.UnitTypeModelManage) { - //ctx.NotFound(ctx.Req.URL.RequestURI(), nil) - ctx.JSON(403, ctx.Tr("repo.model_noright")) - return - } - } if JobId == "" || VersionName == "" { ctx.Error(500, fmt.Sprintf("JobId or VersionName is null.")) From 1ab81931330fb830da3ca542a577bb99a5d95a7d Mon Sep 17 00:00:00 2001 From: chenshihai Date: Thu, 21 Jul 2022 09:26:18 +0800 Subject: [PATCH 09/49] kanban --- .gitignore | 1 + public/kanban/index.html | 12 ------------ templates/base/head.tmpl | 5 +++++ templates/base/head_course.tmpl | 5 +++++ templates/base/head_fluid.tmpl | 5 +++++ templates/base/head_home.tmpl | 5 +++++ templates/base/head_pro.tmpl | 5 +++++ 7 files changed, 26 insertions(+), 12 deletions(-) delete mode 100644 public/kanban/index.html diff --git a/.gitignore b/.gitignore index 9f34fea2a..02f379b0b 100644 --- a/.gitignore +++ b/.gitignore @@ -80,6 +80,7 @@ coverage.all /public/css /public/fonts /public/fomantic +/public/kanban /public/img/svg /VERSION diff --git a/public/kanban/index.html b/public/kanban/index.html deleted file mode 100644 index 0e44d84a3..000000000 --- a/public/kanban/index.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - -
kanban
- - diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index 937abd588..4ab9da231 100755 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -109,6 +109,11 @@ ], {{end}} }; + {{if .IsSigned}} + window.sessionStorage.setItem('_csrf', '{{.CsrfToken}}'); + {{else}} + window.sessionStorage.removeItem('_csrf'); + {{end}} diff --git a/templates/base/head_course.tmpl b/templates/base/head_course.tmpl index 3fff0b8d2..fe21a0e05 100644 --- a/templates/base/head_course.tmpl +++ b/templates/base/head_course.tmpl @@ -109,6 +109,11 @@ ], {{end}} }; + {{if .IsSigned}} + window.sessionStorage.setItem('_csrf', '{{.CsrfToken}}'); + {{else}} + window.sessionStorage.removeItem('_csrf'); + {{end}} diff --git a/templates/base/head_fluid.tmpl b/templates/base/head_fluid.tmpl index 5340c7cb8..1c16e7140 100644 --- a/templates/base/head_fluid.tmpl +++ b/templates/base/head_fluid.tmpl @@ -109,6 +109,11 @@ ], {{end}} }; + {{if .IsSigned}} + window.sessionStorage.setItem('_csrf', '{{.CsrfToken}}'); + {{else}} + window.sessionStorage.removeItem('_csrf'); + {{end}} diff --git a/templates/base/head_home.tmpl b/templates/base/head_home.tmpl index 2def358f8..a77d7b00a 100644 --- a/templates/base/head_home.tmpl +++ b/templates/base/head_home.tmpl @@ -109,6 +109,11 @@ ], {{end}} }; + {{if .IsSigned}} + window.sessionStorage.setItem('_csrf', '{{.CsrfToken}}'); + {{else}} + window.sessionStorage.removeItem('_csrf'); + {{end}} diff --git a/templates/base/head_pro.tmpl b/templates/base/head_pro.tmpl index 75292b6fc..c643ea873 100644 --- a/templates/base/head_pro.tmpl +++ b/templates/base/head_pro.tmpl @@ -109,6 +109,11 @@ ], {{end}} }; + {{if .IsSigned}} + window.sessionStorage.setItem('_csrf', '{{.CsrfToken}}'); + {{else}} + window.sessionStorage.removeItem('_csrf'); + {{end}} From c16a2812393b7e3fab49e45dee256f019833f23c Mon Sep 17 00:00:00 2001 From: Gitea Date: Thu, 21 Jul 2022 11:08:02 +0800 Subject: [PATCH 10/49] fix issue --- web_src/js/features/cloudbrainShow.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/web_src/js/features/cloudbrainShow.js b/web_src/js/features/cloudbrainShow.js index 5e9833616..ab51bf6b5 100644 --- a/web_src/js/features/cloudbrainShow.js +++ b/web_src/js/features/cloudbrainShow.js @@ -189,7 +189,7 @@ export default async function initCloudrainSow() { htmlBread += "
/
"; $(`#file_breadcrumb${version_name}`).append(htmlBread); } else { - renderBrend(path, version_name, parents, filename, init, downloadFlag); + renderBrend(path, version_name, parents, filename, init, downloadFlag,gpuFlag); } }).fail(function (err) { console.log(err, version_name); @@ -223,7 +223,8 @@ export default async function initCloudrainSow() { parents, filename, init, - downloadFlag + downloadFlag, + gpuFlag ) { if (init == "folder") { let htmlBrend = ""; @@ -234,11 +235,11 @@ export default async function initCloudrainSow() { let filename1 = $(`input[name=modelback${version_name}]`).val(); if (parents1 === "") { $(`#file_breadcrumb${version_name} .active.section`).replaceWith( - `
${sectionName}` + `${sectionName}` ); } else { $(`#file_breadcrumb${version_name} .active.section`).replaceWith( - `${sectionName}` + `${sectionName}` ); } @@ -279,7 +280,7 @@ export default async function initCloudrainSow() { html += ""; html += ""; if (data.Dirs[i].IsDir) { - html += ``; + html += ``; html += "" + data.Dirs[i].FileName + From 45bc5d11d5852cd52674edb772f1a8f6297bacda Mon Sep 17 00:00:00 2001 From: Gitea Date: Thu, 21 Jul 2022 11:39:24 +0800 Subject: [PATCH 11/49] fix issue --- templates/repo/cloudbrain/inference/new.tmpl | 2 +- templates/repo/modelarts/inferencejob/new.tmpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/repo/cloudbrain/inference/new.tmpl b/templates/repo/cloudbrain/inference/new.tmpl index 223fcfe1c..d36744ad2 100644 --- a/templates/repo/cloudbrain/inference/new.tmpl +++ b/templates/repo/cloudbrain/inference/new.tmpl @@ -322,7 +322,7 @@ loadCheckpointList(dataID).then((res)=>{ res.forEach(element => { const ckptSuffix = element.FileName.split(".") - const loadCheckpointFile = ['ckpt','pb','h5','json','pkl','pth','t7'] + const loadCheckpointFile = ['ckpt','pb','h5','json','pkl','pth','t7','pdparams','onnx','pbtxt','keras','mlmodel','cfg','pt'] if(!element.IsDir && loadCheckpointFile.includes(ckptSuffix[ckptSuffix.length-1])){ html += `
${element.FileName}
` } diff --git a/templates/repo/modelarts/inferencejob/new.tmpl b/templates/repo/modelarts/inferencejob/new.tmpl index 89f4180c0..6917eb43f 100644 --- a/templates/repo/modelarts/inferencejob/new.tmpl +++ b/templates/repo/modelarts/inferencejob/new.tmpl @@ -339,7 +339,7 @@ loadCheckpointList(dataID).then((res)=>{ res.forEach(element => { const ckptSuffix = element.FileName.split(".") - const loadCheckpointFile = ['ckpt','pb','h5','json','pkl','pth','t7'] + const loadCheckpointFile = ['ckpt','pb','h5','json','pkl','pth','t7','pdparams','onnx','pbtxt','keras','mlmodel','cfg','pt'] if(!element.IsDir && loadCheckpointFile.includes(ckptSuffix[ckptSuffix.length-1])){ html += `
${element.FileName}
` } From 7d5cf069591cfdf351889a91dd2e64c33382dbc3 Mon Sep 17 00:00:00 2001 From: chenshihai Date: Thu, 21 Jul 2022 11:44:19 +0800 Subject: [PATCH 12/49] =?UTF-8?q?fix=20#1172=20=E6=A8=A1=E5=9E=8B=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=9C=892=E4=B8=AA=E5=B1=95=E5=BC=80=E7=9A=84?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E8=8A=82=E7=82=B9=E6=97=B6=EF=BC=8C=E7=BB=99?= =?UTF-8?q?A=E5=88=9B=E5=BB=BA=E6=96=B0=E7=89=88=E6=9C=AC=EF=BC=8CB?= =?UTF-8?q?=E7=9A=84=E5=B1=95=E5=BC=80=E5=9B=BE=E6=A0=87=E4=BC=9A=E6=B6=88?= =?UTF-8?q?=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web_src/js/components/Model.vue | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/web_src/js/components/Model.vue b/web_src/js/components/Model.vue index cb002e76a..cf1210d59 100644 --- a/web_src/js/components/Model.vue +++ b/web_src/js/components/Model.vue @@ -6,7 +6,7 @@ ref="table" :data="tableData" style="min-width: 100%" - row-key="ID" + row-key="rowKey" lazy :load="load" :tree-props="{children: 'Children', hasChildren: 'hasChildren'}" @@ -171,6 +171,7 @@ export default { tableData[i].EngineName = this.getEngineName(tableData[i]) tableData[i].ComputeResource = TrainTaskInfo.ComputeResource tableData[i].cName=tableData[i].Name + tableData[i].rowKey = tableData[i].ID + Math.random() tableData[i].Name='' tableData[i].VersionCount = '' tableData[i].Children = true @@ -310,18 +311,18 @@ export default { const store = this.$refs.table.store if(!this.loadNodeMap.get(row.cName)){ const parent = store.states.data - const index = parent.findIndex(child => child.ID == row.ID) + const index = parent.findIndex(child => child.rowKey == row.rowKey) this.getModelList() }else{ let {tree,treeNode,resolve} = this.loadNodeMap.get(row.cName) const keys = Object.keys(store.states.lazyTreeNodeMap); - if(keys.includes(row.ID)){ + if(keys.includes(row.rowKey)){ this.getModelList() }else{ let parentRow = store.states.data.find(child => child.cName == row.cName); - let childrenIndex = store.states.lazyTreeNodeMap[parentRow.ID].findIndex(child => child.ID == row.ID) + let childrenIndex = store.states.lazyTreeNodeMap[parentRow.rowKey].findIndex(child => child.rowKey == row.rowKey) parentRow.VersionCount = parentRow.VersionCount-1 - const parent = store.states.lazyTreeNodeMap[parentRow.ID] + const parent = store.states.lazyTreeNodeMap[parentRow.rowKey] if(parent.length===1){ this.getModelList() }else{ @@ -379,8 +380,8 @@ export default { } }, getModelList(){ - try { - this.$refs.table.store.states.lazyTreeNodeMap = {} + try { + this.loadNodeMap.clear(); this.$axios.get(location.href+'_api',{ params:this.params }).then((res)=>{ @@ -391,6 +392,7 @@ export default { for(let i=0;i Date: Thu, 21 Jul 2022 11:51:50 +0800 Subject: [PATCH 13/49] #2479 add wechat template msg --- modules/auth/wechat/client.go | 50 ++++++++++++++++++ modules/auth/wechat/template.go | 110 ++++++++++++++++++++++++++++++++++++++++ modules/setting/setting.go | 4 ++ routers/repo/cloudbrain.go | 2 +- 4 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 modules/auth/wechat/template.go diff --git a/modules/auth/wechat/client.go b/modules/auth/wechat/client.go index 9ed4b543f..e137c123f 100644 --- a/modules/auth/wechat/client.go +++ b/modules/auth/wechat/client.go @@ -4,6 +4,7 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "encoding/json" + "errors" "fmt" "github.com/go-resty/resty/v2" "strconv" @@ -19,6 +20,7 @@ const ( ACCESS_TOKEN_PATH = "/cgi-bin/token" QR_CODE_PATH = "/cgi-bin/qrcode/create" GET_MATERIAL_PATH = "/cgi-bin/material/batchget_material" + SEND_TEMPLATE_PATH = "/cgi-bin/message/template/send" ACTION_QR_STR_SCENE = "QR_STR_SCENE" ERR_CODE_ACCESSTOKEN_EXPIRE = 42001 @@ -41,12 +43,33 @@ type QRCodeRequest struct { Action_info ActionInfo `json:"action_info"` Expire_seconds int `json:"expire_seconds"` } + type MaterialRequest struct { Type string `json:"type"` Offset int `json:"offset"` Count int `json:"count"` } +type TemplateMsgRequest struct { + ToUser string `json:"touser"` + TemplateId string `json:"template_id"` + Url string `json:"url"` + ClientMsgId string `json:"client_msg_id"` + Data interface{} `json:"data"` +} +type TemplateValue struct { + Value string `json:"value"` + Color string `json:"color"` +} + +type CloudbrainTaskData struct { + First TemplateValue `json:"first"` + Keyword1 TemplateValue `json:"keyword1"` + Keyword2 TemplateValue `json:"keyword2"` + Keyword3 TemplateValue `json:"keyword3"` + Remark TemplateValue `json:"remark"` +} + type ActionInfo struct { Scene Scene `json:"scene"` } @@ -161,3 +184,30 @@ func getErrorCodeFromResponse(r *resty.Response) int { c, _ := strconv.Atoi(fmt.Sprint(code)) return c } + +func sendTemplateMsg(req TemplateMsgRequest) (error, bool) { + client := getWechatRestyClient() + + bodyJson, _ := json.Marshal(req) + r, err := client.R(). + SetHeader("Content-Type", "application/json"). + SetQueryParam("access_token", GetWechatAccessToken()). + SetBody(bodyJson). + Post(setting.WechatApiHost + SEND_TEMPLATE_PATH) + if err != nil { + log.Error("sendTemplateMsg,e=%v", err) + return nil, false + } + a := r.Body() + resultMap := make(map[string]interface{}, 0) + json.Unmarshal(a, &resultMap) + errcode := resultMap["errcode"] + log.Info("sendTemplateMsg,%v", r) + if errcode == fmt.Sprint(ERR_CODE_ACCESSTOKEN_EXPIRE) || errcode == fmt.Sprint(ERR_CODE_ACCESSTOKEN_INVALID) { + return nil, true + } + if errcode != "" { + return errors.New(fmt.Sprintf("sendTemplateMsg error[%s]", errcode)), false + } + return nil, false +} diff --git a/modules/auth/wechat/template.go b/modules/auth/wechat/template.go new file mode 100644 index 000000000..157f0d92f --- /dev/null +++ b/modules/auth/wechat/template.go @@ -0,0 +1,110 @@ +package wechat + +import ( + "code.gitea.io/gitea/models" + "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/setting" + "errors" + "fmt" + "time" +) + +type JobOperateType string + +const ( + JobOperateTypeStart JobOperateType = "start" + JobOperateTypeStop JobOperateType = "stop" + JobOperateTypeFailed JobOperateType = "failed" +) + +func SendCloudbrainTemplateMsg(operateType JobOperateType, cloudbrain models.Cloudbrain, date time.Time) error { + openId := models.GetUserWechatOpenId(cloudbrain.UserID) + if openId == "" { + return errors.New("Wechat openId not exist") + } + data := CloudbrainTaskData{ + First: TemplateValue{Value: getCloudbrainTemplateTitle(operateType)}, + Keyword1: TemplateValue{Value: cloudbrain.DisplayJobName}, + Keyword2: TemplateValue{Value: getJobTypeDisplayName(cloudbrain.JobType)}, + Keyword3: TemplateValue{Value: date.Format("2006-01-02 15:04:05")}, + Remark: TemplateValue{Value: cloudbrain.DisplayJobName}, + } + req := TemplateMsgRequest{ + ToUser: openId, + TemplateId: setting.CloudbrainTemplateId, + Url: getCloudbrainTemplateUrl(cloudbrain), + ClientMsgId: string(operateType) + "_" + fmt.Sprint(cloudbrain.ID), + Data: data, + } + err, retryFlag := sendTemplateMsg(req) + if retryFlag { + log.Info("retrySendCloudbrainTemplateMsg calling") + refreshAccessToken() + err, _ = sendTemplateMsg(req) + if err != nil { + log.Error("SendCloudbrainTemplateMsg err. %v", err) + return err + } + return nil + } + if err != nil { + log.Error("SendCloudbrainTemplateMsg err. %v", err) + return err + } + return nil +} + +func getCloudbrainTemplateUrl(cloudbrain models.Cloudbrain) string { + url := setting.AppURL + + switch cloudbrain.JobType { + case string(models.JobTypeDebug): + if cloudbrain.ComputeResource == "CPU/GPU" { + url += "/cloudbrain/" + fmt.Sprint(cloudbrain.ID) + } else { + url += "/modelarts/notebook/" + fmt.Sprint(cloudbrain.ID) + } + case string(models.JobTypeBenchmark): + url += "/cloudbrain/benchmark/" + fmt.Sprint(cloudbrain.ID) + case string(models.JobTypeTrain): + if cloudbrain.Type == models.TypeCloudBrainOne { + url += "/cloudbrain/train-job/" + fmt.Sprint(cloudbrain.JobID) + } else if cloudbrain.Type == models.TypeCloudBrainTwo { + url += "/modelarts/train-job" + fmt.Sprint(cloudbrain.JobID) + } else if cloudbrain.Type == models.TypeC2Net { + url += "/grampus/train-job/" + fmt.Sprint(cloudbrain.JobID) + } + case string(models.JobTypeInference): + url += "/modelarts/inference-job/" + fmt.Sprint(cloudbrain.JobID) + } + return url +} + +func getCloudbrainTemplateTitle(operateType JobOperateType) string { + var title string + switch operateType { + case JobOperateTypeStart: + title = "您好,您提交的算力资源申请已通过,任务已启动,请您关注运行情况。" + case JobOperateTypeFailed: + title = "您好,您提交的任务启动失败,您可以通过日志查看失败原因。" + case JobOperateTypeStop: + title = "您好,您提交的任务已运行结束。" + } + + return title + +} + +func getJobTypeDisplayName(jobType string) string { + switch jobType { + case string(models.JobTypeDebug): + return "调试任务" + case string(models.JobTypeBenchmark): + return "评测任务" + case string(models.JobTypeTrain): + return "训练任务" + case string(models.JobTypeInference): + return "推理任务" + } + return "" +} diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 6ec54fdff..c0c5c715f 100755 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -582,6 +582,9 @@ var ( TreePathOfAutoMsgReply string TreePathOfSubscribe string + //wechat template msg config + CloudbrainTemplateId string + //nginx proxy PROXYURL string RadarMap = struct { @@ -1440,6 +1443,7 @@ func NewContext() { RefNameOfWechatReply = sec.Key("AUTO_REPLY_REF_NAME").MustString("master") TreePathOfAutoMsgReply = sec.Key("AUTO_REPLY_TREE_PATH").MustString("wechat/auto_reply.json") TreePathOfSubscribe = sec.Key("SUBSCRIBE_TREE_PATH").MustString("wechat/subscribe_reply.json") + CloudbrainTemplateId = sec.Key("CLOUDBRAIN_TEMPLATE_ID").MustString("4qtOaImiFnzIrzLxxP99lYc12EYxvtAE1fNqd7fcihw") SetRadarMapConfig() diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index bee70965d..59ee08278 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -373,7 +373,6 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { } } - func CloudBrainInferenceJobCreate(ctx *context.Context, form auth.CreateCloudBrainInferencForm) { ctx.Data["PageIsCloudBrain"] = true displayJobName := form.DisplayJobName @@ -494,6 +493,7 @@ func CloudBrainInferenceJobCreate(ctx *context.Context, form auth.CreateCloudBra ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/modelarts/inference-job") } + /** 检查用户传输的参数是否符合专属资源池 */ From ed85b1d84a8814fdb641b76e97deb4d53791b4c7 Mon Sep 17 00:00:00 2001 From: chenshihai Date: Thu, 21 Jul 2022 11:57:54 +0800 Subject: [PATCH 14/49] =?UTF-8?q?fix=20#1347=20=E5=AF=BC=E5=85=A5=E6=96=B0?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E6=97=B6=E8=B6=85=E9=95=BF=E8=AE=AD=E7=BB=83?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=90=8D=E7=A7=B0=E6=98=BE=E7=A4=BA=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E6=9C=89=E9=87=8D=E5=8F=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/repo/modelmanage/index.tmpl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/repo/modelmanage/index.tmpl b/templates/repo/modelmanage/index.tmpl index b54fa5cfa..c42f1ba7b 100644 --- a/templates/repo/modelmanage/index.tmpl +++ b/templates/repo/modelmanage/index.tmpl @@ -6,7 +6,8 @@ text-align: right; } .inline .ui.dropdown .text { - color: rgba(0, 0, 0, .87) !important + color: rgba(0, 0, 0, .87) !important; + max-width: 360px; } .newtext{ left: 15px !important From 2b91b1f8db054ed57dba9ed7ab2699c2a0911d60 Mon Sep 17 00:00:00 2001 From: chenshihai Date: Thu, 21 Jul 2022 12:33:04 +0800 Subject: [PATCH 15/49] =?UTF-8?q?fix=20#2478=20=E8=BF=81=E7=A7=BB=E5=A4=96?= =?UTF-8?q?=E9=83=A8=E9=A1=B9=E7=9B=AE=E6=97=B6=EF=BC=8C=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E7=94=9F=E6=88=90=E7=9A=84=E9=A1=B9=E7=9B=AE=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E6=9C=89=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/repo/migrate.tmpl | 2 +- web_src/js/index.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/repo/migrate.tmpl b/templates/repo/migrate.tmpl index ef667361e..68c8f16d0 100644 --- a/templates/repo/migrate.tmpl +++ b/templates/repo/migrate.tmpl @@ -11,7 +11,7 @@ {{template "base/alert" .}}
- + {{.i18n.Tr "repo.migrate.clone_address_desc"}}{{if .ContextUser.CanImportLocal}} {{.i18n.Tr "repo.migrate.clone_local_path"}}{{end}}
{{.i18n.Tr "repo.migrate.migrate_items_options"}} diff --git a/web_src/js/index.js b/web_src/js/index.js index 53dba8a88..ce859e4df 100755 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -2950,13 +2950,13 @@ $(document).ready(async () => { } const $cloneAddr = $("#clone_addr"); - $cloneAddr.on("change", () => { + $cloneAddr.on("input change", () => { const $repoName = $("#alias"); const $owner = $("#ownerDropdown div.text").attr("title"); const $urlAdd = location.href.split("/")[0] + "//" + location.href.split("/")[2]; - if ($cloneAddr.val().length > 0 && $repoName.val().length === 0) { - // Only modify if repo_name input is blank + if ($cloneAddr.val().length > 0 /* && $repoName.val().length === 0 */) { + // modify when clone address change const repoValue = $cloneAddr.val().match(/^(.*\/)?((.+?)(\.git)?)$/)[3]; $repoName.val($cloneAddr.val().match(/^(.*\/)?((.+?)(\.git)?)$/)[3]); $.get( From ce57f0f98606141e94f44b9f9dd42493c761262b Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Thu, 21 Jul 2022 14:25:07 +0800 Subject: [PATCH 16/49] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- options/locale/locale_en-US.ini | 4 ++-- options/locale/locale_zh-CN.ini | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index b641f4011..105abf006 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1007,7 +1007,7 @@ cloudbrain.time.starttime=Start run time cloudbrain.time.endtime=End run time cloudbrain.datasetdownload=Dataset download url model_manager = Model -model_noright=No right +model_noright=You have no right to do the operation. model_rename=Duplicate model name, please modify model name. date=Date @@ -1225,7 +1225,7 @@ model.manage.create_new_convert_task=Create Model Transformation Task modelconvert.manage.create_error1=A model transformation task with the same name already exists. modelconvert.manage.create_error2=Only one running model transformation task can be created. modelconvert.manage.model_not_exist=The model does not exist. -modelconvert.manage.no_operate_right=No operation permission. +modelconvert.manage.no_operate_right=You have no right to do the operation. grampus.train_job.ai_center = AI Center grampus.dataset_path_rule = The code is storaged in /cache/code;the dataset is storaged in /cache/dataset;and please put your model into /cache/output, then you can download it online。 diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 87630d6c0..1717f5cfd 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -1006,7 +1006,7 @@ datasets.desc=数据集功能 cloudbrain_helper=使用GPU/NPU资源,开启Notebook、模型训练任务等 model_manager = 模型 -model_noright=无权限操作 +model_noright=您没有操作权限。 model_rename=模型名称重复,请修改模型名称 @@ -1237,7 +1237,7 @@ model.manage.create_new_convert_task=创建模型转换任务 modelconvert.manage.create_error1=相同的名称模型转换任务已经存在。 modelconvert.manage.create_error2=只能创建一个正在运行的模型转换任务。 modelconvert.manage.model_not_exist=选择的模型不存在。 -modelconvert.manage.no_operate_right=无操作权限。 +modelconvert.manage.no_operate_right=您没有操作权限。 grampus.train_job.ai_center=智算中心 grampus.dataset_path_rule = 训练脚本存储在/cache/code中,数据集存储在/cache/dataset中,训练输出请存储在/cache/output中以供后续下载。 From c2488397fc2aff65e7d3e7f4626e90bd5dbe8a80 Mon Sep 17 00:00:00 2001 From: Gitea Date: Thu, 21 Jul 2022 14:49:55 +0800 Subject: [PATCH 17/49] fix issue --- web_src/js/features/cloudbrainShow.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web_src/js/features/cloudbrainShow.js b/web_src/js/features/cloudbrainShow.js index ab51bf6b5..12e0b71a4 100644 --- a/web_src/js/features/cloudbrainShow.js +++ b/web_src/js/features/cloudbrainShow.js @@ -175,7 +175,9 @@ export default async function initCloudrainSow() { let url = `/api/v1/repos${path}?version_name=${version_name}&parentDir=${parents}`; $.get(url, (data) => { $(`#dir_list${version_name}`).empty(); - renderDir(path, data, version_name, downloadFlag, gpuFlag); + if(data.Dirs){ + renderDir(path, data, version_name, downloadFlag, gpuFlag); + } if (init === "init") { $(`input[name=model${version_name}]`).val(""); $(`input[name=modelback${version_name}]`).val(version_name); From abb39d7ce29d965ab5d4565048fa58ee2a7799e6 Mon Sep 17 00:00:00 2001 From: chenshihai Date: Thu, 21 Jul 2022 14:50:42 +0800 Subject: [PATCH 18/49] =?UTF-8?q?fix=20#2370=20=E3=80=90=E9=95=9C=E5=83=8F?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E3=80=91=E6=8F=90=E4=BA=A4=E9=95=9C=E5=83=8F?= =?UTF-8?q?=E5=90=8E=E9=A1=B5=E9=9D=A2=E6=B2=A1=E6=9C=89=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E9=95=9C=E5=83=8F=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/repo/debugjob/index.tmpl | 1 + web_src/js/components/images/Images.vue | 40 +++++++++++++++++++++++++++------ 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/templates/repo/debugjob/index.tmpl b/templates/repo/debugjob/index.tmpl index 043816e9f..5381602b9 100755 --- a/templates/repo/debugjob/index.tmpl +++ b/templates/repo/debugjob/index.tmpl @@ -427,6 +427,7 @@ {{if .CanDebug}}
{{$.i18n.Tr "repo.submit_image"}} {{else}} 私有 公开 - - + + - - + + - - + +
@@ -473,6 +473,7 @@ export default { tableDataCustom: [], starCustom:[], loadingCustom:false, + refreshCustomTimer: null, currentPageStar:1, pageSizeStar:10, @@ -485,6 +486,7 @@ export default { methods: { handleClick(tab, event) { this.search = '' + this.stopImageListCustomRefresh(); if(tab.name=="first"){ this.paramsPublic.q = '' this.getImageListPublic() @@ -560,9 +562,31 @@ export default { }); this.loadingCustom = false + this.getImageListCustomRefresh() }) }, + getImageListCustomRefresh() { + this.stopImageListCustomRefresh(); + this.refreshCustomTimer = setInterval(() => { + this.tableDataCustom.forEach(item => { + if (item.status === 0) { + this.$axios.get(`/image/${item.id}`, {}).then((res) => { + const newData = res.data; + this.tableDataCustom.forEach(it => { + if (it.id === newData.id) { + it.status = newData.status; + } + }); + }) + } + }); + }, 5000); + }, + + stopImageListCustomRefresh() { + this.refreshCustomTimer && clearInterval(this.refreshCustomTimer); + }, getImageListStar(){ this.loadingStar = true this.$axios.get('/explore/images/star',{ @@ -715,8 +739,10 @@ export default { else{ this.getImageListPublic() } + }, + beforeDestroy() { + this.stopImageListCustomRefresh(); } - }; From f33089b213397cf34acac0acc44fdcd4e0fbe4cd Mon Sep 17 00:00:00 2001 From: chenshihai Date: Thu, 21 Jul 2022 15:29:23 +0800 Subject: [PATCH 19/49] =?UTF-8?q?fix=20#1345=20=E5=89=8D=E7=AB=AF=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E6=A0=A1=E9=AA=8C=E4=B8=8D=E5=90=88=E6=B3=95=E7=9A=84?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=90=8D=E7=A7=B0=E5=B9=B6=E7=BB=99=E5=87=BA?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/repo/cloudbrain/inference/new.tmpl | 4 ++-- templates/repo/cloudbrain/new.tmpl | 21 +++++++++++++++++++++ templates/repo/cloudbrain/trainjob/new.tmpl | 4 ++-- templates/repo/grampus/trainjob/gpu/new.tmpl | 2 +- templates/repo/grampus/trainjob/npu/new.tmpl | 2 +- templates/repo/modelarts/inferencejob/new.tmpl | 4 ++-- templates/repo/modelarts/notebook/new.tmpl | 22 ++++++++++++++++++++++ templates/repo/modelarts/trainjob/new.tmpl | 2 +- 8 files changed, 52 insertions(+), 9 deletions(-) diff --git a/templates/repo/cloudbrain/inference/new.tmpl b/templates/repo/cloudbrain/inference/new.tmpl index 223fcfe1c..6d3da0be7 100644 --- a/templates/repo/cloudbrain/inference/new.tmpl +++ b/templates/repo/cloudbrain/inference/new.tmpl @@ -421,7 +421,7 @@ identifier : 'display_job_name', rules: [ { - type: 'regExp[/^[a-zA-Z0-9-_]{1,64}[^-]$/]', + type: 'regExp[/^[a-zA-Z0-9-_]{1,64}[a-zA-Z0-9_]$/]', } ] }, @@ -472,9 +472,9 @@ document.getElementById("mask").style.display = "none" } } + validate(); $('.ui.create_train_job.green.button').click(function(e) { send_run_para() get_name() - validate() }) diff --git a/templates/repo/cloudbrain/new.tmpl b/templates/repo/cloudbrain/new.tmpl index f0538261d..9552c80c0 100755 --- a/templates/repo/cloudbrain/new.tmpl +++ b/templates/repo/cloudbrain/new.tmpl @@ -294,6 +294,27 @@ context.value = '' $(".icon.icons").css("visibility", "hidden") } + function validate(){ + $('.ui.form').form({ + on: 'blur', + fields: { + display_job_name:{ + identifier : 'display_job_name', + rules: [ + { + type: 'regExp[/^[a-z0-9][a-z0-9-_]{1,34}[a-z0-9-]$/]', + } + ] + }, + }, + onSuccess: function(){ + }, + onFailure: function(e){ + return false; + } + }) + } + validate(); form.onsubmit = function (e) { let value_task = $("input[name='display_job_name']").val() let value_image = $("input[name='image']").val() diff --git a/templates/repo/cloudbrain/trainjob/new.tmpl b/templates/repo/cloudbrain/trainjob/new.tmpl index c410889b2..07540869d 100755 --- a/templates/repo/cloudbrain/trainjob/new.tmpl +++ b/templates/repo/cloudbrain/trainjob/new.tmpl @@ -483,9 +483,9 @@ $("input#ai_flaver_name").val(name2) } + validate(); $('.ui.create_train_job.green.button').click(function (e) { get_name() - send_run_para() - validate() + send_run_para() }) \ No newline at end of file diff --git a/templates/repo/grampus/trainjob/gpu/new.tmpl b/templates/repo/grampus/trainjob/gpu/new.tmpl index 75b8bcff2..9321532bf 100755 --- a/templates/repo/grampus/trainjob/gpu/new.tmpl +++ b/templates/repo/grampus/trainjob/gpu/new.tmpl @@ -433,9 +433,9 @@ $("input#ai_flavor_name").val(name2) } + validate(); $('.ui.create_train_job.green.button').click(function(e) { get_name() send_run_para() - validate() }) \ No newline at end of file diff --git a/templates/repo/grampus/trainjob/npu/new.tmpl b/templates/repo/grampus/trainjob/npu/new.tmpl index f23942e13..827a2ad8e 100755 --- a/templates/repo/grampus/trainjob/npu/new.tmpl +++ b/templates/repo/grampus/trainjob/npu/new.tmpl @@ -425,9 +425,9 @@ $("input#trainjob_work_server_num").val(val_server_num_select) } + validate(); $('.ui.create_train_job.green.button').click(function(e) { get_name() send_run_para() - validate() }) diff --git a/templates/repo/modelarts/inferencejob/new.tmpl b/templates/repo/modelarts/inferencejob/new.tmpl index 89f4180c0..91d856bf7 100644 --- a/templates/repo/modelarts/inferencejob/new.tmpl +++ b/templates/repo/modelarts/inferencejob/new.tmpl @@ -438,7 +438,7 @@ identifier : 'display_job_name', rules: [ { - type: 'regExp[/^[a-zA-Z0-9-_]{1,64}[^-]$/]', + type: 'regExp[/^[a-zA-Z0-9-_]{1,64}[a-zA-Z0-9_]$/]', } ] }, @@ -489,9 +489,9 @@ document.getElementById("mask").style.display = "none" } } + validate(); $('.ui.create_train_job.green.button').click(function(e) { send_run_para() get_name() - validate() }) diff --git a/templates/repo/modelarts/notebook/new.tmpl b/templates/repo/modelarts/notebook/new.tmpl index 6ab16f941..b81bdfdec 100755 --- a/templates/repo/modelarts/notebook/new.tmpl +++ b/templates/repo/modelarts/notebook/new.tmpl @@ -110,6 +110,28 @@ $('#messageInfo').css('display','none') + function validate(){ + $('.ui.form').form({ + on: 'blur', + fields: { + display_job_name:{ + identifier : 'display_job_name', + rules: [ + { + type: 'regExp[/^[a-z0-9][a-z0-9-_]{1,36}$/]', + } + ] + }, + }, + onSuccess: function(){ + }, + onFailure: function(e){ + return false; + } + }) + } + validate(); + form.onsubmit = function(e){ let value_task = $("input[name='display_job_name']").val() diff --git a/templates/repo/modelarts/trainjob/new.tmpl b/templates/repo/modelarts/trainjob/new.tmpl index e89482dc2..26c57327d 100755 --- a/templates/repo/modelarts/trainjob/new.tmpl +++ b/templates/repo/modelarts/trainjob/new.tmpl @@ -500,9 +500,9 @@ $("input#trainjob_work_server_num").val(val_server_num_select) } + validate(); $('.ui.create_train_job.green.button').click(function (e) { get_name() send_run_para() - validate() }) \ No newline at end of file From 52eac4422dc177775e6fcf62ccf73a0cc7be35bd Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 21 Jul 2022 15:32:46 +0800 Subject: [PATCH 20/49] =?UTF-8?q?=E8=A7=A3=E5=86=B3GPU=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=B8=A6=E5=A4=9A=E7=BA=A7=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- modules/storage/minio_ext.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/storage/minio_ext.go b/modules/storage/minio_ext.go index 4ad83da82..4c0cbac55 100755 --- a/modules/storage/minio_ext.go +++ b/modules/storage/minio_ext.go @@ -187,9 +187,6 @@ func GetOneLevelAllObjectUnderDirMinio(bucket string, prefixRootPath string, rel if val.Key == Prefix { continue } - if strings.Contains(val.Key[prefixLen:len(val.Key)-1], "/") { - continue - } if strings.HasSuffix(val.Key, "/") { isDir = true fileName = val.Key[prefixLen : len(val.Key)-1] From 46a3354d6621db68a8d132f4eac605d03bbe6361 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Thu, 21 Jul 2022 15:41:36 +0800 Subject: [PATCH 21/49] fix issue --- templates/repo/cloudbrain/inference/new.tmpl | 65 +++++++++++++--------- templates/repo/cloudbrain/trainjob/new.tmpl | 65 +++++++++++++--------- templates/repo/grampus/trainjob/gpu/new.tmpl | 34 ++++++----- templates/repo/grampus/trainjob/npu/new.tmpl | 58 +++++++++++++++++-- templates/repo/modelarts/inferencejob/new.tmpl | 36 +++++++++++- templates/repo/modelarts/trainjob/new.tmpl | 38 +++++++++++-- .../js/components/images/selectGrampusImages.vue | 3 + web_src/js/components/images/selectImages.vue | 3 + 8 files changed, 223 insertions(+), 79 deletions(-) diff --git a/templates/repo/cloudbrain/inference/new.tmpl b/templates/repo/cloudbrain/inference/new.tmpl index 223fcfe1c..1126644ec 100644 --- a/templates/repo/cloudbrain/inference/new.tmpl +++ b/templates/repo/cloudbrain/inference/new.tmpl @@ -58,18 +58,7 @@
{{.CsrfTokenHtml}} - - - {{if $.model_version}} - - {{else}} - - {{end}} - {{if $.label_names}} - - {{else}} - - {{end}} +

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

@@ -102,7 +91,11 @@
+ {{if .description}} + + {{else}} + {{end}}
@@ -186,8 +179,21 @@
@@ -196,8 +202,8 @@
- {{if .bootFile}} - + {{if .boot_file}} + {{else}} {{end}} @@ -244,9 +250,22 @@
@@ -397,13 +416,6 @@ msg = JSON.stringify(msg) $('#store_run_para').val(msg) } - function get_name(){ - let name1=$("#engine_name .text").text() - let name2=$("#flaver_name .text").text() - $("input#ai_engine_name").val(name1) - $("input#ai_flaver_name").val(name2) - - } function validate(){ $('.ui.form') .form({ @@ -474,7 +486,6 @@ } $('.ui.create_train_job.green.button').click(function(e) { send_run_para() - get_name() validate() }) diff --git a/templates/repo/cloudbrain/trainjob/new.tmpl b/templates/repo/cloudbrain/trainjob/new.tmpl index c410889b2..756a378ff 100755 --- a/templates/repo/cloudbrain/trainjob/new.tmpl +++ b/templates/repo/cloudbrain/trainjob/new.tmpl @@ -89,8 +89,7 @@ {{.CsrfTokenHtml}} - - +

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

@@ -140,11 +139,11 @@
- + {{if .description}} + + {{else}} + + {{end}}
@@ -179,13 +178,25 @@
-
@@ -195,8 +206,8 @@
- {{if .bootFile}} - {{else}} {{.i18n.Tr "repo.modelarts.train_job.add_run_parameter"}}
- {{if .params}} {{if ne 0 (len .params)}} {{range $k ,$v := .params}}
@@ -238,17 +248,28 @@
{{end}} {{end}} - {{end}}
-
@@ -476,15 +497,7 @@ msg = JSON.stringify(msg) $('#store_run_para').val(msg) } - function get_name() { - let name1 = $("#engine_name .text").text() - let name2 = $("#flaver_name .text").text() - $("input#ai_engine_name").val(name1) - $("input#ai_flaver_name").val(name2) - - } $('.ui.create_train_job.green.button').click(function (e) { - get_name() send_run_para() validate() }) diff --git a/templates/repo/grampus/trainjob/gpu/new.tmpl b/templates/repo/grampus/trainjob/gpu/new.tmpl index 75b8bcff2..3b9d5cea9 100755 --- a/templates/repo/grampus/trainjob/gpu/new.tmpl +++ b/templates/repo/grampus/trainjob/gpu/new.tmpl @@ -80,8 +80,7 @@ {{.CsrfTokenHtml}} - - +

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

@@ -123,7 +122,11 @@
+ {{if .description}} + + {{else}} + {{end}}
@@ -156,8 +159,8 @@
- {{if .bootFile}} - + {{if .boot_file}} + {{else}} {{end}} @@ -199,8 +202,21 @@
@@ -426,15 +442,7 @@ msg = JSON.stringify(msg) $('#store_run_para').val(msg) } - function get_name(){ - let name1=$("#engine_name .text").text() - let name2=$("#flavor_name .text").text() - $("input#ai_engine_name").val(name1) - $("input#ai_flavor_name").val(name2) - - } $('.ui.create_train_job.green.button').click(function(e) { - get_name() send_run_para() validate() }) diff --git a/templates/repo/grampus/trainjob/npu/new.tmpl b/templates/repo/grampus/trainjob/npu/new.tmpl index f23942e13..ebc52b6a1 100755 --- a/templates/repo/grampus/trainjob/npu/new.tmpl +++ b/templates/repo/grampus/trainjob/npu/new.tmpl @@ -119,7 +119,11 @@
+ {{if .description}} + + {{else}} + {{end}}
@@ -150,16 +154,29 @@
- {{if .bootFile}} - + {{if .boot_file}} + {{else}} {{end}} @@ -176,14 +193,45 @@ {{.i18n.Tr "repo.modelarts.train_job.add_run_parameter"}}
+ {{if .params}} + {{if ne 0 (len .params)}} + {{range $k ,$v := .params}} +
+
+ +
+
+ +
+ + + + +
+ {{end}} + {{end}} + {{end}}
diff --git a/templates/repo/modelarts/inferencejob/new.tmpl b/templates/repo/modelarts/inferencejob/new.tmpl index 89f4180c0..2a8ec9207 100644 --- a/templates/repo/modelarts/inferencejob/new.tmpl +++ b/templates/repo/modelarts/inferencejob/new.tmpl @@ -99,8 +99,12 @@
-    + + {{if .description}} + + {{else}} + {{end}}
@@ -169,9 +173,22 @@
@@ -251,8 +268,21 @@
diff --git a/templates/repo/modelarts/trainjob/new.tmpl b/templates/repo/modelarts/trainjob/new.tmpl index e89482dc2..74987a4e2 100755 --- a/templates/repo/modelarts/trainjob/new.tmpl +++ b/templates/repo/modelarts/trainjob/new.tmpl @@ -128,7 +128,11 @@
+ {{if .description}} + + {{else}} + {{end}}
@@ -170,9 +174,22 @@
@@ -220,7 +237,6 @@
- diff --git a/web_src/js/components/images/selectGrampusImages.vue b/web_src/js/components/images/selectGrampusImages.vue index 5bbc3a43e..f702c8cca 100755 --- a/web_src/js/components/images/selectGrampusImages.vue +++ b/web_src/js/components/images/selectGrampusImages.vue @@ -225,6 +225,9 @@ export default { }, }, mounted() { + if (document.getElementById("ai_image_name")) { + this.imageAddress = document.getElementById("ai_image_name").value; + } this.getImageListPublic(); if ( location.href.indexOf("benchmark") !== -1 || diff --git a/web_src/js/components/images/selectImages.vue b/web_src/js/components/images/selectImages.vue index d4eb8d613..844303420 100755 --- a/web_src/js/components/images/selectImages.vue +++ b/web_src/js/components/images/selectImages.vue @@ -498,6 +498,9 @@ export default { }, }, mounted() { + if (document.getElementById("ai_image_name")) { + this.imageAddress = document.getElementById("ai_image_name").value; + } this.getImageListPublic(); if ( location.href.indexOf("train-job") !== -1 || From 347bb1a217f49c4253d17552732c9da7838e3eaa Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Thu, 21 Jul 2022 16:06:21 +0800 Subject: [PATCH 22/49] fix issue --- templates/repo/cloudbrain/inference/new.tmpl | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/templates/repo/cloudbrain/inference/new.tmpl b/templates/repo/cloudbrain/inference/new.tmpl index 1126644ec..d1ef19300 100644 --- a/templates/repo/cloudbrain/inference/new.tmpl +++ b/templates/repo/cloudbrain/inference/new.tmpl @@ -219,22 +219,7 @@ {{.i18n.Tr "repo.modelarts.train_job.add_run_parameter"}}
- {{if ne 0 (len .params)}} - {{range $k ,$v := .params}} -
-
- -
-
- -
- - - - -
- {{end}} - {{end}} + {{.params}}
From aa631ec99a848aaa4e6dfc75d1e10ec1065556e6 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Thu, 21 Jul 2022 16:42:09 +0800 Subject: [PATCH 23/49] #2479 update wechat template msg --- models/cloudbrain.go | 11 +++++- modules/auth/wechat/client.go | 4 --- modules/auth/wechat/template.go | 64 ++++++++++++++++++++++++++++------- modules/notification/base/notifier.go | 2 ++ modules/notification/base/null.go | 4 +++ modules/notification/notification.go | 9 +++++ modules/notification/wechat/wechat.go | 38 +++++++++++++++++++++ modules/setting/setting.go | 4 +-- routers/api/v1/repo/cloudbrain.go | 11 ++++-- routers/api/v1/repo/modelarts.go | 20 +++++++++-- routers/repo/cloudbrain.go | 33 +++++++++++++++++- routers/repo/grampus.go | 10 +++++- routers/repo/modelarts.go | 6 ++++ 13 files changed, 189 insertions(+), 27 deletions(-) create mode 100644 modules/notification/wechat/wechat.go diff --git a/models/cloudbrain.go b/models/cloudbrain.go index af53bad32..f32ad5870 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -206,7 +206,16 @@ func (task *Cloudbrain) CorrectCreateUnix() { func (task *Cloudbrain) IsTerminal() bool { status := task.Status - return status == string(ModelArtsTrainJobCompleted) || status == string(ModelArtsTrainJobFailed) || status == string(ModelArtsTrainJobKilled) || status == string(ModelArtsStopped) || status == string(JobStopped) || status == string(JobFailed) || status == string(JobSucceeded) + return status == string(ModelArtsTrainJobCompleted) || status == string(ModelArtsTrainJobFailed) || + status == string(ModelArtsTrainJobKilled) || status == string(ModelArtsStopped) || + status == string(JobStopped) || status == string(JobFailed) || + status == string(JobSucceeded) || status == GrampusStatusFailed || + status == GrampusStatusSucceeded || status == GrampusStatusStopped +} +func (task *Cloudbrain) IsRunning() bool { + status := task.Status + return status == string(ModelArtsTrainJobRunning) || status == string(ModelArtsRunning) || + status == string(JobRunning) || status == GrampusStatusRunning } func ConvertDurationToStr(duration int64) string { diff --git a/modules/auth/wechat/client.go b/modules/auth/wechat/client.go index e137c123f..bb6db09d0 100644 --- a/modules/auth/wechat/client.go +++ b/modules/auth/wechat/client.go @@ -4,7 +4,6 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "encoding/json" - "errors" "fmt" "github.com/go-resty/resty/v2" "strconv" @@ -206,8 +205,5 @@ func sendTemplateMsg(req TemplateMsgRequest) (error, bool) { if errcode == fmt.Sprint(ERR_CODE_ACCESSTOKEN_EXPIRE) || errcode == fmt.Sprint(ERR_CODE_ACCESSTOKEN_INVALID) { return nil, true } - if errcode != "" { - return errors.New(fmt.Sprintf("sendTemplateMsg error[%s]", errcode)), false - } return nil, false } diff --git a/modules/auth/wechat/template.go b/modules/auth/wechat/template.go index 157f0d92f..7e5f7cd06 100644 --- a/modules/auth/wechat/template.go +++ b/modules/auth/wechat/template.go @@ -12,12 +12,39 @@ import ( type JobOperateType string const ( - JobOperateTypeStart JobOperateType = "start" - JobOperateTypeStop JobOperateType = "stop" - JobOperateTypeFailed JobOperateType = "failed" + JobOperateTypeStart JobOperateType = "start" + JobOperateTypeStop JobOperateType = "stop" ) -func SendCloudbrainTemplateMsg(operateType JobOperateType, cloudbrain models.Cloudbrain, date time.Time) error { +func GetJobOperateTypeFromCloudbrainStatus(cloudbrain *models.Cloudbrain) JobOperateType { + if cloudbrain.IsTerminal() { + return JobOperateTypeStop + } + if cloudbrain.IsRunning() { + return JobOperateTypeStart + } + return "" +} + +func SendCloudbrainStartedMsg(operateType JobOperateType, cloudbrain models.Cloudbrain, date time.Time) error { + defer func() { + if err := recover(); err != nil { + combinedErr := fmt.Errorf("%s\n%s", err, log.Stack(2)) + log.Error("PANIC:", combinedErr) + } + }() + repo, err := models.GetRepositoryByID(cloudbrain.RepoID) + if err != nil { + log.Error("SendCloudbrainStartedMsg GetRepositoryByID error,%v", err) + } + + if setting.CloudbrainStartedTemplateId == "" { + return nil + } + + if date.IsZero() { + date = time.Now() + } openId := models.GetUserWechatOpenId(cloudbrain.UserID) if openId == "" { return errors.New("Wechat openId not exist") @@ -27,12 +54,12 @@ func SendCloudbrainTemplateMsg(operateType JobOperateType, cloudbrain models.Clo Keyword1: TemplateValue{Value: cloudbrain.DisplayJobName}, Keyword2: TemplateValue{Value: getJobTypeDisplayName(cloudbrain.JobType)}, Keyword3: TemplateValue{Value: date.Format("2006-01-02 15:04:05")}, - Remark: TemplateValue{Value: cloudbrain.DisplayJobName}, + Remark: TemplateValue{Value: getCloudbrainTemplateRemark(operateType)}, } req := TemplateMsgRequest{ ToUser: openId, - TemplateId: setting.CloudbrainTemplateId, - Url: getCloudbrainTemplateUrl(cloudbrain), + TemplateId: setting.CloudbrainStartedTemplateId, + Url: getCloudbrainTemplateUrl(cloudbrain, repo), ClientMsgId: string(operateType) + "_" + fmt.Sprint(cloudbrain.ID), Data: data, } @@ -42,20 +69,20 @@ func SendCloudbrainTemplateMsg(operateType JobOperateType, cloudbrain models.Clo refreshAccessToken() err, _ = sendTemplateMsg(req) if err != nil { - log.Error("SendCloudbrainTemplateMsg err. %v", err) + log.Error("SendCloudbrainStartedMsg err. %v", err) return err } return nil } if err != nil { - log.Error("SendCloudbrainTemplateMsg err. %v", err) + log.Error("SendCloudbrainStartedMsg err. %v", err) return err } return nil } -func getCloudbrainTemplateUrl(cloudbrain models.Cloudbrain) string { - url := setting.AppURL +func getCloudbrainTemplateUrl(cloudbrain models.Cloudbrain, repo *models.Repository) string { + url := setting.AppURL + repo.FullName() switch cloudbrain.JobType { case string(models.JobTypeDebug): @@ -85,8 +112,6 @@ func getCloudbrainTemplateTitle(operateType JobOperateType) string { switch operateType { case JobOperateTypeStart: title = "您好,您提交的算力资源申请已通过,任务已启动,请您关注运行情况。" - case JobOperateTypeFailed: - title = "您好,您提交的任务启动失败,您可以通过日志查看失败原因。" case JobOperateTypeStop: title = "您好,您提交的任务已运行结束。" } @@ -95,6 +120,19 @@ func getCloudbrainTemplateTitle(operateType JobOperateType) string { } +func getCloudbrainTemplateRemark(operateType JobOperateType) string { + var remark string + switch operateType { + case JobOperateTypeStart: + remark = "感谢您的耐心等待。" + case JobOperateTypeStop: + remark = "点击可查看运行结果" + } + + return remark + +} + func getJobTypeDisplayName(jobType string) string { switch jobType { case string(models.JobTypeDebug): diff --git a/modules/notification/base/notifier.go b/modules/notification/base/notifier.go index 8d6fdeb52..3bdc29d46 100644 --- a/modules/notification/base/notifier.go +++ b/modules/notification/base/notifier.go @@ -56,4 +56,6 @@ type Notifier interface { NotifySyncDeleteRef(doer *models.User, repo *models.Repository, refType, refFullName string) NotifyOtherTask(doer *models.User, repo *models.Repository, id string, name string, optype models.ActionType) + + NotifyChangeCloudbrainStatus(cloudbrain *models.Cloudbrain, oldStatus string) } diff --git a/modules/notification/base/null.go b/modules/notification/base/null.go index 0d3489882..6a24963d2 100644 --- a/modules/notification/base/null.go +++ b/modules/notification/base/null.go @@ -158,3 +158,7 @@ func (*NullNotifier) NotifySyncDeleteRef(doer *models.User, repo *models.Reposit func (*NullNotifier) NotifyOtherTask(doer *models.User, repo *models.Repository, id string, name string, optype models.ActionType) { } + +func (*NullNotifier) NotifyChangeCloudbrainStatus(cloudbrain *models.Cloudbrain, oldStatus string) { + +} diff --git a/modules/notification/notification.go b/modules/notification/notification.go index 0fd6fa471..b6d925f07 100644 --- a/modules/notification/notification.go +++ b/modules/notification/notification.go @@ -12,6 +12,7 @@ import ( "code.gitea.io/gitea/modules/notification/mail" "code.gitea.io/gitea/modules/notification/ui" "code.gitea.io/gitea/modules/notification/webhook" + wechatNotifier "code.gitea.io/gitea/modules/notification/wechat" "code.gitea.io/gitea/modules/repository" "code.gitea.io/gitea/modules/setting" ) @@ -35,6 +36,7 @@ func NewContext() { RegisterNotifier(indexer.NewNotifier()) RegisterNotifier(webhook.NewNotifier()) RegisterNotifier(action.NewNotifier()) + RegisterNotifier(wechatNotifier.NewNotifier()) } // NotifyUploadAttachment notifies attachment upload message to notifiers @@ -269,3 +271,10 @@ func NotifySyncDeleteRef(pusher *models.User, repo *models.Repository, refType, notifier.NotifySyncDeleteRef(pusher, repo, refType, refFullName) } } + +// NotifyChangeCloudbrainStatus +func NotifyChangeCloudbrainStatus(cloudbrain *models.Cloudbrain, oldStatus string) { + for _, notifier := range notifiers { + notifier.NotifyChangeCloudbrainStatus(cloudbrain, oldStatus) + } +} diff --git a/modules/notification/wechat/wechat.go b/modules/notification/wechat/wechat.go new file mode 100644 index 000000000..c995d9433 --- /dev/null +++ b/modules/notification/wechat/wechat.go @@ -0,0 +1,38 @@ +// Copyright 2019 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package mail + +import ( + "code.gitea.io/gitea/models" + "code.gitea.io/gitea/modules/auth/wechat" + "code.gitea.io/gitea/modules/notification/base" + "time" +) + +type wechatNotifier struct { + base.NullNotifier +} + +var ( + _ base.Notifier = &wechatNotifier{} +) + +// NewNotifier create a new wechatNotifier notifier +func NewNotifier() base.Notifier { + return &wechatNotifier{} +} + +func (*wechatNotifier) NotifyChangeCloudbrainStatus(cloudbrain *models.Cloudbrain, oldStatus string) { + operateType := wechat.GetJobOperateTypeFromCloudbrainStatus(cloudbrain) + if operateType == "" { + return + } + switch operateType { + case wechat.JobOperateTypeStart: + if cloudbrain.JobType == string(models.JobTypeDebug) { + go wechat.SendCloudbrainStartedMsg(operateType, *cloudbrain, time.Unix(int64(cloudbrain.StartTime), 0)) + } + } +} diff --git a/modules/setting/setting.go b/modules/setting/setting.go index c0c5c715f..35789c18b 100755 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -583,7 +583,7 @@ var ( TreePathOfSubscribe string //wechat template msg config - CloudbrainTemplateId string + CloudbrainStartedTemplateId string //nginx proxy PROXYURL string @@ -1443,7 +1443,7 @@ func NewContext() { RefNameOfWechatReply = sec.Key("AUTO_REPLY_REF_NAME").MustString("master") TreePathOfAutoMsgReply = sec.Key("AUTO_REPLY_TREE_PATH").MustString("wechat/auto_reply.json") TreePathOfSubscribe = sec.Key("SUBSCRIBE_TREE_PATH").MustString("wechat/subscribe_reply.json") - CloudbrainTemplateId = sec.Key("CLOUDBRAIN_TEMPLATE_ID").MustString("4qtOaImiFnzIrzLxxP99lYc12EYxvtAE1fNqd7fcihw") + CloudbrainStartedTemplateId = sec.Key("CLOUDBRAIN_STARTED_TEMPLATE_ID").MustString("") SetRadarMapConfig() diff --git a/routers/api/v1/repo/cloudbrain.go b/routers/api/v1/repo/cloudbrain.go index d291024f9..caa0660cd 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/notification" "encoding/json" "net/http" "sort" @@ -74,7 +75,7 @@ func GetCloudbrainTask(ctx *context.APIContext) { log.Error("ConvertToJobResultPayload failed:", err) return } - + oldStatus := job.Status job.Status = result.JobStatus.State taskRoles := result.TaskRoles taskRes, _ := models.ConvertToTaskPod(taskRoles[cloudbrain.SubTaskName].(map[string]interface{})) @@ -86,6 +87,9 @@ func GetCloudbrainTask(ctx *context.APIContext) { if result.JobStatus.State != string(models.JobWaiting) { models.ParseAndSetDurationFromCloudBrainOne(result, job) + if oldStatus != job.Status { + notification.NotifyChangeCloudbrainStatus(job, oldStatus) + } err = models.UpdateJob(job) if err != nil { log.Error("UpdateJob failed:", err) @@ -123,7 +127,7 @@ func GetCloudBrainInferenceJob(ctx *context.APIContext) { log.Error("ConvertToJobResultPayload failed:", err) return } - + oldStatus := job.Status job.Status = result.JobStatus.State if result.JobStatus.State != string(models.JobWaiting) && result.JobStatus.State != string(models.JobFailed) { taskRoles := result.TaskRoles @@ -136,6 +140,9 @@ func GetCloudBrainInferenceJob(ctx *context.APIContext) { if result.JobStatus.State != string(models.JobWaiting) { models.ParseAndSetDurationFromCloudBrainOne(result, job) + if oldStatus != job.Status { + notification.NotifyChangeCloudbrainStatus(job, oldStatus) + } 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 187c16c50..54220fbca 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/notification" "encoding/json" "net/http" "path" @@ -42,8 +43,11 @@ func GetModelArtsNotebook(ctx *context.APIContext) { ctx.NotFound(err) return } - + oldStatus := job.Status job.Status = result.Status + if oldStatus != result.Status { + notification.NotifyChangeCloudbrainStatus(job, oldStatus) + } err = models.UpdateJob(job) if err != nil { log.Error("UpdateJob failed:", err) @@ -75,12 +79,16 @@ func GetModelArtsNotebook2(ctx *context.APIContext) { if job.StartTime == 0 && result.Lease.UpdateTime > 0 { job.StartTime = timeutil.TimeStamp(result.Lease.UpdateTime / 1000) } + oldStatus := job.Status job.Status = result.Status if job.EndTime == 0 && models.IsModelArtsDebugJobTerminal(job.Status) { job.EndTime = timeutil.TimeStampNow() } job.CorrectCreateUnix() job.ComputeAndSetDuration() + if oldStatus != result.Status { + notification.NotifyChangeCloudbrainStatus(job, oldStatus) + } err = models.UpdateJob(job) if err != nil { log.Error("UpdateJob failed:", err) @@ -111,10 +119,13 @@ func GetModelArtsTrainJob(ctx *context.APIContext) { ctx.NotFound(err) return } - + oldStatus := job.Status job.Status = modelarts.TransTrainJobStatus(result.IntStatus) job.Duration = result.Duration job.TrainJobDuration = result.TrainJobDuration + if oldStatus != job.Status { + notification.NotifyChangeCloudbrainStatus(job, oldStatus) + } err = models.UpdateJob(job) if err != nil { log.Error("UpdateJob failed:", err) @@ -155,7 +166,7 @@ func GetModelArtsTrainJobVersion(ctx *context.APIContext) { log.Error("ConvertToJobResultPayload failed:", err) return } - + oldStatus := job.Status job.Status = result.JobStatus.State if result.JobStatus.State != string(models.JobWaiting) && result.JobStatus.State != string(models.JobFailed) { taskRoles := result.TaskRoles @@ -168,6 +179,9 @@ func GetModelArtsTrainJobVersion(ctx *context.APIContext) { if result.JobStatus.State != string(models.JobWaiting) { models.ParseAndSetDurationFromCloudBrainOne(result, job) + if oldStatus != job.Status { + notification.NotifyChangeCloudbrainStatus(job, oldStatus) + } 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 59ee08278..da9801664 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -2,6 +2,7 @@ package repo import ( "bufio" + "code.gitea.io/gitea/modules/notification" "encoding/json" "errors" "fmt" @@ -784,12 +785,16 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo taskRes, _ := models.ConvertToTaskPod(taskRoles[cloudbrain.SubTaskName].(map[string]interface{})) ctx.Data["taskRes"] = taskRes ctx.Data["ExitDiagnostics"] = taskRes.TaskStatuses[0].ExitDiagnostics + oldStatus := task.Status task.Status = taskRes.TaskStatuses[0].State task.ContainerID = taskRes.TaskStatuses[0].ContainerID task.ContainerIp = taskRes.TaskStatuses[0].ContainerIP models.ParseAndSetDurationFromCloudBrainOne(jobRes, task) if task.DeletedAt.IsZero() { //normal record + if oldStatus != task.Status { + notification.NotifyChangeCloudbrainStatus(task, oldStatus) + } err = models.UpdateJob(task) if err != nil { ctx.Data["error"] = err.Error() @@ -1143,12 +1148,15 @@ func CloudBrainStop(ctx *context.Context) { errorMsg = "cloudbrain.Stopped_failed" break } - + oldStatus := task.Status task.Status = string(models.JobStopped) if task.EndTime == 0 { task.EndTime = timeutil.TimeStampNow() } task.ComputeAndSetDuration() + if oldStatus != task.Status { + notification.NotifyChangeCloudbrainStatus(task, oldStatus) + } err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob(%s) failed:%v", task.JobName, err, ctx.Data["msgID"]) @@ -1242,11 +1250,15 @@ func logErrorAndUpdateJobStatus(err error, taskInfo *models.Cloudbrain) { if err != nil { log.Warn("Failed to stop cloudBrain job:"+taskInfo.JobID, err) } else { + oldStatus := taskInfo.Status taskInfo.Status = string(models.JobStopped) if taskInfo.EndTime == 0 { taskInfo.EndTime = timeutil.TimeStampNow() } taskInfo.ComputeAndSetDuration() + if oldStatus != taskInfo.Status { + notification.NotifyChangeCloudbrainStatus(taskInfo, oldStatus) + } err = models.UpdateJob(taskInfo) if err != nil { log.Warn("UpdateJob failed", err) @@ -1726,9 +1738,13 @@ func SyncCloudbrainStatus() { jobRes, _ := models.ConvertToJobResultPayload(result.Payload) taskRoles := jobRes.TaskRoles taskRes, _ := models.ConvertToTaskPod(taskRoles[cloudbrain.SubTaskName].(map[string]interface{})) + oldStatus := task.Status task.Status = taskRes.TaskStatuses[0].State if task.Status != string(models.JobWaiting) { models.ParseAndSetDurationFromCloudBrainOne(jobRes, task) + if oldStatus != task.Status { + notification.NotifyChangeCloudbrainStatus(task, oldStatus) + } err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob(%s) failed:%v", task.JobName, err) @@ -1755,6 +1771,9 @@ func SyncCloudbrainStatus() { task.EndTime = timeutil.TimeStampNow() } task.ComputeAndSetDuration() + if oldStatus != task.Status { + notification.NotifyChangeCloudbrainStatus(task, oldStatus) + } err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob(%s) failed:%v", task.DisplayJobName, err) @@ -1773,6 +1792,7 @@ func SyncCloudbrainStatus() { } if result != nil { + oldStatus := task.Status task.Status = result.Status if task.StartTime == 0 && result.Lease.UpdateTime > 0 { task.StartTime = timeutil.TimeStamp(result.Lease.UpdateTime / 1000) @@ -1782,6 +1802,9 @@ func SyncCloudbrainStatus() { } task.CorrectCreateUnix() task.ComputeAndSetDuration() + if oldStatus != task.Status { + notification.NotifyChangeCloudbrainStatus(task, oldStatus) + } err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob(%s) failed:%v", task.JobName, err) @@ -1796,6 +1819,7 @@ func SyncCloudbrainStatus() { } if result != nil { + oldStatus := task.Status task.Status = modelarts.TransTrainJobStatus(result.IntStatus) task.Duration = result.Duration / 1000 task.TrainJobDuration = result.TrainJobDuration @@ -1808,6 +1832,9 @@ func SyncCloudbrainStatus() { task.EndTime = task.StartTime.Add(task.Duration) } task.CorrectCreateUnix() + if oldStatus != task.Status { + notification.NotifyChangeCloudbrainStatus(task, oldStatus) + } err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob(%s) failed:%v", task.JobName, err) @@ -1828,6 +1855,7 @@ func SyncCloudbrainStatus() { if len(result.JobInfo.Tasks[0].CenterID) == 1 && len(result.JobInfo.Tasks[0].CenterName) == 1 { task.AiCenter = result.JobInfo.Tasks[0].CenterID[0] + "+" + result.JobInfo.Tasks[0].CenterName[0] } + oldStatus := task.Status task.Status = grampus.TransTrainJobStatus(result.JobInfo.Status) task.Duration = result.JobInfo.RunSec task.TrainJobDuration = models.ConvertDurationToStr(task.Duration) @@ -1839,6 +1867,9 @@ func SyncCloudbrainStatus() { task.EndTime = task.StartTime.Add(task.Duration) } task.CorrectCreateUnix() + if oldStatus != task.Status { + notification.NotifyChangeCloudbrainStatus(task, oldStatus) + } err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob(%s) failed:%v", task.JobName, err) diff --git a/routers/repo/grampus.go b/routers/repo/grampus.go index 7d6aa1c30..53fd9be30 100755 --- a/routers/repo/grampus.go +++ b/routers/repo/grampus.go @@ -5,6 +5,7 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/grampus" "code.gitea.io/gitea/modules/modelarts" + "code.gitea.io/gitea/modules/notification" "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/util" "encoding/json" @@ -550,12 +551,15 @@ func GrampusStopJob(ctx *context.Context) { errorMsg = res.ErrorMsg break } - + oldStatus := task.Status task.Status = string(models.GrampusStatusStopped) if task.EndTime == 0 { task.EndTime = timeutil.TimeStampNow() } task.ComputeAndSetDuration() + if oldStatus != task.Status { + notification.NotifyChangeCloudbrainStatus(task, oldStatus) + } err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob(%s) failed:%v", task.JobName, err, ctx.Data["msgID"]) @@ -642,6 +646,7 @@ func GrampusTrainJobShow(ctx *context.Context) { if len(result.JobInfo.Tasks[0].CenterID) == 1 && len(result.JobInfo.Tasks[0].CenterName) == 1 { task.AiCenter = result.JobInfo.Tasks[0].CenterID[0] + "+" + result.JobInfo.Tasks[0].CenterName[0] } + oldStatus := task.Status task.Status = grampus.TransTrainJobStatus(result.JobInfo.Status) if task.Status != result.JobInfo.Status || result.JobInfo.Status == models.GrampusStatusRunning { task.Duration = result.JobInfo.RunSec @@ -654,6 +659,9 @@ func GrampusTrainJobShow(ctx *context.Context) { task.EndTime = task.StartTime.Add(task.Duration) } task.CorrectCreateUnix() + if oldStatus != task.Status { + notification.NotifyChangeCloudbrainStatus(task, oldStatus) + } err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob failed:" + err.Error()) diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index ccdc31337..88bf0d22a 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -272,8 +272,10 @@ func NotebookShow(ctx *context.Context) { if result != nil { if task.DeletedAt.IsZero() { //normal record if task.Status != result.Status { + oldStatus := task.Status task.Status = result.Status models.ParseAndSetDurationFromModelArtsNotebook(result, task) + notification.NotifyChangeCloudbrainStatus(task, oldStatus) err = models.UpdateJob(task) if err != nil { log.Error("GET job error", err.Error()) @@ -510,11 +512,15 @@ func NotebookManage(ctx *context.Context) { ID = strconv.FormatInt(newTask.ID, 10) notification.NotifyOtherTask(ctx.User, ctx.Repo.Repository, ID, task.DisplayJobName, models.ActionCreateDebugNPUTask) } else { + oldStatus := task.Status task.Status = res.Status if task.EndTime == 0 && models.IsModelArtsDebugJobTerminal(task.Status) { task.EndTime = timeutil.TimeStampNow() } task.ComputeAndSetDuration() + if oldStatus != task.Status { + notification.NotifyChangeCloudbrainStatus(task, oldStatus) + } err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob(%s) failed:%v", task.JobName, err.Error(), ctx.Data["MsgID"]) From 11a1099cdee15b01b75d335dffc8454b213af730 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Thu, 21 Jul 2022 17:16:32 +0800 Subject: [PATCH 24/49] fix issue --- templates/repo/cloudbrain/inference/new.tmpl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/templates/repo/cloudbrain/inference/new.tmpl b/templates/repo/cloudbrain/inference/new.tmpl index d1ef19300..cfdbc6e75 100644 --- a/templates/repo/cloudbrain/inference/new.tmpl +++ b/templates/repo/cloudbrain/inference/new.tmpl @@ -59,6 +59,16 @@ {{.CsrfTokenHtml}} + {{if $.model_version}} + + {{else}} + + {{end}} + {{if $.label_names}} + + {{else}} + + {{end}}

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

From 132030bc04afca71075e4f7d6a63a8841c2ef86b Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Thu, 21 Jul 2022 17:18:43 +0800 Subject: [PATCH 25/49] #2479 update --- modules/auth/wechat/template.go | 7 ++----- modules/notification/wechat/wechat.go | 12 +++++++++--- modules/setting/setting.go | 2 ++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/modules/auth/wechat/template.go b/modules/auth/wechat/template.go index 7e5f7cd06..0620aa7b9 100644 --- a/modules/auth/wechat/template.go +++ b/modules/auth/wechat/template.go @@ -26,7 +26,7 @@ func GetJobOperateTypeFromCloudbrainStatus(cloudbrain *models.Cloudbrain) JobOpe return "" } -func SendCloudbrainStartedMsg(operateType JobOperateType, cloudbrain models.Cloudbrain, date time.Time) error { +func SendCloudbrainStartedMsg(operateType JobOperateType, cloudbrain models.Cloudbrain) error { defer func() { if err := recover(); err != nil { combinedErr := fmt.Errorf("%s\n%s", err, log.Stack(2)) @@ -42,9 +42,6 @@ func SendCloudbrainStartedMsg(operateType JobOperateType, cloudbrain models.Clou return nil } - if date.IsZero() { - date = time.Now() - } openId := models.GetUserWechatOpenId(cloudbrain.UserID) if openId == "" { return errors.New("Wechat openId not exist") @@ -53,7 +50,7 @@ func SendCloudbrainStartedMsg(operateType JobOperateType, cloudbrain models.Clou First: TemplateValue{Value: getCloudbrainTemplateTitle(operateType)}, Keyword1: TemplateValue{Value: cloudbrain.DisplayJobName}, Keyword2: TemplateValue{Value: getJobTypeDisplayName(cloudbrain.JobType)}, - Keyword3: TemplateValue{Value: date.Format("2006-01-02 15:04:05")}, + Keyword3: TemplateValue{Value: time.Unix(int64(cloudbrain.CreatedUnix), 0).Format("2006-01-02 15:04:05")}, Remark: TemplateValue{Value: getCloudbrainTemplateRemark(operateType)}, } req := TemplateMsgRequest{ diff --git a/modules/notification/wechat/wechat.go b/modules/notification/wechat/wechat.go index c995d9433..c20be8e9b 100644 --- a/modules/notification/wechat/wechat.go +++ b/modules/notification/wechat/wechat.go @@ -8,7 +8,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/auth/wechat" "code.gitea.io/gitea/modules/notification/base" - "time" + "code.gitea.io/gitea/modules/setting" ) type wechatNotifier struct { @@ -31,8 +31,14 @@ func (*wechatNotifier) NotifyChangeCloudbrainStatus(cloudbrain *models.Cloudbrai } switch operateType { case wechat.JobOperateTypeStart: - if cloudbrain.JobType == string(models.JobTypeDebug) { - go wechat.SendCloudbrainStartedMsg(operateType, *cloudbrain, time.Unix(int64(cloudbrain.StartTime), 0)) + if len(setting.CloudbrainStartedNotifyList) == 0 { + return + } + for _, v := range setting.CloudbrainStartedNotifyList { + if v == cloudbrain.JobType { + go wechat.SendCloudbrainStartedMsg(operateType, *cloudbrain) + return + } } } } diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 35789c18b..609832e7e 100755 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -584,6 +584,7 @@ var ( //wechat template msg config CloudbrainStartedTemplateId string + CloudbrainStartedNotifyList []string //nginx proxy PROXYURL string @@ -1444,6 +1445,7 @@ func NewContext() { TreePathOfAutoMsgReply = sec.Key("AUTO_REPLY_TREE_PATH").MustString("wechat/auto_reply.json") TreePathOfSubscribe = sec.Key("SUBSCRIBE_TREE_PATH").MustString("wechat/subscribe_reply.json") CloudbrainStartedTemplateId = sec.Key("CLOUDBRAIN_STARTED_TEMPLATE_ID").MustString("") + CloudbrainStartedNotifyList = strings.Split(sec.Key("CLOUDBRAIN_STARTED_NOTIFY_LIST").MustString("DEBUG"), ",") SetRadarMapConfig() From 17b5416cbb3b24546db36196b41098bc0c5ae003 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Thu, 21 Jul 2022 17:32:35 +0800 Subject: [PATCH 26/49] #2479 update --- modules/setting/setting.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 609832e7e..f63088091 100755 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -1436,7 +1436,7 @@ func NewContext() { WechatApiHost = sec.Key("HOST").MustString("https://api.weixin.qq.com") WechatApiTimeoutSeconds = sec.Key("TIMEOUT_SECONDS").MustInt(3) WechatAppId = sec.Key("APP_ID").MustString("wxba77b915a305a57d") - WechatAppSecret = sec.Key("APP_SECRET").MustString("e48e13f315adc32749ddc7057585f198") + WechatAppSecret = sec.Key("APP_SECRET").MustString("") WechatQRCodeExpireSeconds = sec.Key("QR_CODE_EXPIRE_SECONDS").MustInt(120) WechatAuthSwitch = sec.Key("AUTH_SWITCH").MustBool(true) UserNameOfWechatReply = sec.Key("AUTO_REPLY_USER_NAME").MustString("OpenIOSSG") From cf09a72b8344d6a47be49218a0d3e3b5a91b91b8 Mon Sep 17 00:00:00 2001 From: liuzx Date: Thu, 21 Jul 2022 18:02:00 +0800 Subject: [PATCH 27/49] updata --- routers/repo/cloudbrain.go | 1 + 1 file changed, 1 insertion(+) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 58087a4f6..9f985e269 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -652,6 +652,7 @@ func CloudBrainInferenceJobCreate(ctx *context.Context, form auth.CreateCloudBra } if !jobNamePattern.MatchString(displayJobName) { + cloudBrainInferenceJobErrorPrepare(ctx, form) ctx.RenderWithErr(ctx.Tr("repo.cloudbrain_jobname_err"), tpl, &form) return } From ecce77575235be3124410408febd725eab49f643 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Thu, 21 Jul 2022 19:07:16 +0800 Subject: [PATCH 28/49] fix issue --- templates/repo/cloudbrain/inference/new.tmpl | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/templates/repo/cloudbrain/inference/new.tmpl b/templates/repo/cloudbrain/inference/new.tmpl index cfdbc6e75..2dbb175bd 100644 --- a/templates/repo/cloudbrain/inference/new.tmpl +++ b/templates/repo/cloudbrain/inference/new.tmpl @@ -229,7 +229,22 @@ {{.i18n.Tr "repo.modelarts.train_job.add_run_parameter"}}
- {{.params}} + {{if ne 0 (len .params)}} + {{range $k ,$v := .params}} +
+
+ +
+
+ +
+ + + + +
+ {{end}} + {{end}}
From 88cee1d1d19642d3c7d2b2d7aa64752569ecc575 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Fri, 22 Jul 2022 09:11:15 +0800 Subject: [PATCH 29/49] #2479 update --- modules/auth/wechat/template.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/auth/wechat/template.go b/modules/auth/wechat/template.go index 0620aa7b9..6c19651a6 100644 --- a/modules/auth/wechat/template.go +++ b/modules/auth/wechat/template.go @@ -94,7 +94,7 @@ func getCloudbrainTemplateUrl(cloudbrain models.Cloudbrain, repo *models.Reposit if cloudbrain.Type == models.TypeCloudBrainOne { url += "/cloudbrain/train-job/" + fmt.Sprint(cloudbrain.JobID) } else if cloudbrain.Type == models.TypeCloudBrainTwo { - url += "/modelarts/train-job" + fmt.Sprint(cloudbrain.JobID) + url += "/modelarts/train-job/" + fmt.Sprint(cloudbrain.JobID) } else if cloudbrain.Type == models.TypeC2Net { url += "/grampus/train-job/" + fmt.Sprint(cloudbrain.JobID) } From bf813e8c6be531e2b53fc5f9e8117faf26467294 Mon Sep 17 00:00:00 2001 From: chenshihai Date: Fri, 22 Jul 2022 09:13:56 +0800 Subject: [PATCH 30/49] update kanban entry menu --- templates/base/head_navbar.tmpl | 6 ++++-- templates/base/head_navbar_fluid.tmpl | 6 ++++-- templates/base/head_navbar_home.tmpl | 6 ++++-- templates/base/head_navbar_pro.tmpl | 6 ++++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/templates/base/head_navbar.tmpl b/templates/base/head_navbar.tmpl index 51761a7e5..8dcca349c 100755 --- a/templates/base/head_navbar.tmpl +++ b/templates/base/head_navbar.tmpl @@ -42,7 +42,8 @@
{{.i18n.Tr "explore.organizations"}} {{.i18n.Tr "explore.images"}} {{if .IsOperator}} - {{.i18n.Tr "explore.data_analysis"}} + {{/* {{.i18n.Tr "explore.data_analysis"}} */}} + {{.i18n.Tr "explore.data_analysis"}} {{end}} {{.i18n.Tr "custom.head.openi.repo"}} @@ -73,7 +74,8 @@ {{.i18n.Tr "explore.organizations"}} {{.i18n.Tr "explore.images"}} {{if .IsOperator}} - {{.i18n.Tr "explore.data_analysis"}} + {{/* {{.i18n.Tr "explore.data_analysis"}} */}} + {{.i18n.Tr "explore.data_analysis"}} {{end}} {{.i18n.Tr "custom.head.openi.repo"}} diff --git a/templates/base/head_navbar_fluid.tmpl b/templates/base/head_navbar_fluid.tmpl index 6baeced54..263e5333a 100644 --- a/templates/base/head_navbar_fluid.tmpl +++ b/templates/base/head_navbar_fluid.tmpl @@ -41,7 +41,8 @@ {{.i18n.Tr "explore.organizations"}} {{.i18n.Tr "explore.images"}} {{if .IsOperator}} - {{.i18n.Tr "explore.data_analysis"}} + {{/* {{.i18n.Tr "explore.data_analysis"}} */}} + {{.i18n.Tr "explore.data_analysis"}} {{end}} {{.i18n.Tr "custom.head.openi.repo"}} @@ -71,7 +72,8 @@ {{.i18n.Tr "explore.organizations"}} {{.i18n.Tr "explore.images"}} {{if .IsOperator}} - {{.i18n.Tr "explore.data_analysis"}} + {{/* {{.i18n.Tr "explore.data_analysis"}} */}} + {{.i18n.Tr "explore.data_analysis"}} {{end}} {{.i18n.Tr "custom.head.openi.repo"}} diff --git a/templates/base/head_navbar_home.tmpl b/templates/base/head_navbar_home.tmpl index c9ea13b8a..fb5868dce 100644 --- a/templates/base/head_navbar_home.tmpl +++ b/templates/base/head_navbar_home.tmpl @@ -33,7 +33,8 @@ {{.i18n.Tr "explore.organizations"}} {{.i18n.Tr "explore.images"}} {{if .IsOperator}} - {{.i18n.Tr "explore.data_analysis"}} + {{/* {{.i18n.Tr "explore.data_analysis"}} */}} + {{.i18n.Tr "explore.data_analysis"}} {{end}} {{.i18n.Tr "custom.head.openi.repo"}} @@ -64,7 +65,8 @@ {{.i18n.Tr "explore.organizations"}} {{.i18n.Tr "explore.images"}} {{if .IsOperator}} - {{.i18n.Tr "explore.data_analysis"}} + {{/* {{.i18n.Tr "explore.data_analysis"}} */}} + {{.i18n.Tr "explore.data_analysis"}} {{end}} {{.i18n.Tr "custom.head.openi.repo"}} diff --git a/templates/base/head_navbar_pro.tmpl b/templates/base/head_navbar_pro.tmpl index e744508f0..340f50f6b 100644 --- a/templates/base/head_navbar_pro.tmpl +++ b/templates/base/head_navbar_pro.tmpl @@ -43,7 +43,8 @@ {{.i18n.Tr "explore.organizations"}} {{.i18n.Tr "explore.images"}} {{if .IsOperator}} - {{.i18n.Tr "explore.data_analysis"}} + {{/* {{.i18n.Tr "explore.data_analysis"}} */}} + {{.i18n.Tr "explore.data_analysis"}} {{end}} {{.i18n.Tr "custom.head.openi.repo"}} @@ -74,7 +75,8 @@ {{.i18n.Tr "explore.organizations"}} {{.i18n.Tr "explore.images"}} {{if .IsOperator}} - {{.i18n.Tr "explore.data_analysis"}} + {{/* {{.i18n.Tr "explore.data_analysis"}} */}} + {{.i18n.Tr "explore.data_analysis"}} {{end}} {{.i18n.Tr "custom.head.openi.repo"}} From cefdac00b17b4bc78b960f0351ac19b3e52d844a Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Fri, 22 Jul 2022 09:16:01 +0800 Subject: [PATCH 31/49] #2479 update --- modules/notification/wechat/wechat.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/notification/wechat/wechat.go b/modules/notification/wechat/wechat.go index c20be8e9b..f77bfe741 100644 --- a/modules/notification/wechat/wechat.go +++ b/modules/notification/wechat/wechat.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -package mail +package wechat import ( "code.gitea.io/gitea/models" From fc1164df88b5c2d90956c30673163715b3bfba83 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Fri, 22 Jul 2022 09:30:54 +0800 Subject: [PATCH 32/49] #2477 remove /panel path --- routers/kanban/kanban.go | 24 ------------------------ routers/routes/routes.go | 2 -- 2 files changed, 26 deletions(-) delete mode 100644 routers/kanban/kanban.go diff --git a/routers/kanban/kanban.go b/routers/kanban/kanban.go deleted file mode 100644 index d6bb743bb..000000000 --- a/routers/kanban/kanban.go +++ /dev/null @@ -1,24 +0,0 @@ -package kanban - -import ( - "code.gitea.io/gitea/modules/base" - "code.gitea.io/gitea/modules/context" - "code.gitea.io/gitea/modules/setting" - "net/http" - "os" - "path" - "time" -) - -func Index(ctx *context.Context) { - file := path.Join(setting.StaticRootPath, "public/kanban/index.html") - name := "index.html" - f, err := os.Open(file) - if err != nil { - ctx.HTML(http.StatusNotFound, base.TplName("status/404")) - return - } - defer f.Close() - ctx.Resp.Header().Set("Content-Type", "text/html") - http.ServeContent(ctx.Resp, ctx.Req.Request, name, time.Now(), f) -} diff --git a/routers/routes/routes.go b/routers/routes/routes.go index e4481d3c1..35a26f585 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -6,7 +6,6 @@ package routes import ( "bytes" - "code.gitea.io/gitea/routers/kanban" "encoding/gob" "net/http" "path" @@ -328,7 +327,6 @@ func RegisterRoutes(m *macaron.Macaron) { }) m.Get("/", routers.Home) m.Get("/dashboard", routers.Dashboard) - m.Get("/panel", kanban.Index) go routers.SocketManager.Run() m.Get("/action/notification", routers.ActionNotification) m.Get("/recommend/home", routers.RecommendHomeInfo) From ae3b50ad2ce597cfa156fd53f913158a32a86ca0 Mon Sep 17 00:00:00 2001 From: chenshihai Date: Fri, 22 Jul 2022 10:17:32 +0800 Subject: [PATCH 33/49] update kanban entry menu --- templates/base/head_navbar.tmpl | 4 ++-- templates/base/head_navbar_fluid.tmpl | 4 ++-- templates/base/head_navbar_home.tmpl | 4 ++-- templates/base/head_navbar_pro.tmpl | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/templates/base/head_navbar.tmpl b/templates/base/head_navbar.tmpl index 8dcca349c..a5a898ad0 100755 --- a/templates/base/head_navbar.tmpl +++ b/templates/base/head_navbar.tmpl @@ -43,7 +43,7 @@ {{.i18n.Tr "explore.images"}} {{if .IsOperator}} {{/* {{.i18n.Tr "explore.data_analysis"}} */}} - {{.i18n.Tr "explore.data_analysis"}} + {{.i18n.Tr "explore.data_analysis"}} {{end}} {{.i18n.Tr "custom.head.openi.repo"}} @@ -75,7 +75,7 @@ {{.i18n.Tr "explore.images"}} {{if .IsOperator}} {{/* {{.i18n.Tr "explore.data_analysis"}} */}} - {{.i18n.Tr "explore.data_analysis"}} + {{.i18n.Tr "explore.data_analysis"}} {{end}} {{.i18n.Tr "custom.head.openi.repo"}} diff --git a/templates/base/head_navbar_fluid.tmpl b/templates/base/head_navbar_fluid.tmpl index 263e5333a..84781db11 100644 --- a/templates/base/head_navbar_fluid.tmpl +++ b/templates/base/head_navbar_fluid.tmpl @@ -42,7 +42,7 @@ {{.i18n.Tr "explore.images"}} {{if .IsOperator}} {{/* {{.i18n.Tr "explore.data_analysis"}} */}} - {{.i18n.Tr "explore.data_analysis"}} + {{.i18n.Tr "explore.data_analysis"}} {{end}} {{.i18n.Tr "custom.head.openi.repo"}} @@ -73,7 +73,7 @@ {{.i18n.Tr "explore.images"}} {{if .IsOperator}} {{/* {{.i18n.Tr "explore.data_analysis"}} */}} - {{.i18n.Tr "explore.data_analysis"}} + {{.i18n.Tr "explore.data_analysis"}} {{end}} {{.i18n.Tr "custom.head.openi.repo"}} diff --git a/templates/base/head_navbar_home.tmpl b/templates/base/head_navbar_home.tmpl index fb5868dce..64e04b4c3 100644 --- a/templates/base/head_navbar_home.tmpl +++ b/templates/base/head_navbar_home.tmpl @@ -34,7 +34,7 @@ {{.i18n.Tr "explore.images"}} {{if .IsOperator}} {{/* {{.i18n.Tr "explore.data_analysis"}} */}} - {{.i18n.Tr "explore.data_analysis"}} + {{.i18n.Tr "explore.data_analysis"}} {{end}} {{.i18n.Tr "custom.head.openi.repo"}} @@ -66,7 +66,7 @@ {{.i18n.Tr "explore.images"}} {{if .IsOperator}} {{/* {{.i18n.Tr "explore.data_analysis"}} */}} - {{.i18n.Tr "explore.data_analysis"}} + {{.i18n.Tr "explore.data_analysis"}} {{end}} {{.i18n.Tr "custom.head.openi.repo"}} diff --git a/templates/base/head_navbar_pro.tmpl b/templates/base/head_navbar_pro.tmpl index 340f50f6b..e9f662bbe 100644 --- a/templates/base/head_navbar_pro.tmpl +++ b/templates/base/head_navbar_pro.tmpl @@ -44,7 +44,7 @@ {{.i18n.Tr "explore.images"}} {{if .IsOperator}} {{/* {{.i18n.Tr "explore.data_analysis"}} */}} - {{.i18n.Tr "explore.data_analysis"}} + {{.i18n.Tr "explore.data_analysis"}} {{end}} {{.i18n.Tr "custom.head.openi.repo"}} @@ -76,7 +76,7 @@ {{.i18n.Tr "explore.images"}} {{if .IsOperator}} {{/* {{.i18n.Tr "explore.data_analysis"}} */}} - {{.i18n.Tr "explore.data_analysis"}} + {{.i18n.Tr "explore.data_analysis"}} {{end}} {{.i18n.Tr "custom.head.openi.repo"}} From 8a35e507fe987f920bdbf07f3a4a29b36a68f5b6 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Fri, 22 Jul 2022 10:47:40 +0800 Subject: [PATCH 34/49] fix issue --- templates/repo/cloudbrain/inference/new.tmpl | 46 +++++++++----- templates/repo/modelarts/inferencejob/new.tmpl | 87 +++++++++++++++++--------- 2 files changed, 88 insertions(+), 45 deletions(-) diff --git a/templates/repo/cloudbrain/inference/new.tmpl b/templates/repo/cloudbrain/inference/new.tmpl index 2dbb175bd..fedd9fa3c 100644 --- a/templates/repo/cloudbrain/inference/new.tmpl +++ b/templates/repo/cloudbrain/inference/new.tmpl @@ -59,16 +59,13 @@ {{.CsrfTokenHtml}} - {{if $.model_version}} - - {{else}} - {{end}} - {{if $.label_names}} - - {{else}} - - {{end}} + + + + + +

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

@@ -298,6 +295,7 @@