diff --git a/models/attachment.go b/models/attachment.go index a3fc6fa01..7c95a73dd 100755 --- a/models/attachment.go +++ b/models/attachment.go @@ -51,6 +51,7 @@ type Attachment struct { FileChunk *FileChunk `xorm:"-"` CanDel bool `xorm:"-"` Uploader *User `xorm:"-"` + Md5 string `xorm:"-"` } type AttachmentUsername struct { diff --git a/models/dataset.go b/models/dataset.go index 7cac6c468..95800100c 100755 --- a/models/dataset.go +++ b/models/dataset.go @@ -1,6 +1,7 @@ package models import ( + "code.gitea.io/gitea/modules/log" "errors" "fmt" "sort" @@ -62,19 +63,20 @@ func (datasets DatasetList) loadAttributes(e Engine) error { } set := make(map[int64]struct{}) + userIdSet := make(map[int64]struct{}) datasetIDs := make([]int64, len(datasets)) for i := range datasets { - set[datasets[i].UserID] = struct{}{} + userIdSet[datasets[i].UserID] = struct{}{} set[datasets[i].RepoID] = struct{}{} datasetIDs[i] = datasets[i].ID } // Load owners. - users := make(map[int64]*User, len(set)) + users := make(map[int64]*User, len(userIdSet)) repos := make(map[int64]*Repository, len(set)) if err := e. Where("id > 0"). - In("id", keysInt64(set)). + In("id", keysInt64(userIdSet)). Find(&users); err != nil { return fmt.Errorf("find users: %v", err) } @@ -296,7 +298,13 @@ func getDatasetAttachments(e Engine, typeCloudBrain int, isSigned bool, user *Us if err != nil { return err } - attachment.FileChunk = fileChunks[0] + if len(fileChunks) > 0 { + attachment.Md5 = fileChunks[0].Md5 + } else { + log.Error("has attachment record, but has no file_chunk record") + attachment.Md5 = "no_record" + } + attachment.CanDel = CanDelAttachment(isSigned, user, attachment) sortedRels.Rel[currentIndex].Attachments = append(sortedRels.Rel[currentIndex].Attachments, attachment) } diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index c29e55402..933571a0b 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -249,7 +249,7 @@ func NotebookShow(ctx *context.Context) { debugListType := ctx.Query("debugListType") var ID = ctx.Params(":id") - task, err := models.GetCloudbrainByID(ID) + task, err := models.GetCloudbrainByIDWithDeleted(ID) if err != nil { ctx.Data["error"] = err.Error() ctx.RenderWithErr(err.Error(), tplModelArtsNotebookShow, nil) @@ -264,16 +264,19 @@ func NotebookShow(ctx *context.Context) { } if result != nil { - task.Status = result.Status - err = models.UpdateJob(task) - if err != nil { - ctx.Data["error"] = err.Error() - ctx.RenderWithErr(err.Error(), tplModelArtsNotebookShow, nil) - return - } + if task.DeletedAt.IsZero() { //normal record + if task.Status != result.Status { + task.Status = result.Status + err = models.UpdateJob(task) + if err != nil { + ctx.Data["error"] = err.Error() + ctx.RenderWithErr(err.Error(), tplModelArtsNotebookShow, nil) + return + } + } + } else { //deleted record - result.CreateTime = time.Unix(int64(result.CreateAt/1000), 0).Format("2006-01-02 15:04:05") - result.LatestUpdateTime = time.Unix(int64(result.UpdateAt/1000), 0).Format("2006-01-02 15:04:05") + } } datasetDownloadLink := "-" @@ -319,7 +322,6 @@ func NotebookShow(ctx *context.Context) { ctx.Data["task"] = task ctx.Data["ID"] = ID ctx.Data["jobName"] = task.JobName - ctx.Data["result"] = result ctx.Data["debugListType"] = debugListType ctx.HTML(200, tplModelArtsNotebookShow) } diff --git a/templates/custom/select_dataset.tmpl b/templates/custom/select_dataset.tmpl index dc5ca6c9e..273477dd2 100644 --- a/templates/custom/select_dataset.tmpl +++ b/templates/custom/select_dataset.tmpl @@ -135,4 +135,4 @@ - \ No newline at end of file + diff --git a/templates/custom/select_dataset_train.tmpl b/templates/custom/select_dataset_train.tmpl new file mode 100644 index 000000000..2771200b6 --- /dev/null +++ b/templates/custom/select_dataset_train.tmpl @@ -0,0 +1,134 @@ + + +
+     + + + {{.i18n.Tr "dataset.select_dataset"}} + +
+ + +
+ + + +
+
+
${dataset.Repo.OwnerName}/${dataset.Repo.Alias} ${dataset.Name}
+
+ + + + ${dataset.Description} +
+
+
+ + + + 解压中 + + + + 解压失败 + +
+
+ + +
+ +
+
+
${dataset.Repo.OwnerName}/${dataset.Repo.Alias}${dataset.Name}
+
+ + + + ${dataset.Description} +
+
+
+ + + + 解压中 + + + + 解压失败 + +
+
+ +
+ +
+
+
${dataset.Repo.OwnerName}/${dataset.Repo.Alias}${dataset.Name}
+
+ + + + ${dataset.Description} +
+
+
+ + + + 解压中 + + + + 解压失败 + +
+
+ +
+ +
+
+
${dataset.Repo.OwnerName}/${dataset.Repo.Alias}${dataset.Name}
+
+ + + + ${dataset.Description} +
+
+
+ + + + 解压中 + + + + 解压失败 + +
+
+ +
+
+
+ + +
+
+ + +
diff --git a/templates/explore/datasets.tmpl b/templates/explore/datasets.tmpl index ff18a3da3..a1692cf35 100644 --- a/templates/explore/datasets.tmpl +++ b/templates/explore/datasets.tmpl @@ -121,10 +121,10 @@ @@ -184,9 +184,15 @@
+ {{if eq .UserID 0}} + {{else}} + + + + {{end}} 创建于:{{TimeSinceUnix1 .CreatedUnix}}
@@ -215,4 +221,4 @@ -{{template "base/footer" .}} +{{template "base/footer" .}} \ No newline at end of file diff --git a/templates/repo/cloudbrain/trainjob/new.tmpl b/templates/repo/cloudbrain/trainjob/new.tmpl index e33920b20..e7254e410 100755 --- a/templates/repo/cloudbrain/trainjob/new.tmpl +++ b/templates/repo/cloudbrain/trainjob/new.tmpl @@ -169,9 +169,9 @@
{{if .bootFile}} - + {{else}} - + {{end}} @@ -179,17 +179,9 @@ 查看样例
-
- - - 训练脚本存储在/code中,数据集存储在/dataset中,训练输出请存储在/model中以供后续下载。 -
+ {{template "custom/select_dataset_train" .}} + 训练脚本存储在/code中,数据集存储在/dataset中,训练输出请存储在/model中以供后续下载。
{{.i18n.Tr "repo.modelarts.train_job.add_run_parameter"}} diff --git a/templates/repo/datasets/index.tmpl b/templates/repo/datasets/index.tmpl index 065ada386..e8d9b65e3 100755 --- a/templates/repo/datasets/index.tmpl +++ b/templates/repo/datasets/index.tmpl @@ -199,7 +199,7 @@
{{range $k, $v :=.Attachments}} -
+
@@ -266,8 +266,8 @@ {{$.i18n.Tr "preview"}} {{end}} {{if and (.CanDel) (not $.Repository.IsPrivate)}} - {{$.i18n.Tr "dataset.set_public"}} - {{$.i18n.Tr "dataset.set_private"}} + {{$.i18n.Tr "dataset.set_public"}} + {{$.i18n.Tr "dataset.set_private"}} {{end}} -
-      - - - - -
- + {{template "custom/select_dataset_train" .}} + {{.i18n.Tr "cloudbrain.dataset_path_rule"}}
-   + {{if .bootFile}} {{else}} diff --git a/templates/repo/modelarts/trainjob/new.tmpl b/templates/repo/modelarts/trainjob/new.tmpl index 963250bcb..3629de442 100755 --- a/templates/repo/modelarts/trainjob/new.tmpl +++ b/templates/repo/modelarts/trainjob/new.tmpl @@ -158,29 +158,18 @@
{{if .bootFile}} - + {{else}} - + {{end}} {{.i18n.Tr "cloudbrain.view_sample"}}
-
- - - {{.i18n.Tr "cloudbrain.dataset_path_rule"}} -
- + + {{template "custom/select_dataset_train" .}} + {{.i18n.Tr "cloudbrain.dataset_path_rule"}}
{{.i18n.Tr "repo.modelarts.train_job.add_run_parameter"}}