diff --git a/models/dataset.go b/models/dataset.go index f4482630a..6913071bb 100755 --- a/models/dataset.go +++ b/models/dataset.go @@ -101,11 +101,28 @@ type SearchDatasetOptions struct { } func CreateDataset(dataset *Dataset) (err error) { - if _, err = x.Insert(dataset); err != nil { + + sess := x.NewSession() + defer sess.Close() + + if err := sess.Begin(); err != nil { return err } - return nil + datasetByRepoId := &Dataset{RepoID: dataset.RepoID} + has, err := sess.Get(datasetByRepoId) + if err != nil { + return err + } + if has { + return fmt.Errorf("The dataset already exists.") + } + + if _, err = sess.Insert(dataset); err != nil { + return err + } + return sess.Commit() + } func SearchDataset(opts *SearchDatasetOptions) (DatasetList, int64, error) { diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index 481d0900b..96cce5cd0 100755 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -68,6 +68,12 @@ func renderAttachmentSettings(ctx *context.Context) { func UploadAttachmentUI(ctx *context.Context) { ctx.Data["datasetId"] = ctx.Query("datasetId") + dataset, _ := models.GetDatasetByID(ctx.QueryInt64("datasetId")) + if dataset == nil { + ctx.Error(404, "The dataset does not exits.") + } + r, _ := models.GetRepositoryByID(dataset.RepoID) + ctx.Data["Repo"] = r ctx.HTML(200, tplAttachmentUpload) } diff --git a/templates/repo/attachment/upload.tmpl b/templates/repo/attachment/upload.tmpl new file mode 100644 index 000000000..167a65aae --- /dev/null +++ b/templates/repo/attachment/upload.tmpl @@ -0,0 +1,98 @@ + +{{template "base/head" .}} +
+{{template "repo/header" .}} +
+ +
+

+ 上传数据集文件 +

+
+
+ + {{.CsrfTokenHtml}} + + CPU/GPU + NPU + + + + + + + + + + + + + + + + +
+
+
+
+
+
+ +

说明:

+

只有zip格式的数据集才能发起云脑任务;
+ 云脑1提供CPU / GPU资源,云脑2提供Ascend NPU资源;调试使用的数据集也需要上传到对应的环境;

+ +
+
+
+{{template "base/footer" .}} + \ No newline at end of file diff --git a/templates/repo/datasets/create.tmpl b/templates/repo/datasets/create.tmpl new file mode 100644 index 000000000..ea935c345 --- /dev/null +++ b/templates/repo/datasets/create.tmpl @@ -0,0 +1,65 @@ + +
+
+
+
+
+
+
+
+
+{{template "base/head" .}} +
+ {{template "repo/header" .}} +
+ +
+

+ {{.i18n.Tr "repo.modelarts.train_job.new_infer"}} +

+
+
+ + {{.CsrfTokenHtml}} + + + 请输入字母、数字、_和-,最长64个字符,且不能以中划线(-)结尾。 + + + + + + + + + + + + + + + + + + + + + + + + + 确定 + 取消 + + +
+
+
+
+
+{{template "base/footer" .}} diff --git a/templates/repo/datasets/index.tmpl b/templates/repo/datasets/index.tmpl index 65ba2bb6e..9074e62c4 100755 --- a/templates/repo/datasets/index.tmpl +++ b/templates/repo/datasets/index.tmpl @@ -6,145 +6,142 @@ margin: -1px; background: #FFF !important; } +.wrapper { + display: flex; + overflow: hidden; + padding: 0 1rem; + } + .exp{ + display: none; + } + .exp:checked+.text{ + max-height: none; + } + .exp:checked+.text::after{ + visibility: hidden; + } + .exp:checked+.text .btn::before{ + visibility: hidden; + } + .exp:checked+.text .btn::after{ + content:'收起' + } + + .wrapper>.text { + font-family: SourceHanSansSC-regular; + font-size: 14px; + color: #101010; + overflow: hidden; + text-overflow: ellipsis; + text-align: justify; + position: relative; + line-height: 1.5; + max-height: 3em; + transition: .3s max-height; + } + .wrapper>.text::before { + content: ''; + height: calc(100% - 20px); + float: right; + } + .wrapper>.text::after { + content: ''; + width: 999vw; + height: 999vw; + position: absolute; + box-shadow: inset calc(100px - 999vw) calc(30px - 999vw) 0 0 #fff; + margin-left: -100px; + } + .btn{ + position: relative; + float: right; + clear: both; + margin-left: 20px; + font-size: 14px; + padding: 0 8px; + background: #3F51B5; + line-height: 20px; + border-radius: 4px; + color: #fff; + cursor: pointer; + /* margin-top: -30px; */ + } + .btn::after{ + content:'展开' + } + .btn::before{ + content: '...'; + position: absolute; + left: -5px; + color: #333; + transform: translateX(-100%) + } -
+
{{template "repo/header" .}} - -
- - -
- {{.CsrfTokenHtml}} - {{template "base/alert" .}} -
-
-
-

{{.dataset.Title}}

-
- {{if .Permission.CanWrite $.UnitTypeDatasets}} - - {{end}} -
-
-
- {{if .dataset.Description }} - {{.dataset.Description}} - {{else}} - {{.Repository.DescriptionHTML}} - {{end}} -
-
-
- -
- -
- -
- -
- -
- -
- {{.i18n.Tr "cancel"}} - -
-
- - - -
-
-
-
-
- {{if eq .Type 0}}{{.i18n.Tr "repo.cloudbrain1"}}{{else}}{{.i18n.Tr "repo.cloudbrain2"}}{{end}}-{{.i18n.Tr "datasets"}} -
-
-