diff --git a/models/cloudbrain.go b/models/cloudbrain.go
index 20e3ac6d1..23fa0a069 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"`
}
@@ -437,6 +441,10 @@ type NotebookActionResult struct {
PreviousState string `json:"previous_state"`
}
+type NotebookDelResult struct {
+ InstanceID string `json:"instance_id"`
+}
+
func Cloudbrains(opts *CloudbrainsOptions) ([]*Cloudbrain, int64, error) {
sess := x.NewSession()
defer sess.Close()
diff --git a/modules/modelarts/resty.go b/modules/modelarts/resty.go
index 93ddfb75d..7c50547d6 100755
--- a/modules/modelarts/resty.go
+++ b/modules/modelarts/resty.go
@@ -205,3 +205,42 @@ sendjob:
return &result, nil
}
+
+func DelJob(jobID string) (*models.NotebookDelResult, error) {
+ checkSetting()
+ client := getRestyClient()
+ var result models.NotebookDelResult
+
+ retry := 0
+
+sendjob:
+ res, err := client.R().
+ SetHeader("Content-Type", "application/json").
+ SetAuthToken(TOKEN).
+ SetResult(&result).
+ Delete(HOST + "/v1/" + setting.ProjectID + urlNotebook + "/" + jobID)
+
+ if err != nil {
+ return &result, fmt.Errorf("resty DelJob: %v", err)
+ }
+
+ if res.StatusCode() == http.StatusUnauthorized && retry < 1 {
+ retry++
+ _ = getToken()
+ goto sendjob
+ }
+
+ var response models.NotebookResult
+ err = json.Unmarshal(res.Body(), &response)
+ if err != nil {
+ log.Error("json.Unmarshal failed: %s", err.Error())
+ return &result, fmt.Errorf("son.Unmarshal failed: %s", err.Error())
+ }
+
+ if len(response.ErrorCode) != 0 {
+ log.Error("DelJob failed(%s): %s", response.ErrorCode, response.ErrorMsg)
+ return &result, fmt.Errorf("DelJob failed(%s): %s", response.ErrorCode, response.ErrorMsg)
+ }
+
+ return &result, nil
+}
diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go
index 6a9e7240b..cf12eaece 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)
}
@@ -176,9 +185,7 @@ func ModelArtsStop(ctx *context.Context) {
return
}
- 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)
@@ -202,6 +209,13 @@ func ModelArtsDel(ctx *context.Context) {
return
}
+ _, err = modelarts.DelJob(jobID)
+ if err != nil {
+ log.Error("DelJob(%s) failed:%v", task.JobName, err.Error())
+ ctx.ServerError("DelJob failed", err)
+ return
+ }
+
err = models.DeleteJob(task)
if err != nil {
ctx.ServerError("DeleteJob failed", err)
diff --git a/templates/explore/dataset_list.tmpl b/templates/explore/dataset_list.tmpl
index f7caf4f36..9200274a9 100755
--- a/templates/explore/dataset_list.tmpl
+++ b/templates/explore/dataset_list.tmpl
@@ -31,9 +31,7 @@
{{svg "octicon-tasklist" 16}} {{$.i18n.Tr (printf "dataset.task.%s" .Task)}}
{{svg "octicon-tag" 16}}{{$.i18n.Tr (printf "dataset.category.%s" .Category)}}
- {{if ne .DownloadTimes 0}}
{{svg "octicon-flame" 16}} {{.DownloadTimes}}
- {{end}}
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}} |