From dc5da68d639ad9cb4b681c67ea191029ba16daf9 Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Fri, 4 Mar 2022 11:52:49 +0800 Subject: [PATCH] benchmark opt --- models/cloudbrain.go | 13 +++++++----- routers/repo/cloudbrain.go | 20 ++++++++++++++++++- templates/explore/repo_orgtop.tmpl | 4 ++-- .../repo/cloudbrain/benchmark/index.tmpl | 2 +- 4 files changed, 30 insertions(+), 9 deletions(-) mode change 100644 => 100755 templates/repo/cloudbrain/benchmark/index.tmpl diff --git a/models/cloudbrain.go b/models/cloudbrain.go index 8bb3357ae..b2eed744d 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -144,8 +144,10 @@ type Cloudbrain struct { CkptName string //权重文件名称 ResultUrl string //推理结果的obs路径 - User *User `xorm:"-"` - Repo *Repository `xorm:"-"` + User *User `xorm:"-"` + Repo *Repository `xorm:"-"` + BenchmarkTypeName string `xorm:"-"` + BenchmarkTypeRankLink string `xorm:"-"` } type CloudbrainInfo struct { @@ -407,9 +409,10 @@ type BenchmarkTypes struct { } type BenchmarkType struct { - Id int `json:"id"` - First string `json:"first"` //一级算法类型名称 - Second []*BenchmarkDataset `json:"second"` + Id int `json:"id"` + RankLink string `json:"rank_link"` + First string `json:"first"` //一级算法类型名称 + Second []*BenchmarkDataset `json:"second"` } type BenchmarkDataset struct { diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 4cde5d40d..6fae64bea 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -404,10 +404,11 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName) { } else { duration = int64(task.UpdatedUnix) - int64(task.CreatedUnix) } - if benchmarkTypes != nil { + if task.BenchmarkTypeID > 0 { for _, benchmarkType := range benchmarkTypes.BenchmarkType { if task.BenchmarkTypeID == benchmarkType.Id { ctx.Data["BenchmarkTypeName"] = benchmarkType.First + ctx.Data["RankLink"] = benchmarkType.RankLink for _, benchmarkChildType := range benchmarkType.Second { if task.BenchmarkChildTypeID == benchmarkChildType.Id { ctx.Data["BenchmarkChildTypeName"] = benchmarkChildType.Value @@ -1051,6 +1052,13 @@ func CloudBrainBenchmarkIndex(ctx *context.Context) { return } + if benchmarkTypes == nil { + if err := json.Unmarshal([]byte(setting.BenchmarkTypes), &benchmarkTypes); err != nil { + ctx.ServerError("Get BenchmarkTypes faild:", err) + return + } + } + for i, task := range ciTasks { ciTasks[i].CanDel = cloudbrain.CanDeleteJob(ctx, &task.Cloudbrain) ciTasks[i].Cloudbrain.ComputeResource = task.ComputeResource @@ -1061,6 +1069,16 @@ func CloudBrainBenchmarkIndex(ctx *context.Context) { duration = int64(task.Cloudbrain.UpdatedUnix) - int64(task.Cloudbrain.CreatedUnix) } ciTasks[i].TrainJobDuration = util.AddZero(duration/3600000) + ":" + util.AddZero(duration%3600000/60000) + ":" + util.AddZero(duration%60000/1000) + ciTasks[i].BenchmarkTypeName = "" + if task.BenchmarkTypeID > 0 { + for _, benchmarkType := range benchmarkTypes.BenchmarkType { + if task.BenchmarkTypeID == benchmarkType.Id { + ciTasks[i].BenchmarkTypeRankLink = benchmarkType.RankLink + ciTasks[i].BenchmarkTypeName = benchmarkType.First + break + } + } + } } pager := context.NewPagination(int(count), setting.UI.IssuePagingNum, page, 5) diff --git a/templates/explore/repo_orgtop.tmpl b/templates/explore/repo_orgtop.tmpl index d9c29fd54..5706a92b8 100755 --- a/templates/explore/repo_orgtop.tmpl +++ b/templates/explore/repo_orgtop.tmpl @@ -53,8 +53,8 @@
- - 京东 + + 京东智能供应链开源工具
diff --git a/templates/repo/cloudbrain/benchmark/index.tmpl b/templates/repo/cloudbrain/benchmark/index.tmpl old mode 100644 new mode 100755 index e2eea57e3..2fc12dc40 --- a/templates/repo/cloudbrain/benchmark/index.tmpl +++ b/templates/repo/cloudbrain/benchmark/index.tmpl @@ -113,7 +113,7 @@
- + {{.BenchmarkTypeName}}