From 6eb17718d0f33e13170993ed8a63c7c996035507 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Thu, 7 Apr 2022 09:40:35 +0800 Subject: [PATCH 1/9] fix-1827 --- models/dataset.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/models/dataset.go b/models/dataset.go index 7cac6c468..939aa8634 100755 --- a/models/dataset.go +++ b/models/dataset.go @@ -62,19 +62,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) } From 4197eaec1303d88b38e751d5269fa37c312e2f04 Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Thu, 7 Apr 2022 10:42:05 +0800 Subject: [PATCH 2/9] no_record md5 --- models/attachment.go | 1 + models/dataset.go | 9 ++++++++- templates/repo/datasets/index.tmpl | 10 +++++----- 3 files changed, 14 insertions(+), 6 deletions(-) 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..c56a8fdc3 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" @@ -296,7 +297,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/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}}
From d8de9704fbd925012633a85ea79c8f8489bde8f6 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Mon, 11 Apr 2022 10:06:19 +0800 Subject: [PATCH 9/9] fix issue --- templates/custom/select_dataset.tmpl | 2 +- templates/custom/select_dataset_train.tmpl | 134 ++++++++++++++++++ templates/repo/cloudbrain/trainjob/new.tmpl | 16 +-- .../repo/modelarts/inferencejob/new.tmpl | 20 +-- templates/repo/modelarts/trainjob/new.tmpl | 21 +-- 5 files changed, 147 insertions(+), 46 deletions(-) create mode 100644 templates/custom/select_dataset_train.tmpl 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/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/modelarts/inferencejob/new.tmpl b/templates/repo/modelarts/inferencejob/new.tmpl index 5e7347abf..6c8681432 100644 --- a/templates/repo/modelarts/inferencejob/new.tmpl +++ b/templates/repo/modelarts/inferencejob/new.tmpl @@ -169,24 +169,10 @@
-
-      - - - - -
- + {{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"}}