From 2ead5ccbb69da4b811596909cce3036f1b1caa83 Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Fri, 18 Mar 2022 18:55:51 +0800 Subject: [PATCH] opt --- modules/cloudbrain/cloudbrain.go | 18 +- routers/repo/cloudbrain.go | 24 +- routers/routes/routes.go | 2 +- templates/repo/cloudbrain/trainjob/show.tmpl | 539 ++----------------- 4 files changed, 67 insertions(+), 516 deletions(-) diff --git a/modules/cloudbrain/cloudbrain.go b/modules/cloudbrain/cloudbrain.go index b843bb497..55044e704 100755 --- a/modules/cloudbrain/cloudbrain.go +++ b/modules/cloudbrain/cloudbrain.go @@ -157,21 +157,21 @@ func GenerateTask(ctx *context.Context, displayJobName, jobName, image, command, var resourceSpec *models.ResourceSpec var versionCount int - if jobType == string(models.JobTypeDebug) { - if ResourceSpecs == nil { - json.Unmarshal([]byte(setting.ResourceSpecs), &ResourceSpecs) + if jobType == string(models.JobTypeTrain) { + versionCount = 1 + if TrainResourceSpecs == nil { + json.Unmarshal([]byte(setting.TrainResourceSpecs), &TrainResourceSpecs) } - for _, spec := range ResourceSpecs.ResourceSpec { + for _, spec := range TrainResourceSpecs.ResourceSpec { if resourceSpecId == spec.Id { resourceSpec = spec } } - } else if jobType == string(models.JobTypeTrain) { - versionCount = 1 - if TrainResourceSpecs == nil { - json.Unmarshal([]byte(setting.TrainResourceSpecs), &TrainResourceSpecs) + } else { + if ResourceSpecs == nil { + json.Unmarshal([]byte(setting.ResourceSpecs), &ResourceSpecs) } - for _, spec := range TrainResourceSpecs.ResourceSpec { + for _, spec := range ResourceSpecs.ResourceSpec { if resourceSpecId == spec.Id { resourceSpec = spec } diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 21f5a0fce..4aa186a91 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -36,7 +36,8 @@ const ( tplCloudBrainBenchmarkNew base.TplName = "repo/cloudbrain/benchmark/new" tplCloudBrainBenchmarkShow base.TplName = "repo/cloudbrain/benchmark/show" - tplCloudBrainTrainJobNew base.TplName = "repo/cloudbrain/trainjob/new" + tplCloudBrainTrainJobNew base.TplName = "repo/cloudbrain/trainjob/new" + tplCloudBrainTrainJobShow base.TplName = "repo/cloudbrain/trainjob/show" ) var ( @@ -383,18 +384,29 @@ func CloudBrainBenchMarkShow(ctx *context.Context) { return } } - cloudBrainShow(ctx, tplCloudBrainBenchmarkShow) + cloudBrainShow(ctx, tplCloudBrainBenchmarkShow, models.JobTypeBenchmark) } func CloudBrainShow(ctx *context.Context) { - cloudBrainShow(ctx, tplCloudBrainShow) + cloudBrainShow(ctx, tplCloudBrainShow, models.JobTypeDebug) } -func cloudBrainShow(ctx *context.Context, tpName base.TplName) { +func CloudBrainTrainJobShow(ctx *context.Context) { + cloudBrainShow(ctx, tplCloudBrainTrainJobShow, models.JobTypeTrain) +} + +func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.JobType) { ctx.Data["PageIsCloudBrain"] = true - var ID = ctx.Params(":id") debugListType := ctx.Query("debugListType") - task, err := models.GetCloudbrainByID(ID) + + var task *models.Cloudbrain + var err error + if jobType == models.JobTypeTrain { + task, err = models.GetCloudbrainByJobID(ctx.Params(":jobid")) + } else { + task, err = models.GetCloudbrainByID(ctx.Params(":id")) + } + if err != nil { log.Info("error:" + err.Error()) ctx.Data["error"] = err.Error() diff --git a/routers/routes/routes.go b/routers/routes/routes.go index e8b42796b..6ce28600b 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -1020,7 +1020,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Group("/train-job", func() { m.Group("/:jobid", func() { //todo: jobid to id - m.Get("", reqRepoCloudBrainReader, repo.TrainJobShow) + m.Get("", reqRepoCloudBrainReader, repo.CloudBrainTrainJobShow) m.Post("/stop", cloudbrain.AdminOrOwnerOrJobCreaterRightForTrain, repo.CloudBrainStop) m.Post("/del", cloudbrain.AdminOrOwnerOrJobCreaterRightForTrain, repo.CloudBrainTrainJobDel) m.Get("/models", reqRepoCloudBrainReader, repo.CloudBrainShowModels) diff --git a/templates/repo/cloudbrain/trainjob/show.tmpl b/templates/repo/cloudbrain/trainjob/show.tmpl index bb6039c97..10a3d544b 100755 --- a/templates/repo/cloudbrain/trainjob/show.tmpl +++ b/templates/repo/cloudbrain/trainjob/show.tmpl @@ -179,8 +179,8 @@ td, th { {{.i18n.Tr "repo.cloudbrain"}}
| - {{$.i18n.Tr "repo.modelarts.train_job.AI_driver"}} - | -
-
- {{.EngineName}}
-
- |
-
| - {{$.i18n.Tr "repo.modelarts.code_version"}} + {{$.i18n.Tr "repo.modelarts.train_job.description"}} | - +
-
- {{.BranchName}}
+
+ {{.Description}}
|
| - {{$.i18n.Tr "repo.modelarts.train_job.start_file"}} + {{$.i18n.Tr "repo.modelarts.train_job.standard"}} |
- {{.BootFile}}
-
- |
-
| - {{$.i18n.Tr "repo.modelarts.train_job.train_dataset"}} - | - -
-
- {{.DatasetName}}
+ {{$.resource_spec}}
|
| - {{$.i18n.Tr "repo.modelarts.train_job.run_parameter"}} - | - -
-
- {{.Parameters}}
-
- |
-
| - {{$.i18n.Tr "repo.modelarts.train_job.description"}} + 创建者 | - +
-
- {{.Cloudbrain.Description}}
+
+ {{.User.Name}}
|