diff --git a/modules/modelarts/modelarts.go b/modules/modelarts/modelarts.go index 538fcfbd9..b1e7b269e 100755 --- a/modules/modelarts/modelarts.go +++ b/modules/modelarts/modelarts.go @@ -280,6 +280,7 @@ func GenerateNotebook2(ctx *context.Context, displayJobName, jobName, uuid, desc RepoID: ctx.Repo.Repository.ID, JobID: jobResult.ID, JobName: jobName, + FlavorCode: flavor, DisplayJobName: displayJobName, JobType: string(models.JobTypeDebug), Type: models.TypeCloudBrainTwo, diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 73b1914e5..2848b8e19 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -346,6 +346,24 @@ func CloudBrainRestart(ctx *context.Context) { break } + var hasSameResource bool + if gpuInfos == nil { + json.Unmarshal([]byte(setting.GpuTypes), &gpuInfos) + } + for _, resourceType := range gpuInfos.GpuInfo { + if resourceType.Queue == task.GpuQueue { + hasSameResource = true + continue + } + } + + if !hasSameResource { + log.Error("has no same resource, can not restart", ctx.Data["MsgID"]) + resultCode = "-1" + errorMsg = "the job's version is too old and can not be restarted" + break + } + count, err := models.GetCloudbrainCountByUserID(ctx.User.ID, string(models.JobTypeDebug)) if err != nil { log.Error("GetCloudbrainCountByUserID failed:%v", err, ctx.Data["MsgID"]) @@ -417,6 +435,18 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo return } + if cloudbrain.ResourceSpecs == nil { + json.Unmarshal([]byte(setting.ResourceSpecs), &cloudbrain.ResourceSpecs) + } + for _, tmp := range cloudbrain.ResourceSpecs.ResourceSpec { + if tmp.Id == task.ResourceSpecId { + ctx.Data["GpuNum"] = tmp.GpuNum + ctx.Data["CpuNum"] = tmp.CpuNum + ctx.Data["MemMiB"] = tmp.MemMiB + ctx.Data["ShareMemMiB"] = tmp.ShareMemMiB + } + } + if result != nil { jobRes, _ := models.ConvertToJobResultPayload(result.Payload) jobRes.Resource.Memory = strings.ReplaceAll(jobRes.Resource.Memory, "Mi", "MB") diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index 32d9db9ce..3f835ee5d 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -2,10 +2,9 @@ package repo import ( "archive/zip" - "code.gitea.io/gitea/modules/notification" - "code.gitea.io/gitea/modules/timeutil" "encoding/json" "errors" + "fmt" "io" "io/ioutil" "net/http" @@ -16,6 +15,9 @@ import ( "time" "unicode/utf8" + "code.gitea.io/gitea/modules/notification" + "code.gitea.io/gitea/modules/timeutil" + "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/auth" "code.gitea.io/gitea/modules/base" @@ -279,11 +281,40 @@ func NotebookShow(ctx *context.Context) { if task.Uuid != "" && task.UserID == ctx.User.ID { attachment, err := models.GetAttachmentByUUID(task.Uuid) if err == nil { + task.DatasetName = attachment.Name datasetDownloadLink = attachment.S3DownloadURL() } } } - + user, err := models.GetUserByID(task.UserID) + if err == nil { + task.User = user + } + if modelarts.FlavorInfos == nil { + json.Unmarshal([]byte(setting.FlavorInfos), &modelarts.FlavorInfos) + } + if modelarts.FlavorInfos != nil { + ctx.Data["resource_spec"] = modelarts.FlavorInfos.FlavorInfo[0].Desc + for _, f := range modelarts.FlavorInfos.FlavorInfo { + if fmt.Sprint(f.Value) == task.FlavorCode { + ctx.Data["resource_spec"] = f.Desc + break + } + } + } + if task.TrainJobDuration == "" { + if task.Duration == 0 { + var duration int64 + if task.Status == string(models.JobRunning) { + duration = time.Now().Unix() - int64(task.CreatedUnix) + } else { + duration = int64(task.UpdatedUnix) - int64(task.CreatedUnix) + } + task.Duration = duration + } + task.TrainJobDuration = models.ConvertDurationToStr(task.Duration) + } + ctx.Data["duration"] = task.TrainJobDuration ctx.Data["datasetDownloadLink"] = datasetDownloadLink ctx.Data["task"] = task ctx.Data["ID"] = ID diff --git a/templates/admin/cloudbrain/list.tmpl b/templates/admin/cloudbrain/list.tmpl index 02f100e46..6fea2eef7 100755 --- a/templates/admin/cloudbrain/list.tmpl +++ b/templates/admin/cloudbrain/list.tmpl @@ -155,7 +155,7 @@ {{else}} - + {{$.i18n.Tr "repo.stop"}} {{end}} diff --git a/templates/repo/cloudbrain/show.tmpl b/templates/repo/cloudbrain/show.tmpl index 895a5c14f..781c66d67 100755 --- a/templates/repo/cloudbrain/show.tmpl +++ b/templates/repo/cloudbrain/show.tmpl @@ -330,12 +330,12 @@ td, th { - {{$.i18n.Tr "repo.cloudbrain.platform"}} + {{$.i18n.Tr "cloudbrain.gpu_type"}}
- {{$.result.Platform}} + {{$.resource_type}}
@@ -357,7 +357,7 @@ td, th {
- {{if not (eq .StartTime 0)}} + {{if not (eq .EndTime 0)}} {{TimeSinceUnix1 .EndTime}} {{else}} -- @@ -386,7 +386,7 @@ td, th {
- {{$.resource_spec}} + {{$.i18n.Tr "cloudbrain.gpu_num"}}:{{$.GpuNum}},{{$.i18n.Tr "cloudbrain.cpu_num"}}:{{$.CpuNum}},{{$.i18n.Tr "cloudbrain.memory"}}(MB):{{$.MemMiB}},{{$.i18n.Tr "cloudbrain.shared_memory"}}(MB):{{$.ShareMemMiB}}
diff --git a/templates/repo/modelarts/notebook/show.tmpl b/templates/repo/modelarts/notebook/show.tmpl index 59474ee49..684ad99a1 100755 --- a/templates/repo/modelarts/notebook/show.tmpl +++ b/templates/repo/modelarts/notebook/show.tmpl @@ -1,68 +1,439 @@ {{template "base/head" .}} + +
+
+
+
+
+
+
+
+
{{template "repo/header" .}} -
-
- {{template "base/alert" .}} - +

+ +
/
+ {{with .task}} +
{{.DisplayJobName}}
+ {{end}} +

-
-
- {{with .task}} -

任务名称: {{.DisplayJobName}}

- {{end}} -
-
-

任务详情:

- {{with .result}} - - - - - - - - - - - - - - - - - - - - - - - - - - - -
状态 {{.Status}}
描述 {{$.task.Description}}
镜像名称 {{$.task.Image}}
数据集下载地址 {{$.datasetDownloadLink}}
开始时间 {{.CreateTime}}
最后更新时间 {{.LatestUpdateTime}}
- {{end}} -
- + {{with .task}} +
+
+
+
+ + + +
+ + {{if not (eq .StartTime 0)}} + {{TimeSinceUnix1 .StartTime}} + {{else}} + {{TimeSinceUnix1 .CreatedUnix}} + {{end}} + + + {{$.i18n.Tr "repo.modelarts.status"}}: + {{.Status}} + + {{$.i18n.Tr "repo.modelarts.train_job.dura_time"}}: + {{$.duration}} + +
+
+
+
+
+
+
+
+ +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ {{$.i18n.Tr "repo.cloudbrain_task"}} + +
+ {{.DisplayJobName}} +
+
+ {{$.i18n.Tr "repo.modelarts.status"}} + +
+ {{.Status}} +
+
+ {{$.i18n.Tr "repo.modelarts.train_job.start_time"}} + +
+ + {{if not (eq .StartTime 0)}} + {{TimeSinceUnix1 .StartTime}} + {{else}} + {{TimeSinceUnix1 .CreatedUnix}} + {{end}} + +
+
+ {{$.i18n.Tr "admin.auths.updated"}} + +
+ + {{TimeSinceUnix1 .UpdatedUnix}} + +
+
+ {{$.i18n.Tr "repo.modelarts.train_job.dura_time"}} + +
+ {{$.duration}} +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ {{$.i18n.Tr "cloudbrain.mirror"}} + +
+ {{.Image}} +
+
+ {{$.i18n.Tr "repo.modelarts.train_job.dataset"}} + +
+ {{.DatasetName}} +
+
+ {{$.i18n.Tr "repo.modelarts.train_job.standard"}} + +
+ {{$.resource_spec}} +
+
+ {{$.i18n.Tr "repo.cloudbrain_creator"}} + +
+ {{.User.Name}} +
+
+ {{$.i18n.Tr "cloudbrain.description"}} + +
+ {{.Description}} +
+
+
+
+ +
+ +
+
+ + +
+
+ {{end}} + {{template "base/paginate" .}} +
+ +
+
-
+ +
{{template "base/footer" .}} + +