From cab1e2cb57dcfc44ead4f3301f80e920f31471b1 Mon Sep 17 00:00:00 2001
From: yuyuanshifu <747342561@qq.com>
Date: Fri, 5 Feb 2021 10:40:59 +0800
Subject: [PATCH] show notebool
---
models/cloudbrain.go | 4 ++
routers/repo/modelarts.go | 11 +++-
templates/repo/modelarts/show.tmpl | 86 ++++++++++++++++++------------
3 files changed, 66 insertions(+), 35 deletions(-)
diff --git a/models/cloudbrain.go b/models/cloudbrain.go
index 20e3ac6d1..34113fed6 100755
--- a/models/cloudbrain.go
+++ b/models/cloudbrain.go
@@ -353,7 +353,9 @@ type GetNotebookResult struct {
Description string `json:"description"`
Status string `json:"status"`
CreationTimestamp string `json:"creation_timestamp"`
+ CreateTime string
LatestUpdateTimestamp string `json:"latest_update_timestamp"`
+ LatestUpdateTime string
Profile struct {
ID string `json:"id"`
Name string `json:"name"`
@@ -376,8 +378,10 @@ type GetNotebookResult struct {
DeType string `json:"de_type"`
Status string `json:"status"`
BeginTimestamp int `json:"begin_timestamp"`//time of instance begin in queue
+ BeginTime string
RemainTime int `json:"remain_time"` //remain time of instance
EndTimestamp int `json:"end_timestamp"` //
+ EndTime string
Rank int `json:"rank"` //rank of instance in queue
} `json:"queuing_info"`
}
diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go
index 6a9e7240b..45140c674 100755
--- a/routers/repo/modelarts.go
+++ b/routers/repo/modelarts.go
@@ -3,6 +3,7 @@ package repo
import (
"code.gitea.io/gitea/modules/modelarts"
"errors"
+ "github.com/unknwon/com"
"strconv"
"time"
@@ -129,10 +130,18 @@ func ModelArtsShow(ctx *context.Context) {
ctx.RenderWithErr(err.Error(), tplModelArtsIndex, nil)
return
}
+
+ createTime, _ := com.StrTo(result.CreationTimestamp).Int64()
+ result.CreateTime = time.Unix(int64(createTime/1000), 0).Format("2006-01-02 15:04:05")
+ endTime, _ := com.StrTo(result.LatestUpdateTimestamp).Int64()
+ result.LatestUpdateTime = time.Unix(int64(endTime/1000), 0).Format("2006-01-02 15:04:05")
+ result.QueuingInfo.BeginTime = time.Unix(int64(result.QueuingInfo.BeginTimestamp/1000), 0).Format("2006-01-02 15:04:05")
+ result.QueuingInfo.EndTime = time.Unix(int64(result.QueuingInfo.EndTimestamp/1000), 0).Format("2006-01-02 15:04:05")
}
ctx.Data["task"] = task
ctx.Data["jobID"] = jobID
+ ctx.Data["result"] = result
ctx.HTML(200, tplModelArtsShow)
}
@@ -178,7 +187,7 @@ func ModelArtsStop(ctx *context.Context) {
log.Info("pre(%s), current(%s)", res.PreviousState, res.CurrentStatus)
- task.Status = string(models.JobStopped)
+ task.Status = res.CurrentStatus
err = models.UpdateJob(task)
if err != nil {
ctx.ServerError("UpdateJob failed", err)
diff --git a/templates/repo/modelarts/show.tmpl b/templates/repo/modelarts/show.tmpl
index fe4ec7ab3..3f914b56d 100755
--- a/templates/repo/modelarts/show.tmpl
+++ b/templates/repo/modelarts/show.tmpl
@@ -16,81 +16,99 @@
任务结果:
- {{with .taskRes}}
- {{range .TaskStatuses}}
+ {{with .result}}
状态 |
- {{.State}} |
+ {{.Status}} |
开始时间 |
- {{.StartTime}} |
+ {{.CreateTime}} |
- 结束时间 |
- {{.FinishedTime}} |
-
-
- ExitCode |
- {{.ExitCode}} |
-
-
- 退出信息 |
- {{.ExitDiagnostics| nl2br}} |
+ 最后更新时间 |
+ {{.LatestUpdateTime}} |
- {{end}}
{{end}}
{{with .result}}
- 硬件信息 |
+ 配置信息 |
+
+
+
+ 开发环境类型 |
+ {{.Profile.DeType}} |
+
+
+ 硬件类型 |
+ {{.Profile.FlavorType}} |
+
+
+
+
+
+
+ 机器规格详情 |
- CPU |
- {{.Resource.CPU}} |
+ 机器规格 |
+ {{.Flavor}} |
+
+
+ 规格名称 |
+ {{.FlavorDetails.Name}} |
+
+
+ 规格销售状态 |
+ {{.FlavorDetails.Status}} |
+
+
+ 排队个数 |
+ {{.FlavorDetails.QueuingNum}} |
- Memory |
- {{.Resource.Memory}} |
+ 排到队的剩余时间(秒) |
+ {{.FlavorDetails.QueueLeftTime}} |
- NvidiaComGpu |
- {{.Resource.NvidiaComGpu}} |
+ 自动停止时间(秒) |
+ {{.FlavorDetails.Duration}} |
-
+
- 调试信息 |
+ 排队信息 |
- 状态 |
- {{.Platform}} |
+ 实例状态 |
+ {{.QueuingInfo.Status}} |
- 开始时间 |
- {{.JobStatus.StartTime}} |
+ 实例排队的开始时间 |
+ {{.QueuingInfo.BeginTime}} |
- 结束时间 |
- {{.JobStatus.EndTime}} |
+ 排到队的剩余时间(秒) |
+ {{.QueuingInfo.RemainTime}} |
- ExitCode |
- {{.JobStatus.AppExitCode}} |
+ 实例排队的预计停止时间 |
+ {{.QueuingInfo.EndTime}} |
- 退出信息 |
- {{.JobStatus.AppExitDiagnostics | nl2br}} |
+ 实例在队列中的排位 |
+ {{.QueuingInfo.Rank}} |