From 6931dc07ff6eef673050df6d6c431be5f674306c Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Wed, 2 Mar 2022 09:43:34 +0800 Subject: [PATCH 001/109] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E7=82=B9?= =?UTF-8?q?=E8=B5=9E=E5=90=8E=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/base_message.go | 10 ++++++ models/dataset.go | 1 + models/dataset_star.go | 62 +++++++++++++++++++++++++++++++++ models/user.go | 9 ++--- options/locale/locale_en-US.ini | 1 + options/locale/locale_zh-CN.ini | 2 ++ routers/repo/dataset.go | 19 ++++++++++ routers/routes/routes.go | 1 + 8 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 models/base_message.go create mode 100644 models/dataset_star.go diff --git a/models/base_message.go b/models/base_message.go new file mode 100644 index 000000000..d20650463 --- /dev/null +++ b/models/base_message.go @@ -0,0 +1,10 @@ +package models + +type BaseMessage struct { + Code int + Message string +} + +var BaseMessageOK = BaseMessage{ + 0, "", +} diff --git a/models/dataset.go b/models/dataset.go index 2b3de752b..00b45d48f 100755 --- a/models/dataset.go +++ b/models/dataset.go @@ -22,6 +22,7 @@ type Dataset struct { Category string Description string `xorm:"TEXT"` DownloadTimes int64 + NumStars int License string Task string ReleaseID int64 `xorm:"INDEX"` diff --git a/models/dataset_star.go b/models/dataset_star.go new file mode 100644 index 000000000..fac08caee --- /dev/null +++ b/models/dataset_star.go @@ -0,0 +1,62 @@ +package models + +import "code.gitea.io/gitea/modules/timeutil" + +type DatasetStar struct { + ID int64 `xorm:"pk autoincr"` + UID int64 `xorm:"UNIQUE(s)"` + DatasetID int64 `xorm:"UNIQUE(s)"` + CreatedUnix timeutil.TimeStamp `xorm:"created"` +} + +// StarRepo or unstar repository. +func StarDataset(userID, datasetID int64, star bool) error { + sess := x.NewSession() + defer sess.Close() + + if err := sess.Begin(); err != nil { + return err + } + + if star { + if isDatasetStaring(sess, userID, datasetID) { + return nil + } + + if _, err := sess.Insert(&DatasetStar{UID: userID, DatasetID: datasetID}); err != nil { + return err + } + if _, err := sess.Exec("UPDATE `dataset` SET num_stars = num_stars + 1 WHERE id = ?", datasetID); err != nil { + return err + } + if _, err := sess.Exec("UPDATE `user` SET num_dataset_stars = num_dataset_stars + 1 WHERE id = ?", userID); err != nil { + return err + } + } else { + if !isDatasetStaring(sess, userID, datasetID) { + return nil + } + + if _, err := sess.Delete(&DatasetStar{0, userID, datasetID, 0}); err != nil { + return err + } + if _, err := sess.Exec("UPDATE `dataset` SET num_stars = num_stars - 1 WHERE id = ?", datasetID); err != nil { + return err + } + if _, err := sess.Exec("UPDATE `user` SET num_dataset_stars = num_dataset_stars - 1 WHERE id = ?", userID); err != nil { + return err + } + } + + return sess.Commit() +} + +func IsDatasetStaring(userID, datasetID int64) bool { + + return isDatasetStaring(x, userID, datasetID) +} + +func isDatasetStaring(e Engine, userID, datasetID int64) bool { + has, _ := e.Get(&DatasetStar{0, userID, datasetID, 0}) + return has +} diff --git a/models/user.go b/models/user.go index f7857248b..bbbe9359e 100755 --- a/models/user.go +++ b/models/user.go @@ -153,10 +153,11 @@ type User struct { UseCustomAvatar bool // Counters - NumFollowers int - NumFollowing int `xorm:"NOT NULL DEFAULT 0"` - NumStars int - NumRepos int + NumFollowers int + NumFollowing int `xorm:"NOT NULL DEFAULT 0"` + NumStars int + NumDatasetStars int + NumRepos int // For organization NumTeams int diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 0787e6ce6..a4331b3d7 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1061,6 +1061,7 @@ unstar = Unstar star = Star fork = Fork download_archive = Download Repository +star_fail=Failed to %s the dataset. no_desc = No Description no_label = No labels diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 2eeb72735..a09bafc89 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -1070,6 +1070,8 @@ unstar=取消点赞 star=点赞 fork=派生 download_archive=下载此项目 +star_fail=%s失败。 + no_desc=暂无描述 no_label = 暂无标签 diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index 7d59ab486..fcbf2894d 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -1,6 +1,7 @@ package repo import ( + "net/http" "sort" "code.gitea.io/gitea/models" @@ -190,3 +191,21 @@ func EditDatasetPost(ctx *context.Context, form auth.EditDatasetForm) { } ctx.Redirect(ctx.Repo.RepoLink + "/datasets?type=" + form.Type) } + +func DatasetAction(ctx *context.Context) { + var err error + datasetId := ctx.QueryInt64(":id") + switch ctx.Params(":action") { + case "star": + err = models.StarDataset(ctx.User.ID, datasetId, true) + case "unstar": + err = models.StarDataset(ctx.User.ID, datasetId, false) + + } + if err != nil { + ctx.JSON(http.StatusOK, models.BaseMessage{1, ctx.Tr("repo.star_fail", ctx.Params(":action"))}) + } else { + ctx.JSON(http.StatusOK, models.BaseMessageOK) + } + +} diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 7fa06fa3b..d97c22a2d 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -978,6 +978,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Group("/datasets", func() { m.Get("", reqRepoDatasetReader, repo.DatasetIndex) + m.Put("/:id/:action", reqRepoDatasetReader, repo.DatasetAction) m.Post("", reqRepoDatasetWriter, bindIgnErr(auth.EditDatasetForm{}), repo.EditDatasetPost) m.Group("/dirs", func() { From 7a3cd6b1cd15556db0b0dd46b60355b8233bb022 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Wed, 2 Mar 2022 10:42:10 +0800 Subject: [PATCH 002/109] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/dataset.go | 2 +- models/user.go | 2 +- routers/repo/dataset.go | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/models/dataset.go b/models/dataset.go index 00b45d48f..54feb0f96 100755 --- a/models/dataset.go +++ b/models/dataset.go @@ -22,7 +22,7 @@ type Dataset struct { Category string Description string `xorm:"TEXT"` DownloadTimes int64 - NumStars int + NumStars int `xorm:"NOT NULL DEFAULT 0"` License string Task string ReleaseID int64 `xorm:"INDEX"` diff --git a/models/user.go b/models/user.go index bbbe9359e..f72462051 100755 --- a/models/user.go +++ b/models/user.go @@ -156,7 +156,7 @@ type User struct { NumFollowers int NumFollowing int `xorm:"NOT NULL DEFAULT 0"` NumStars int - NumDatasetStars int + NumDatasetStars int `xorm:"NOT NULL DEFAULT 0"` NumRepos int // For organization diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index fcbf2894d..0e5cf2182 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -3,6 +3,7 @@ package repo import ( "net/http" "sort" + "strconv" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/auth" @@ -194,7 +195,7 @@ func EditDatasetPost(ctx *context.Context, form auth.EditDatasetForm) { func DatasetAction(ctx *context.Context) { var err error - datasetId := ctx.QueryInt64(":id") + datasetId, _ := strconv.ParseInt(ctx.Params(":id"), 10, 64) switch ctx.Params(":action") { case "star": err = models.StarDataset(ctx.User.ID, datasetId, true) From b2cb55734b57611f7ba7f34791c1e9cbf94a7f3b Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Wed, 2 Mar 2022 17:38:44 +0800 Subject: [PATCH 003/109] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E4=B8=8D=E5=88=9B=E5=BB=BA=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86=20=E9=A1=B9=E7=9B=AE=E6=94=B9=E4=B8=BA=E7=A7=81?= =?UTF-8?q?=E6=9C=89=EF=BC=8C=E6=8A=8A=E6=95=B0=E6=8D=AE=E9=9B=86=E5=92=8C?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E4=B8=8B=E6=89=80=E6=9C=89=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=94=B9=E4=B8=BA=E7=A7=81=E6=9C=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/dataset.go | 3 --- models/repo.go | 23 +++++++++++++++++++---- routers/repo/attachment.go | 8 +++++++- routers/repo/dataset.go | 4 ++-- routers/repo/setting.go | 4 ---- 5 files changed, 28 insertions(+), 14 deletions(-) diff --git a/models/dataset.go b/models/dataset.go index 54feb0f96..87b99589d 100755 --- a/models/dataset.go +++ b/models/dataset.go @@ -302,9 +302,6 @@ func GetDatasetByID(id int64) (*Dataset, error) { } func GetDatasetByRepo(repo *Repository) (*Dataset, error) { - if err := CreateDefaultDatasetToRepo(repo); err != nil { - return nil, err - } dataset := &Dataset{RepoID: repo.ID} has, err := x.Get(dataset) if err != nil { diff --git a/models/repo.go b/models/repo.go index 6b3df9fe0..9bb4b9d03 100755 --- a/models/repo.go +++ b/models/repo.go @@ -1280,10 +1280,6 @@ func CreateRepository(ctx DBContext, doer, u *User, repo *Repository, opts ...Cr return fmt.Errorf("copyDefaultWebhooksToRepo: %v", err) } - if err = CreateDefaultDatasetToRepo(repo); err != nil { - return fmt.Errorf("models.CreateDefaultDatasetToRepo: %v", err) - } - return nil } @@ -1586,6 +1582,25 @@ func updateRepository(e Engine, repo *Repository, visibilityChanged bool) (err e if err != nil { return err } + //If repo has become private, we need set dataset and dataset_file to private + _, err = e.Where("repo_id = ?", repo.ID).Cols("status").Update(&Dataset{ + Status: 0, + }) + if err != nil { + return err + } + + dataset, err := GetDatasetByRepo(repo) + if err != nil { + return err + } + _, err = e.Where("dataset_id = ?", dataset.ID).Cols("is_private").Update(&Attachment{ + IsPrivate: true, + }) + if err != nil { + return err + } + } // Create/Remove git-daemon-export-ok for git-daemon... diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index bc843c555..13ce62aa9 100755 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -387,11 +387,17 @@ func AddAttachment(ctx *context.Context) { ctx.Error(404, "attachment has not been uploaded") return } + datasetId := ctx.QueryInt64("dataset_id") + dataset, err := models.GetDatasetByID(datasetId) + if err != nil { + ctx.Error(404, "dataset does not exist.") + return + } attachment, err := models.InsertAttachment(&models.Attachment{ UUID: uuid, UploaderID: ctx.User.ID, - IsPrivate: true, + IsPrivate: dataset.IsPrivate(), Name: fileName, Size: ctx.QueryInt64("size"), DatasetID: ctx.QueryInt64("dataset_id"), diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index 0e5cf2182..f7e5415f4 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -112,8 +112,8 @@ func DatasetIndex(ctx *context.Context) { dataset, err := models.GetDatasetByRepo(repo) if err != nil { - log.Error("query dataset, not found repo.") - ctx.NotFound("GetDatasetByRepo", err) + log.Warn("query dataset, not found.") + ctx.HTML(200, tplIndex) return } diff --git a/routers/repo/setting.go b/routers/repo/setting.go index 5b057dbe5..af28f3290 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -245,10 +245,6 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) { // This section doesn't require repo_name/RepoName to be set in the form, don't show it // as an error on the UI for this action ctx.Data["Err_RepoName"] = nil - if err := models.CreateDefaultDatasetToRepo(repo); err != nil { - ctx.ServerError("CreateDefaultDatasetToRepo", err) - return - } if form.EnableDataset && !models.UnitTypeDatasets.UnitGlobalDisabled() { units = append(units, models.RepoUnit{ From a5c49c30ba23c6c4ca5cc6c6df18db1e4a687ebd Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Thu, 3 Mar 2022 15:31:28 +0800 Subject: [PATCH 004/109] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/base_message.go | 8 +++- models/dataset.go | 29 +++++------- modules/auth/dataset.go | 10 ++--- options/locale/locale_en-US.ini | 4 ++ options/locale/locale_zh-CN.ini | 5 +++ routers/home.go | 4 ++ routers/repo/dataset.go | 78 +++++++++++++++++++++++++++------ routers/routes/routes.go | 3 ++ 8 files changed, 101 insertions(+), 40 deletions(-) diff --git a/models/base_message.go b/models/base_message.go index d20650463..37f7668ad 100644 --- a/models/base_message.go +++ b/models/base_message.go @@ -5,6 +5,12 @@ type BaseMessage struct { Message string } -var BaseMessageOK = BaseMessage{ +var BaseOKMessage = BaseMessage{ 0, "", } + +func BaseErrorMessage(message string) BaseMessage { + return BaseMessage{ + 1, message, + } +} diff --git a/models/dataset.go b/models/dataset.go index 87b99589d..b64b00eb6 100755 --- a/models/dataset.go +++ b/models/dataset.go @@ -22,7 +22,7 @@ type Dataset struct { Category string Description string `xorm:"TEXT"` DownloadTimes int64 - NumStars int `xorm:"NOT NULL DEFAULT 0"` + NumStars int `xorm:"INDEX NOT NULL DEFAULT 0"` License string Task string ReleaseID int64 `xorm:"INDEX"` @@ -105,22 +105,6 @@ func CreateDataset(dataset *Dataset) (err error) { return nil } -func CreateDefaultDatasetToRepo(repo *Repository) (err error) { - dataset := &Dataset{RepoID: repo.ID} - has, err := x.Get(dataset) - if err != nil { - return err - } - if !has { - dataset.Status = DatasetStatusPrivate - dataset.Title = repo.Name - if err = CreateDataset(dataset); err != nil { - return err - } - } - return nil -} - func SearchDataset(opts *SearchDatasetOptions) (DatasetList, int64, error) { cond := SearchDatasetCondition(opts) return SearchDatasetByCondition(opts, cond) @@ -140,6 +124,7 @@ func SearchDatasetCondition(opts *SearchDatasetOptions) builder.Cond { if opts.IncludePublic { cond = cond.And(builder.Eq{"dataset.status": DatasetStatusPublic}) + cond = cond.And(builder.Eq{"attachment.is_private": false}) if opts.OwnerID > 0 { if len(opts.Keyword) == 0 { cond = cond.Or(builder.Eq{"repository.owner_id": opts.OwnerID}) @@ -154,6 +139,7 @@ func SearchDatasetCondition(opts *SearchDatasetOptions) builder.Cond { cond = cond.And(builder.Eq{"repository.owner_id": opts.OwnerID}) if !opts.IsOwner { cond = cond.And(builder.Eq{"dataset.status": DatasetStatusPublic}) + cond = cond.And(builder.Eq{"attachment.is_private": false}) } } @@ -170,14 +156,19 @@ func SearchDatasetByCondition(opts *SearchDatasetOptions, cond builder.Cond) (Da defer sess.Close() datasets := make(DatasetList, 0, opts.PageSize) + selectColumnsSql := "distinct dataset.id,dataset.title, dataset.status, dataset.category, dataset.description, dataset.download_times, dataset.license, dataset.task, dataset.release_id, dataset.user_id, dataset.repo_id, dataset.created_unix,dataset.updated_unix,dataset.num_stars" - count, err := sess.Join("INNER", "repository", "repository.id = dataset.repo_id").Where(cond).Count(new(Dataset)) + count, err := sess.Select(selectColumnsSql).Join("INNER", "repository", "repository.id = dataset.repo_id"). + Join("INNER", "attachment", "attachment.dataset_id=dataset.id"). + Where(cond).Count(new(Dataset)) if err != nil { return nil, 0, fmt.Errorf("Count: %v", err) } - sess.Select("dataset.*").Join("INNER", "repository", "repository.id = dataset.repo_id").Where(cond).OrderBy(opts.SearchOrderBy.String()) + sess.Select(selectColumnsSql).Join("INNER", "repository", "repository.id = dataset.repo_id"). + Join("INNER", "attachment", "attachment.dataset_id=dataset.id"). + Where(cond).OrderBy(opts.SearchOrderBy.String()) if opts.PageSize > 0 { sess.Limit(opts.PageSize, (opts.Page-1)*opts.PageSize) } diff --git a/modules/auth/dataset.go b/modules/auth/dataset.go index 577637273..4a6dbbd7d 100755 --- a/modules/auth/dataset.go +++ b/modules/auth/dataset.go @@ -9,11 +9,10 @@ import ( type CreateDatasetForm struct { Title string `binding:"Required"` Category string `binding:"Required"` - Description string `binding:"Required;MaxSize(254)"` + Description string `binding:"Required"` License string `binding:"Required;MaxSize(64)"` Task string `binding:"Required;MaxSize(64)"` ReleaseID int64 `xorm:"INDEX"` - Private bool Files []string } @@ -25,11 +24,10 @@ type EditDatasetForm struct { ID int64 `binding:"Required"` Title string `binding:"Required"` Category string `binding:"Required"` - Description string `binding:"Required;MaxSize(254)"` + Description string `binding:"Required"` License string `binding:"Required;MaxSize(64)"` Task string `binding:"Required;MaxSize(64)"` - Private bool - ReleaseID int64 `xorm:"INDEX"` + ReleaseID int64 `xorm:"INDEX"` Files []string - Type string `binding:"Required"` + Type string `binding:"Required"` } diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index a4331b3d7..5b07b6b4d 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -709,8 +709,12 @@ alert = To initiate a cloud brain task, please upload the dataset in zip format. dataset = Dataset dataset_setting= Dataset Setting title = Name +title_format_err=Name can only contain number,letter,'-','_' or '.', and can be up to 100 characters long. description = Description +description_format_err=Description's length can be up to 1024 characters long. create_dataset = Create Dataset +create_dataset_fail=Failed to create dataset. +query_dataset_fail=Failed to query dataset. show_dataset= Dataset edit_dataset= Edit Dataset update_dataset= Update Dataset diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index a09bafc89..7609437d6 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -712,8 +712,13 @@ alert=如果要发起云脑任务,请上传zip格式的数据集 dataset=数据集 dataset_setting=数据集设置 title=名称 +title_format_err=名称最多允许输入100个字符,只允许字母,数字,中划线 (‘-’),下划线 (‘_’) 和点 (‘.’) 。 description=描述 +description_format_err=描述最多允许输入1024个字符。 create_dataset=创建数据集 +create_dataset_fail=创建数据集失败。 +query_dataset_fail=查询数据集失败 + show_dataset=数据集 edit_dataset=编辑数据集 update_dataset=更新数据集 diff --git a/routers/home.go b/routers/home.go index 2db8d2112..93e6f8461 100755 --- a/routers/home.go +++ b/routers/home.go @@ -301,6 +301,10 @@ func ExploreDatasets(ctx *context.Context) { orderBy = models.SearchOrderBySizeReverse case "downloadtimes": orderBy = models.SearchOrderByDownloadTimes + case "moststars": + orderBy = models.SearchOrderByStarsReverse + case "feweststars": + orderBy = models.SearchOrderByStars default: ctx.Data["SortType"] = "recentupdate" orderBy = models.SearchOrderByRecentUpdated diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index f7e5415f4..8ad83654b 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -2,8 +2,10 @@ package repo import ( "net/http" + "regexp" "sort" "strconv" + "unicode/utf8" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/auth" @@ -14,9 +16,12 @@ import ( ) const ( - tplIndex base.TplName = "repo/datasets/index" + tplIndex base.TplName = "repo/datasets/index" + tplDatasetCreate base.TplName = "repo/datasets/create" ) +var titlePattern = regexp.MustCompile(`^[A-Za-z0-9-_\\.]{1,100}$`) + // MustEnableDataset check if repository enable internal dataset func MustEnableDataset(ctx *context.Context) { if !ctx.Repo.CanRead(models.UnitTypeDatasets) { @@ -161,22 +166,69 @@ func DatasetIndex(ctx *context.Context) { ctx.HTML(200, tplIndex) } +func CreateDataset(ctx *context.Context) { + + MustEnableDataset(ctx) + + ctx.HTML(200, tplDatasetCreate) +} + +func CreateDatasetPost(ctx *context.Context, form auth.CreateDatasetForm) { + + dataset := &models.Dataset{} + + if !titlePattern.MatchString(form.Title) { + ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr("dataset.title_format_err"))) + return + } + if utf8.RuneCountInString(form.Description) > 1024 { + ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr("dataset.description_format_err"))) + return + } + + dataset.RepoID = ctx.Repo.Repository.ID + dataset.UserID = ctx.User.ID + dataset.Category = form.Category + dataset.Task = form.Task + dataset.Title = form.Title + dataset.License = form.License + dataset.Description = form.Description + dataset.DownloadTimes = 0 + if ctx.Repo.Repository.IsPrivate { + dataset.Status = 0 + } else { + dataset.Status = 1 + } + err := models.CreateDataset(dataset) + if err != nil { + log.Error("fail to create dataset", err) + ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr("dataset.create_dataset_fail"))) + } else { + ctx.JSON(http.StatusOK, models.BaseOKMessage) + } + +} + func EditDatasetPost(ctx *context.Context, form auth.EditDatasetForm) { ctx.Data["PageIsDataset"] = true ctx.Data["Title"] = ctx.Tr("dataset.edit_dataset") + if !titlePattern.MatchString(form.Title) { + ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr("dataset.title_format_err"))) + return + } + if utf8.RuneCountInString(form.Description) > 1024 { + ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr("dataset.description_format_err"))) + return + } + rel, err := models.GetDatasetByID(form.ID) ctx.Data["dataset"] = rel if err != nil { - ctx.ServerError("GetDataset", err) - return - } - - if ctx.HasError() { - ctx.Data["Error"] = true - ctx.HTML(200, tplIndex) + log.Error("failed to query dataset", err) + ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr("dataset.query_dataset_fail"))) return } @@ -186,11 +238,9 @@ func EditDatasetPost(ctx *context.Context, form auth.EditDatasetForm) { rel.Task = form.Task rel.License = form.License if err = models.UpdateDataset(models.DefaultDBContext(), rel); err != nil { - ctx.Data["Error"] = true - ctx.HTML(200, tplIndex) - log.Error("%v", err) + ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr("dataset.query_dataset_fail"))) } - ctx.Redirect(ctx.Repo.RepoLink + "/datasets?type=" + form.Type) + ctx.JSON(http.StatusOK, models.BaseOKMessage) } func DatasetAction(ctx *context.Context) { @@ -204,9 +254,9 @@ func DatasetAction(ctx *context.Context) { } if err != nil { - ctx.JSON(http.StatusOK, models.BaseMessage{1, ctx.Tr("repo.star_fail", ctx.Params(":action"))}) + ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr("repo.star_fail", ctx.Params(":action")))) } else { - ctx.JSON(http.StatusOK, models.BaseMessageOK) + ctx.JSON(http.StatusOK, models.BaseOKMessage) } } diff --git a/routers/routes/routes.go b/routers/routes/routes.go index d97c22a2d..50da9ad23 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -979,6 +979,9 @@ func RegisterRoutes(m *macaron.Macaron) { m.Group("/datasets", func() { m.Get("", reqRepoDatasetReader, repo.DatasetIndex) m.Put("/:id/:action", reqRepoDatasetReader, repo.DatasetAction) + m.Get("/create", reqRepoDatasetWriter, repo.CreateDataset) + m.Post("/create", reqRepoDatasetWriter, bindIgnErr(auth.CreateDatasetForm{}), repo.CreateDatasetPost) + m.Post("", reqRepoDatasetWriter, bindIgnErr(auth.EditDatasetForm{}), repo.EditDatasetPost) m.Group("/dirs", func() { From 68b39af5e5cc811f38842b07ebba0c5f3c3b195e Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Fri, 4 Mar 2022 11:34:20 +0800 Subject: [PATCH 005/109] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/attachment.go | 1 + models/dataset.go | 38 +++++++++++++++---- routers/home.go | 9 +++++ routers/repo/attachment.go | 32 ++++++++++------ routers/repo/dataset.go | 78 ++++++++++++++++++++------------------ routers/routes/routes.go | 1 + 6 files changed, 104 insertions(+), 55 deletions(-) diff --git a/models/attachment.go b/models/attachment.go index c322d391b..af7cafe53 100755 --- a/models/attachment.go +++ b/models/attachment.go @@ -38,6 +38,7 @@ type Attachment struct { UploaderID int64 `xorm:"INDEX DEFAULT 0"` // Notice: will be zero before this column added CommentID int64 Name string + Description string `xorm:"TEXT"` DownloadCount int64 `xorm:"DEFAULT 0"` Size int64 `xorm:"DEFAULT 0"` IsPrivate bool `xorm:"DEFAULT false"` diff --git a/models/dataset.go b/models/dataset.go index b64b00eb6..efc610630 100755 --- a/models/dataset.go +++ b/models/dataset.go @@ -92,6 +92,9 @@ type SearchDatasetOptions struct { OwnerID int64 RepoID int64 IncludePublic bool + Category string + Task string + License string ListOptions SearchOrderBy IsOwner bool @@ -118,6 +121,17 @@ func SearchDatasetCondition(opts *SearchDatasetOptions) builder.Cond { cond = cond.And(builder.Like{"dataset.title", opts.Keyword}) } + if len(opts.Category) > 0 { + cond = cond.And(builder.Eq{"dataset.category": opts.Category}) + } + + if len(opts.Task) > 0 { + cond = cond.And(builder.Eq{"dataset.task": opts.Task}) + } + if len(opts.License) > 0 { + cond = cond.And(builder.Eq{"dataset.license": opts.License}) + } + if opts.RepoID > 0 { cond = cond.And(builder.Eq{"dataset.repo_id": opts.RepoID}) } @@ -223,13 +237,23 @@ func getDatasetAttachments(e Engine, typeCloudBrain int, isSigned bool, user *Us sort.Sort(sortedRels) // Select attachments - err = e. - Asc("dataset_id"). - In("dataset_id", sortedRels.ID). - And("type = ?", typeCloudBrain). - Find(&attachments, Attachment{}) - if err != nil { - return err + if typeCloudBrain == -1 { + err = e. + Asc("dataset_id"). + In("dataset_id", sortedRels.ID). + Find(&attachments, Attachment{}) + if err != nil { + return err + } + } else { + err = e. + Asc("dataset_id"). + In("dataset_id", sortedRels.ID). + And("type = ?", typeCloudBrain). + Find(&attachments, Attachment{}) + if err != nil { + return err + } } // merge join diff --git a/routers/home.go b/routers/home.go index 93e6f8461..c59e9576a 100755 --- a/routers/home.go +++ b/routers/home.go @@ -312,6 +312,9 @@ func ExploreDatasets(ctx *context.Context) { keyword := strings.Trim(ctx.Query("q"), " ") + category := ctx.Query("category") + task := ctx.Query("task") + license := ctx.Query("license") var ownerID int64 if ctx.User != nil && !ctx.User.IsAdmin { ownerID = ctx.User.ID @@ -320,6 +323,9 @@ func ExploreDatasets(ctx *context.Context) { Keyword: keyword, IncludePublic: true, SearchOrderBy: orderBy, + Category: category, + Task: task, + License: license, OwnerID: ownerID, ListOptions: models.ListOptions{ Page: page, @@ -335,6 +341,9 @@ func ExploreDatasets(ctx *context.Context) { pager := context.NewPagination(int(count), opts.PageSize, page, 5) ctx.Data["Keyword"] = opts.Keyword + ctx.Data["Category"] = category + ctx.Data["Task"] = task + ctx.Data["License"] = license pager.SetDefaultParams(ctx) ctx.Data["Page"] = pager diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index 13ce62aa9..481d0900b 100755 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -15,6 +15,8 @@ import ( "strconv" "strings" + "code.gitea.io/gitea/modules/base" + "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/labelmsg" @@ -30,8 +32,9 @@ import ( const ( //result of decompress - DecompressSuccess = "0" - DecompressFailed = "1" + DecompressSuccess = "0" + DecompressFailed = "1" + tplAttachmentUpload base.TplName = "repo/attachment/upload" ) type CloudBrainDataset struct { @@ -63,6 +66,12 @@ func renderAttachmentSettings(ctx *context.Context) { ctx.Data["AttachmentMaxFiles"] = setting.Attachment.MaxFiles } +func UploadAttachmentUI(ctx *context.Context) { + ctx.Data["datasetId"] = ctx.Query("datasetId") + ctx.HTML(200, tplAttachmentUpload) + +} + // UploadAttachment response for uploading issue's attachment func UploadAttachment(ctx *context.Context) { if !setting.Attachment.Enabled { @@ -836,22 +845,23 @@ func CompleteMultipart(ctx *context.Context) { ctx.Error(500, fmt.Sprintf("UpdateFileChunk: %v", err)) return } - + dataset, _ := models.GetDatasetByID(ctx.QueryInt64("dataset_id")) attachment, err := models.InsertAttachment(&models.Attachment{ - UUID: uuid, - UploaderID: ctx.User.ID, - IsPrivate: true, - Name: fileName, - Size: ctx.QueryInt64("size"), - DatasetID: ctx.QueryInt64("dataset_id"), - Type: typeCloudBrain, + UUID: uuid, + UploaderID: ctx.User.ID, + IsPrivate: dataset.IsPrivate(), + Name: fileName, + Size: ctx.QueryInt64("size"), + DatasetID: ctx.QueryInt64("dataset_id"), + Description: ctx.Query("description"), + Type: typeCloudBrain, }) if err != nil { ctx.Error(500, fmt.Sprintf("InsertAttachment: %v", err)) return } - dataset, _ := models.GetDatasetByID(attachment.DatasetID) + repository, _ := models.GetRepositoryByID(dataset.RepoID) notification.NotifyOtherTask(ctx.User, repository, fmt.Sprint(attachment.Type), attachment.Name, models.ActionUploadAttachment) diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index 8ad83654b..413ec6951 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -91,21 +91,11 @@ func QueryDataSet(ctx *context.Context) []*models.Attachment { attachments := newFilterPrivateAttachments(ctx, dataset.Attachments, repo) ctx.Data["SortType"] = ctx.Query("sort") - switch ctx.Query("sort") { - case "newest": - sort.Slice(attachments, func(i, j int) bool { - return attachments[i].CreatedUnix > attachments[j].CreatedUnix - }) - case "oldest": - sort.Slice(attachments, func(i, j int) bool { - return attachments[i].CreatedUnix < attachments[j].CreatedUnix - }) - default: - ctx.Data["SortType"] = "newest" - sort.Slice(attachments, func(i, j int) bool { - return attachments[i].CreatedUnix > attachments[j].CreatedUnix - }) - } + + sort.Slice(attachments, func(i, j int) bool { + return attachments[i].CreatedUnix > attachments[j].CreatedUnix + }) + return attachments } @@ -121,13 +111,12 @@ func DatasetIndex(ctx *context.Context) { ctx.HTML(200, tplIndex) return } + cloudbrainType := -1 + if ctx.Query("type") != "" { - if ctx.Query("type") == "" { - log.Error("query dataset, not found param type") - ctx.NotFound("type error", nil) - return + cloudbrainType = ctx.QueryInt("type") } - err = models.GetDatasetAttachments(ctx.QueryInt("type"), ctx.IsSigned, ctx.User, dataset) + err = models.GetDatasetAttachments(cloudbrainType, ctx.IsSigned, ctx.User, dataset) if err != nil { ctx.ServerError("GetDatasetAttachments", err) return @@ -135,37 +124,52 @@ func DatasetIndex(ctx *context.Context) { attachments := newFilterPrivateAttachments(ctx, dataset.Attachments, repo) - ctx.Data["SortType"] = ctx.Query("sort") - switch ctx.Query("sort") { - case "newest": - sort.Slice(attachments, func(i, j int) bool { - return attachments[i].CreatedUnix > attachments[j].CreatedUnix - }) - case "oldest": - sort.Slice(attachments, func(i, j int) bool { - return attachments[i].CreatedUnix < attachments[j].CreatedUnix - }) - default: - ctx.Data["SortType"] = "newest" - sort.Slice(attachments, func(i, j int) bool { - return attachments[i].CreatedUnix > attachments[j].CreatedUnix - }) + sort.Slice(attachments, func(i, j int) bool { + return attachments[i].CreatedUnix > attachments[j].CreatedUnix + }) + + page := ctx.QueryInt("page") + if page <= 0 { + page = 1 + } + pagesize := ctx.QueryInt("pagesize") + if pagesize <= 0 { + pagesize = setting.UI.ExplorePagingNum } + pager := context.NewPagination(len(attachments), pagesize, page, 5) + pageAttachments := getPageAttachments(attachments, page, pagesize) + + ctx.Data["Page"] = pager ctx.Data["PageIsDataset"] = true ctx.Data["Title"] = ctx.Tr("dataset.show_dataset") ctx.Data["Link"] = ctx.Repo.RepoLink + "/datasets" ctx.Data["dataset"] = dataset - ctx.Data["Attachments"] = attachments + ctx.Data["Attachments"] = pageAttachments ctx.Data["IsOwner"] = true ctx.Data["StoreType"] = setting.Attachment.StoreType - ctx.Data["Type"] = ctx.QueryInt("type") + ctx.Data["Type"] = cloudbrainType renderAttachmentSettings(ctx) ctx.HTML(200, tplIndex) } +func getPageAttachments(attachments []*models.Attachment, page int, pagesize int) []*models.Attachment { + begin := (page - 1) * pagesize + end := (page) * pagesize + + if begin > len(attachments)-1 { + return nil + } + if end > len(attachments)-1 { + return attachments[begin:] + } else { + return attachments[begin:end] + } + +} + func CreateDataset(ctx *context.Context) { MustEnableDataset(ctx) diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 50da9ad23..c260ca686 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -586,6 +586,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Post("/delete", repo.DeleteAttachment) m.Get("/get_pre_url", repo.GetPresignedPutObjectURL) m.Post("/add", repo.AddAttachment) + m.Get("/upload", repo.UploadAttachmentUI) m.Post("/private", repo.UpdatePublicAttachment) m.Get("/get_chunks", repo.GetSuccessChunks) m.Get("/new_multipart", repo.NewMultipart) From aa1347a63359c469f79f9f923b1c4cb327c99023 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Fri, 4 Mar 2022 15:35:19 +0800 Subject: [PATCH 006/109] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/repo/dataset.go | 16 ++++++++++++++++ routers/routes/routes.go | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index 413ec6951..c3f4de52a 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -18,6 +18,7 @@ import ( const ( tplIndex base.TplName = "repo/datasets/index" tplDatasetCreate base.TplName = "repo/datasets/create" + tplDatasetEdit base.TplName = "repo/datasets/edit" ) var titlePattern = regexp.MustCompile(`^[A-Za-z0-9-_\\.]{1,100}$`) @@ -177,6 +178,21 @@ func CreateDataset(ctx *context.Context) { ctx.HTML(200, tplDatasetCreate) } +func EditDataset(ctx *context.Context) { + + MustEnableDataset(ctx) + datasetId, _ := strconv.ParseInt(ctx.Params(":id"), 10, 64) + + dataset, _ := models.GetDatasetByID(datasetId) + if dataset == nil { + ctx.Error(http.StatusNotFound, "") + return + } + ctx.Data["Dataset"] = dataset + + ctx.HTML(200, tplDatasetEdit) +} + func CreateDatasetPost(ctx *context.Context, form auth.CreateDatasetForm) { dataset := &models.Dataset{} diff --git a/routers/routes/routes.go b/routers/routes/routes.go index c260ca686..1bf80ec82 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -982,8 +982,8 @@ func RegisterRoutes(m *macaron.Macaron) { m.Put("/:id/:action", reqRepoDatasetReader, repo.DatasetAction) m.Get("/create", reqRepoDatasetWriter, repo.CreateDataset) m.Post("/create", reqRepoDatasetWriter, bindIgnErr(auth.CreateDatasetForm{}), repo.CreateDatasetPost) - - m.Post("", reqRepoDatasetWriter, bindIgnErr(auth.EditDatasetForm{}), repo.EditDatasetPost) + m.Get("/edit/:id", reqRepoDatasetWriter, repo.EditDataset) + m.Post("/edit", reqRepoDatasetWriter, bindIgnErr(auth.EditDatasetForm{}), repo.EditDatasetPost) m.Group("/dirs", func() { m.Get("/:uuid", reqRepoDatasetReader, repo.DirIndex) From 6077d4fe6521740413ad22c142b5dda564a2c2df Mon Sep 17 00:00:00 2001 From: liuzx Date: Tue, 8 Mar 2022 11:13:18 +0800 Subject: [PATCH 007/109] update --- models/attachment.go | 82 ++++++++++++++++++++++++ routers/repo/dataset.go | 34 ++++++++++ routers/routes/routes.go | 4 +- templates/repo/datasets/tasks/index.tmpl | 0 4 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 templates/repo/datasets/tasks/index.tmpl diff --git a/models/attachment.go b/models/attachment.go index af7cafe53..d482a9018 100755 --- a/models/attachment.go +++ b/models/attachment.go @@ -18,6 +18,7 @@ import ( "code.gitea.io/gitea/modules/timeutil" gouuid "github.com/satori/go.uuid" + "xorm.io/builder" "xorm.io/xorm" ) @@ -55,6 +56,19 @@ type AttachmentUsername struct { Name string } +type AttachmentInfo struct { + Attachment `xorm:"extends"` + Repo *Repository `xorm:"extends"` +} + +type AttachmentsOptions struct { + ListOptions + DatasetID int8 + DecompressState int + Type int + NeedRepoInfo bool +} + func (a *Attachment) AfterUpdate() { if a.DatasetID > 0 { datasetIsPublicCount, err := x.Where("dataset_id = ? AND is_private = ?", a.DatasetID, false).Count(new(Attachment)) @@ -504,3 +518,71 @@ func GetAttachmentSizeByDatasetID(datasetID int64) (int64, error) { func GetAllAttachmentSize() (int64, error) { return x.SumInt(&Attachment{}, "size") } + +func Attachments(opts *AttachmentsOptions) ([]*AttachmentInfo, int64, error) { + sess := x.NewSession() + defer sess.Close() + + var cond = builder.NewCond() + if opts.DatasetID > 0 { + cond = cond.And( + builder.Eq{"attachment.dataset_id": opts.DatasetID}, + ) + } + + if opts.DecompressState > 0 { + cond = cond.And( + builder.Eq{"attachment.decompress_state": opts.DecompressState}, + ) + } + + if (opts.Type) >= 0 { + cond = cond.And( + builder.Eq{"cloudbrain.type": opts.Type}, + ) + } + + var count int64 + var err error + if opts.DatasetID > 0 { + count, err = sess.Where(cond).Count(new(Attachment)) + } + + if err != nil { + return nil, 0, fmt.Errorf("Count: %v", err) + } + + if opts.Page >= 0 && opts.PageSize > 0 { + var start int + if opts.Page == 0 { + start = 0 + } else { + start = (opts.Page - 1) * opts.PageSize + } + sess.Limit(opts.PageSize, start) + } + + sess.OrderBy("attachment.created_unix DESC") + attachments := make([]*AttachmentInfo, 0, setting.UI.IssuePagingNum) + if err := sess.Table(&Attachment{}).Where(cond). + Find(&attachments); err != nil { + return nil, 0, fmt.Errorf("Find: %v", err) + } + + if opts.NeedRepoInfo { + for _, attachment := range attachments { + dataset, err := GetDatasetByID(attachment.DatasetID) + if err != nil { + return nil, 0, fmt.Errorf("GetDatasetByID failed error: %v", err) + } + repo, err := GetRepositoryByID(dataset.RepoID) + if err == nil { + attachment.Repo = repo + } else { + return nil, 0, fmt.Errorf("GetRepositoryByID failed error: %v", err) + } + } + } + + return attachments, count, nil +} diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index c3f4de52a..7b3625d49 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -1,6 +1,7 @@ package repo import ( + "encoding/json" "net/http" "regexp" "sort" @@ -19,6 +20,7 @@ const ( tplIndex base.TplName = "repo/datasets/index" tplDatasetCreate base.TplName = "repo/datasets/create" tplDatasetEdit base.TplName = "repo/datasets/edit" + taskstplIndex base.TplName = "repo/datasets/tasks/index" ) var titlePattern = regexp.MustCompile(`^[A-Za-z0-9-_\\.]{1,100}$`) @@ -280,3 +282,35 @@ func DatasetAction(ctx *context.Context) { } } + +func TasksDatasetIndex(ctx *context.Context) { + page := ctx.QueryInt("page") + // repo := ctx.Repo.Repository + + datasets, count, err := models.Attachments(&models.AttachmentsOptions{ + ListOptions: models.ListOptions{ + Page: page, + PageSize: setting.UI.IssuePagingNum, + }, + Type: models.TypeCloudBrainTwo, + }) + if err != nil { + ctx.ServerError("datasets", err) + return + } + + data, err := json.Marshal(datasets) + if err != nil { + log.Error("json.Marshal failed:", err.Error()) + ctx.JSON(200, map[string]string{ + "result_code": "-1", + "error_msg": err.Error(), + "data": "", + }) + return + } + ctx.JSON(200, map[string]string{ + "data": string(data), + "count": strconv.FormatInt(count, 10), + }) +} diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 1bf80ec82..84d01cdb1 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -6,13 +6,14 @@ package routes import ( "bytes" - "code.gitea.io/gitea/routers/authentication" "encoding/gob" "net/http" "path" "text/template" "time" + "code.gitea.io/gitea/routers/authentication" + "code.gitea.io/gitea/modules/cloudbrain" "code.gitea.io/gitea/routers/operation" @@ -984,6 +985,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Post("/create", reqRepoDatasetWriter, bindIgnErr(auth.CreateDatasetForm{}), repo.CreateDatasetPost) m.Get("/edit/:id", reqRepoDatasetWriter, repo.EditDataset) m.Post("/edit", reqRepoDatasetWriter, bindIgnErr(auth.EditDatasetForm{}), repo.EditDatasetPost) + m.Get("/tasks", reqRepoDatasetReader, repo.TasksDatasetIndex) m.Group("/dirs", func() { m.Get("/:uuid", reqRepoDatasetReader, repo.DirIndex) diff --git a/templates/repo/datasets/tasks/index.tmpl b/templates/repo/datasets/tasks/index.tmpl new file mode 100644 index 000000000..e69de29bb From 5737eac68213a31b54828873987845780f199f5a Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Tue, 8 Mar 2022 11:30:42 +0800 Subject: [PATCH 008/109] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E5=B9=BF?= =?UTF-8?q?=E5=9C=BA=E6=90=9C=E7=B4=A2=E6=94=AF=E6=8C=81=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/dataset.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/dataset.go b/models/dataset.go index efc610630..096ab291c 100755 --- a/models/dataset.go +++ b/models/dataset.go @@ -118,7 +118,7 @@ func SearchDatasetCondition(opts *SearchDatasetOptions) builder.Cond { cond = cond.And(builder.Neq{"dataset.status": DatasetStatusDeleted}) if len(opts.Keyword) > 0 { - cond = cond.And(builder.Like{"dataset.title", opts.Keyword}) + cond = cond.And(builder.Or(builder.Like{"dataset.title", opts.Keyword}, builder.Like{"dataset.description", opts.Keyword})) } if len(opts.Category) > 0 { @@ -144,7 +144,7 @@ func SearchDatasetCondition(opts *SearchDatasetOptions) builder.Cond { cond = cond.Or(builder.Eq{"repository.owner_id": opts.OwnerID}) } else { subCon := builder.NewCond() - subCon = subCon.And(builder.Eq{"repository.owner_id": opts.OwnerID}, builder.Like{"dataset.title", opts.Keyword}) + subCon = subCon.And(builder.Eq{"repository.owner_id": opts.OwnerID}, builder.Or(builder.Like{"dataset.title", opts.Keyword}, builder.Like{"dataset.description", opts.Keyword})) cond = cond.Or(subCon) } From bfdd694ad225236ace0a82a231cfe89c304b3c0a Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Tue, 8 Mar 2022 16:06:48 +0800 Subject: [PATCH 009/109] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E5=88=9B=E5=BB=BA=E5=A4=9A=E4=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/dataset.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/models/dataset.go b/models/dataset.go index 096ab291c..e5b252ce6 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) { From ce1ff8e795151611582108b8930bdcd8cfcaef9e Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Tue, 8 Mar 2022 17:12:50 +0800 Subject: [PATCH 010/109] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/repo/attachment.go | 6 ++++++ 1 file changed, 6 insertions(+) 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) } From 4d7323930eee1a670792902bbb160bbb1b64f507 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Tue, 8 Mar 2022 17:57:50 +0800 Subject: [PATCH 011/109] fix issue --- templates/repo/attachment/upload.tmpl | 98 +++++++++ templates/repo/datasets/create.tmpl | 65 ++++++ templates/repo/datasets/index.tmpl | 257 ++++++++++++------------ web_src/js/components/MinioUploader.vue | 122 +++++++---- web_src/js/components/ObsUploader.vue | 5 +- web_src/js/index.js | 96 +++++++++ web_src/less/openi.less | 4 + 7 files changed, 472 insertions(+), 175 deletions(-) create mode 100644 templates/repo/attachment/upload.tmpl create mode 100644 templates/repo/datasets/create.tmpl 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"}} -
-
-
- {{.dataset.Title}} - {{.dataset.Category}} - {{.dataset.License}} + {{if .dataset.Title}} + {{.dataset.Title}} + {{end}} + {{if .dataset.Category}} + {{.dataset.Category}} + {{end}} + {{if .dataset.License}} + {{.dataset.License}} + {{end}}
From fbe28851c1688912fee75b0637a5b09eafefb4ce Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Wed, 9 Mar 2022 09:27:13 +0800 Subject: [PATCH 014/109] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/repo/attachment.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index 96cce5cd0..8254ccc67 100755 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -814,6 +814,9 @@ func CompleteMultipart(ctx *context.Context) { typeCloudBrain := ctx.QueryInt("type") fileName := ctx.Query("file_name") + log.Warn("uuid:" + uuid) + log.Warn("typeCloudBrain:" + strconv.Itoa(typeCloudBrain)) + err := checkTypeCloudBrain(typeCloudBrain) if err != nil { ctx.ServerError("checkTypeCloudBrain failed", err) @@ -852,6 +855,7 @@ func CompleteMultipart(ctx *context.Context) { return } dataset, _ := models.GetDatasetByID(ctx.QueryInt64("dataset_id")) + log.Warn("insert attachment to datasetId:" + strconv.FormatInt(dataset.ID, 10)) attachment, err := models.InsertAttachment(&models.Attachment{ UUID: uuid, UploaderID: ctx.User.ID, From e3004c488c30a40e85a46839baf6c359df47017b Mon Sep 17 00:00:00 2001 From: liuzx Date: Wed, 9 Mar 2022 17:04:12 +0800 Subject: [PATCH 015/109] fix-bug --- models/attachment.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/models/attachment.go b/models/attachment.go index 5179c0170..6214567ef 100755 --- a/models/attachment.go +++ b/models/attachment.go @@ -9,6 +9,7 @@ import ( "fmt" "io" "path" + "strings" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/obs" @@ -70,6 +71,7 @@ type AttachmentsOptions struct { NeedIsPrivate bool IsPrivate bool NeedRepoInfo bool + Keyword string } func (a *Attachment) AfterUpdate() { @@ -554,8 +556,14 @@ func Attachments(opts *AttachmentsOptions) ([]*AttachmentInfo, int64, error) { var count int64 var err error - if (opts.Type) >= 0 { + if len(opts.Keyword) == 0 { count, err = sess.Where(cond).Count(new(Attachment)) + } else { + lowerKeyWord := strings.ToLower(opts.Keyword) + + cond = cond.And(builder.Or(builder.Like{"LOWER(attachment.name)", lowerKeyWord})) + count, err = sess.Table(&Attachment{}).Where(cond).Count(new(AttachmentInfo)) + } if err != nil { From 8497e5b0591350eae0e5c7ab1a3274aa805f0abb Mon Sep 17 00:00:00 2001 From: liuzx Date: Thu, 10 Mar 2022 09:31:53 +0800 Subject: [PATCH 016/109] fix-bug --- routers/repo/dataset.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index d4e12ab8f..e73a942f8 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -6,6 +6,7 @@ import ( "regexp" "sort" "strconv" + "strings" "unicode/utf8" "code.gitea.io/gitea/models" @@ -286,6 +287,8 @@ func DatasetAction(ctx *context.Context) { func CurrentRepoDataset(ctx *context.Context) { page := ctx.QueryInt("page") cloudbrainType := ctx.QueryInt("type") + keyword := strings.Trim(ctx.Query("search"), " ") + repo := ctx.Repo.Repository var datasetIDs []int64 dataset, err := models.GetDatasetByRepo(repo) @@ -299,6 +302,7 @@ func CurrentRepoDataset(ctx *context.Context) { Page: page, PageSize: setting.UI.IssuePagingNum, }, + Keyword: keyword, DatasetIDs: datasetIDs, UploaderID: uploaderID, Type: cloudbrainType, @@ -329,6 +333,7 @@ func CurrentRepoDataset(ctx *context.Context) { func MyDataset(ctx *context.Context) { page := ctx.QueryInt("page") cloudbrainType := ctx.QueryInt("type") + keyword := strings.Trim(ctx.Query("search"), " ") uploaderID := ctx.User.ID datasets, count, err := models.Attachments(&models.AttachmentsOptions{ @@ -336,6 +341,7 @@ func MyDataset(ctx *context.Context) { Page: page, PageSize: setting.UI.IssuePagingNum, }, + Keyword: keyword, UploaderID: uploaderID, Type: cloudbrainType, NeedIsPrivate: false, @@ -365,12 +371,14 @@ func MyDataset(ctx *context.Context) { func PublicDataset(ctx *context.Context) { page := ctx.QueryInt("page") cloudbrainType := ctx.QueryInt("type") + keyword := strings.Trim(ctx.Query("search"), " ") datasets, count, err := models.Attachments(&models.AttachmentsOptions{ ListOptions: models.ListOptions{ Page: page, PageSize: setting.UI.IssuePagingNum, }, + Keyword: keyword, NeedIsPrivate: true, IsPrivate: false, Type: cloudbrainType, @@ -400,6 +408,7 @@ func PublicDataset(ctx *context.Context) { func MyFavoriteDataset(ctx *context.Context) { page := ctx.QueryInt("page") cloudbrainType := ctx.QueryInt("type") + keyword := strings.Trim(ctx.Query("search"), " ") var datasetIDs []int64 @@ -416,6 +425,7 @@ func MyFavoriteDataset(ctx *context.Context) { Page: page, PageSize: setting.UI.IssuePagingNum, }, + Keyword: keyword, DatasetIDs: datasetIDs, NeedIsPrivate: true, IsPrivate: false, From 1ad707670f5de54eadd9197ff614221b1f555dc2 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Thu, 10 Mar 2022 10:10:30 +0800 Subject: [PATCH 017/109] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/repo/dataset.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index e73a942f8..9c3efb3a4 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -138,7 +138,7 @@ func DatasetIndex(ctx *context.Context) { } pagesize := ctx.QueryInt("pagesize") if pagesize <= 0 { - pagesize = setting.UI.ExplorePagingNum + pagesize = 10 } pager := context.NewPagination(len(attachments), pagesize, page, 5) From c7eb80ac3681e1d23196670ff6b5a594e08e50e8 Mon Sep 17 00:00:00 2001 From: liuzx Date: Thu, 10 Mar 2022 15:25:10 +0800 Subject: [PATCH 018/109] fix bug --- routers/repo/dataset.go | 10 +++++----- routers/routes/routes.go | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index 9c3efb3a4..5ef9f30bf 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -287,7 +287,7 @@ func DatasetAction(ctx *context.Context) { func CurrentRepoDataset(ctx *context.Context) { page := ctx.QueryInt("page") cloudbrainType := ctx.QueryInt("type") - keyword := strings.Trim(ctx.Query("search"), " ") + keyword := strings.Trim(ctx.Query("q"), " ") repo := ctx.Repo.Repository var datasetIDs []int64 @@ -330,10 +330,10 @@ func CurrentRepoDataset(ctx *context.Context) { }) } -func MyDataset(ctx *context.Context) { +func MyDatasets(ctx *context.Context) { page := ctx.QueryInt("page") cloudbrainType := ctx.QueryInt("type") - keyword := strings.Trim(ctx.Query("search"), " ") + keyword := strings.Trim(ctx.Query("q"), " ") uploaderID := ctx.User.ID datasets, count, err := models.Attachments(&models.AttachmentsOptions{ @@ -371,7 +371,7 @@ func MyDataset(ctx *context.Context) { func PublicDataset(ctx *context.Context) { page := ctx.QueryInt("page") cloudbrainType := ctx.QueryInt("type") - keyword := strings.Trim(ctx.Query("search"), " ") + keyword := strings.Trim(ctx.Query("q"), " ") datasets, count, err := models.Attachments(&models.AttachmentsOptions{ ListOptions: models.ListOptions{ @@ -408,7 +408,7 @@ func PublicDataset(ctx *context.Context) { func MyFavoriteDataset(ctx *context.Context) { page := ctx.QueryInt("page") cloudbrainType := ctx.QueryInt("type") - keyword := strings.Trim(ctx.Query("search"), " ") + keyword := strings.Trim(ctx.Query("q"), " ") var datasetIDs []int64 diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 8c03824e3..a7b7c61d7 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -986,7 +986,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Get("/edit/:id", reqRepoDatasetWriter, repo.EditDataset) m.Post("/edit", reqRepoDatasetWriter, bindIgnErr(auth.EditDatasetForm{}), repo.EditDatasetPost) m.Get("/current_repo", reqRepoDatasetReader, repo.CurrentRepoDataset) - m.Get("/my_datasets", reqRepoDatasetReader, repo.MyDataset) + m.Get("/my_datasets", reqRepoDatasetReader, repo.MyDatasets) m.Get("/public_datasets", reqRepoDatasetReader, repo.PublicDataset) m.Get("/my_favorite", reqRepoDatasetReader, repo.MyFavoriteDataset) From c6f56a7226fb0be5299f016cac4e162bbf93f83e Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Thu, 10 Mar 2022 16:23:47 +0800 Subject: [PATCH 019/109] fix issue --- templates/repo/datasets/create.tmpl | 4 +- templates/repo/datasets/edit.tmpl | 72 ++++++++++++ templates/repo/datasets/index.tmpl | 164 +++++++++++++++++++++++++++- web_src/js/index.js | 101 ++++++++++++++++- 4 files changed, 330 insertions(+), 11 deletions(-) create mode 100644 templates/repo/datasets/edit.tmpl diff --git a/templates/repo/datasets/create.tmpl b/templates/repo/datasets/create.tmpl index ea935c345..e7a2a4f8e 100644 --- a/templates/repo/datasets/create.tmpl +++ b/templates/repo/datasets/create.tmpl @@ -54,12 +54,12 @@ 确定 - 取消 + 取消
-
+
{{template "base/footer" .}} diff --git a/templates/repo/datasets/edit.tmpl b/templates/repo/datasets/edit.tmpl new file mode 100644 index 000000000..d44e8765c --- /dev/null +++ b/templates/repo/datasets/edit.tmpl @@ -0,0 +1,72 @@ + +
+
+
+
+
+
+
+
+
+{{template "base/head" .}} +
+ {{template "repo/header" .}} +
+ +
+

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

+ + +
+
+ + {{.CsrfTokenHtml}} + + + 请输入字母、数字、_和-,最长64个字符,且不能以中划线(-)结尾。 + + + + + + + + + + + + + + + + + + + + + + + + + 确定 + 取消 + + +
+
+
+
+
+{{template "base/footer" .}} + \ No newline at end of file diff --git a/templates/repo/datasets/index.tmpl b/templates/repo/datasets/index.tmpl index 289e6525a..73f153c04 100755 --- a/templates/repo/datasets/index.tmpl +++ b/templates/repo/datasets/index.tmpl @@ -6,6 +6,14 @@ margin: -1px; background: #FFF !important; } + +.dataset_title{ + font-size: 14px; + max-width: 80%; + display: inline-block !important; + margin-left: 6px !important; + padding-right: 0 !important; +} .wrapper { display: flex; overflow: hidden; @@ -76,10 +84,26 @@ color: #333; transform: translateX(-100%) } + + .el-button--text{color:#0366d6 ;} + .heart-stroke{ + stroke: #666; + stroke-width: 2; + fill: #fff + } + .stars_active{ + fill: #FA8C16 !important; + }
{{template "repo/header" .}} {{if .dataset}} + +
@@ -87,11 +111,12 @@

{{.dataset.Title}}

-
+
-
- {{.dataset.NumStars}} - 修改 + +
+ + 修改
@@ -130,10 +155,122 @@ 上传
+
+
+
+
+ +
+ 文件名称 +
+
+ 大小 +
+
+ 存储位置 +
+
+ 状态 +
+
+ 创建者 +
+
+ 上传时间 +
+
+ 操作 +
+
+
+ {{range $k, $v :=.dataset.Attachments}} +
+
+ + + +
+ {{.Size | FileSize}} +
+
+ {{.Type}} +
+
+ {{.IsPrivate}} +
+
+ 创建者 +
+
+ {{.CreatedUnix | TimeSinceUnix1}} +
+ +
+
+ {{end}} + +
+ +
+
- +
+
+ + +
+
{{else}}
@@ -146,8 +283,25 @@
{{end}}
+ + {{template "base/footer" .}} \ No newline at end of file diff --git a/web_src/js/index.js b/web_src/js/index.js index 0663cb3f2..fdcc617c2 100755 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -43,7 +43,7 @@ import Contributors from './components/Contributors.vue' import Model from './components/Model.vue'; import WxAutorize from './components/WxAutorize.vue' import initCloudrain from './features/cloudrbanin.js' - +// import $ from 'jquery.js' Vue.use(ElementUI); Vue.prototype.$axios = axios; @@ -3664,6 +3664,11 @@ function initVueDataset() { if (!el) { return; } + const items = [] + $('#dataset-range-value').find('.item').each(function(){ + items.push($(this).data('private')) + }) + let num_stars = $('#dataset-range-value').data('num-stars') new Vue({ delimiters: ['${', '}'], el, @@ -3673,13 +3678,17 @@ function initVueDataset() { type:0, desc:'', datasetType:'全部', + privates:[], + star_active:false, + num_stars:0, ruleForm:{ title:'', description:'', category:'', task:'', license:'', - _csrf:csrf + _csrf:csrf, + id:'', }, rules: { title: [ @@ -3716,6 +3725,10 @@ function initVueDataset() { if(document.getElementById('postPath')){ this.url = document.getElementById('postPath').value } + this.privates = items + this.num_stars = num_stars + this.getEditInit() + }, methods:{ createDataset(formName){ @@ -3730,6 +3743,9 @@ function initVueDataset() { }else{ console.log(res.data.Message) } + document.getElementById("mask").style.display = "none" + }).catch(error=>{ + console.log(error) }) } else{ @@ -3737,8 +3753,15 @@ function initVueDataset() { } }) }, - cancelDataset(){ - location.href = this.url.split('/create')[0]+'?type=-1' + cancelDataset(getpage){ + if(getpage==='create'){ + location.href = this.url.split('/create')[0]+'?type=-1' + }else if(getpage==='edit'){ + location.href = this.url.split('/edit')[0]+'?type=-1' + }else{ + location.href='/' + } + }, gotoUpload(datsetId){ location.href = `${AppSubUrl}/attachments/upload?datasetId=${datsetId}` @@ -3748,8 +3771,78 @@ function initVueDataset() { }, uploadNpu(){ this.type=1 + }, + setPrivate(uuid,privateFlag,index){ + const params = {_csrf:csrf,file:uuid,is_private:privateFlag} + this.$axios.post('/attachments/private',this.qs.stringify(params)).then((res)=>{ + console.log(res) + this.$set(this.privates,index,privateFlag) + }).catch(error=>{ + console.log(error) + }) + }, + delDataset(uuid){ + let _this = this + const params = {_csrf:csrf,file:uuid} + $('#data-dataset-delete-modal') + .modal({ + closable: false, + onApprove() { + _this.$axios.post('/attachments/delete',_this.qs.stringify(params)).then((res)=>{ + console.log(res) + $('#'+uuid).hide() + }).catch(error=>{ + console.log(error) + }) + } + }) + .modal('show'); + }, + getEditInit(){ + console.log(this.ruleForm) + if($('#dataset-edit-value')){ + console.log("==========") + let $this = $('#dataset-edit-value') + this.ruleForm.title = $this.data('edit-title') || '' + this.ruleForm.description = $this.data('edit-description') || '' + this.ruleForm.category = $this.data('edit-category') || '' + this.ruleForm.task = $this.data('edit-task') || '' + this.ruleForm.license = $this.data('edit-license') || '' + this.ruleForm.id = $this.data('edit-id') || '' + } + console.log(this.ruleForm) + }, + editDataset(formName,id){ + let _this = this + console.log(this.url) + this.url = this.url.split(`/${id}`)[0] + console.log(this.url) + this.$refs[formName].validate((valid)=>{ + if(valid){ + document.getElementById("mask").style.display = "block" + _this.$axios.post(_this.url,_this.qs.stringify(_this.ruleForm)).then((res)=>{ + if(res.data.Code===0){ + document.getElementById("mask").style.display = "none" + location.href = _this.url.split('/edit')[0]+'?type=-1' + }else{ + console.log(res.data.Message) + } + document.getElementById("mask").style.display = "none" + }).catch((err)=>{ + console.log(err) + }) + } + else{ + return false + } + }) + + }, + postStar(id,link){ + console.log(id,link) } + } }); From 8cf36fcc3173bc543beb0e1c97e87dbcbd8141c1 Mon Sep 17 00:00:00 2001 From: liuzx Date: Thu, 10 Mar 2022 16:30:45 +0800 Subject: [PATCH 020/109] fix-bug --- routers/repo/dataset.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index 5ef9f30bf..3f5209918 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -325,8 +325,9 @@ func CurrentRepoDataset(ctx *context.Context) { return } ctx.JSON(200, map[string]string{ - "data": string(data), - "count": strconv.FormatInt(count, 10), + "result_code": "0", + "data": string(data), + "count": strconv.FormatInt(count, 10), }) } @@ -363,8 +364,9 @@ func MyDatasets(ctx *context.Context) { return } ctx.JSON(200, map[string]string{ - "data": string(data), - "count": strconv.FormatInt(count, 10), + "result_code": "0", + "data": string(data), + "count": strconv.FormatInt(count, 10), }) } @@ -400,8 +402,9 @@ func PublicDataset(ctx *context.Context) { return } ctx.JSON(200, map[string]string{ - "data": string(data), - "count": strconv.FormatInt(count, 10), + "result_code": "0", + "data": string(data), + "count": strconv.FormatInt(count, 10), }) } @@ -448,7 +451,8 @@ func MyFavoriteDataset(ctx *context.Context) { return } ctx.JSON(200, map[string]string{ - "data": string(data), - "count": strconv.FormatInt(count, 10), + "result_code": "0", + "data": string(data), + "count": strconv.FormatInt(count, 10), }) } From 915b3a6d94a294906628be64e33a7b95d732d67e Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Thu, 10 Mar 2022 17:12:38 +0800 Subject: [PATCH 021/109] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/dataset_star.go | 9 ++++++--- modules/context/repo.go | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/models/dataset_star.go b/models/dataset_star.go index fac08caee..5dedb2ba4 100644 --- a/models/dataset_star.go +++ b/models/dataset_star.go @@ -51,9 +51,12 @@ func StarDataset(userID, datasetID int64, star bool) error { return sess.Commit() } -func IsDatasetStaring(userID, datasetID int64) bool { - - return isDatasetStaring(x, userID, datasetID) +func IsDatasetStaringByRepoId(userID, repoID int64) bool { + dataset, _ := GetDatasetByRepo(&Repository{ID: repoID}) + if dataset == nil { + return false + } + return isDatasetStaring(x, userID, dataset.ID) } func isDatasetStaring(e Engine, userID, datasetID int64) bool { diff --git a/modules/context/repo.go b/modules/context/repo.go index 64f02c921..7c425c8c0 100755 --- a/modules/context/repo.go +++ b/modules/context/repo.go @@ -475,6 +475,8 @@ func RepoAssignment() macaron.Handler { if ctx.IsSigned { ctx.Data["IsWatchingRepo"] = models.IsWatching(ctx.User.ID, repo.ID) ctx.Data["IsStaringRepo"] = models.IsStaring(ctx.User.ID, repo.ID) + + ctx.Data["IsStaringDataset"] = models.IsDatasetStaringByRepoId(ctx.User.ID, repo.ID) } if repo.IsFork { From 4786375ab93285bb79c38f32f809af9c770fa9f9 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Thu, 10 Mar 2022 17:34:32 +0800 Subject: [PATCH 022/109] fix issue --- web_src/js/index.js | 50 +++++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/web_src/js/index.js b/web_src/js/index.js index fdcc617c2..5c595b47a 100755 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -3669,6 +3669,28 @@ function initVueDataset() { items.push($(this).data('private')) }) let num_stars = $('#dataset-range-value').data('num-stars') + const ruleForm = {} + if(document.getElementById('dataset-edit-value')){ + let $this = $('#dataset-edit-value') + ruleForm.title = $this.data('edit-title') || '' + ruleForm.description = $this.data('edit-description') || '' + ruleForm.category = $this.data('edit-category') || '' + ruleForm.task = $this.data('edit-task') || '' + ruleForm.license = $this.data('edit-license') || '' + ruleForm.id = $this.data('edit-id')|| '' + } + console.log(ruleForm) + // getEditInit(){ + // if($('#dataset-edit-value')){ + // $this = $('#dataset-edit-value') + // this.ruleForm.title = $this.data('edit-title') || '' + // this.ruleForm.description = $this.data('edit-description') || '' + // this.ruleForm.category = $this.data('edit-category') || '' + // this.ruleForm.task = $this.data('edit-task') || '' + // this.ruleForm.license = $this.data('edit-license') || '' + // this.ruleForm.id = $this.data('edit-id')|| '' + // } + // }, new Vue({ delimiters: ['${', '}'], el, @@ -3727,7 +3749,8 @@ function initVueDataset() { } this.privates = items this.num_stars = num_stars - this.getEditInit() + this.ruleForm = ruleForm + // this.getEditInit() }, methods:{ @@ -3798,20 +3821,17 @@ function initVueDataset() { }) .modal('show'); }, - getEditInit(){ - console.log(this.ruleForm) - if($('#dataset-edit-value')){ - console.log("==========") - let $this = $('#dataset-edit-value') - this.ruleForm.title = $this.data('edit-title') || '' - this.ruleForm.description = $this.data('edit-description') || '' - this.ruleForm.category = $this.data('edit-category') || '' - this.ruleForm.task = $this.data('edit-task') || '' - this.ruleForm.license = $this.data('edit-license') || '' - this.ruleForm.id = $this.data('edit-id') || '' - } - console.log(this.ruleForm) - }, + // getEditInit(){ + // if($('#dataset-edit-value')){ + // $this = $('#dataset-edit-value') + // this.ruleForm.title = $this.data('edit-title') || '' + // this.ruleForm.description = $this.data('edit-description') || '' + // this.ruleForm.category = $this.data('edit-category') || '' + // this.ruleForm.task = $this.data('edit-task') || '' + // this.ruleForm.license = $this.data('edit-license') || '' + // this.ruleForm.id = $this.data('edit-id')|| '' + // } + // }, editDataset(formName,id){ let _this = this console.log(this.url) From 95b2613cdaa98210410ba8f93aa322a53dd58728 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Fri, 11 Mar 2022 10:00:26 +0800 Subject: [PATCH 023/109] fix issue --- templates/repo/datasets/edit.tmpl | 14 ++++----- templates/repo/datasets/index.tmpl | 14 +++++---- web_src/js/components/MinioUploader.vue | 20 +++++++----- web_src/js/index.js | 42 ++++++++++++++++++++++--- 4 files changed, 65 insertions(+), 25 deletions(-) diff --git a/templates/repo/datasets/edit.tmpl b/templates/repo/datasets/edit.tmpl index d44e8765c..d198d1666 100644 --- a/templates/repo/datasets/edit.tmpl +++ b/templates/repo/datasets/edit.tmpl @@ -28,36 +28,36 @@
- + {{.CsrfTokenHtml}} - + 请输入字母、数字、_和-,最长64个字符,且不能以中划线(-)结尾。 - + - + - + - + - 确定 + 确定 取消 diff --git a/templates/repo/datasets/index.tmpl b/templates/repo/datasets/index.tmpl index 73f153c04..656f22a75 100755 --- a/templates/repo/datasets/index.tmpl +++ b/templates/repo/datasets/index.tmpl @@ -93,12 +93,13 @@ } .stars_active{ fill: #FA8C16 !important; + stroke:#FA8C16 !important }
{{template "repo/header" .}} {{if .dataset}} - +
{{range .Tasks}}
- + -
- {{.ModelName}}  {{.ModelVersion}} +
+ {{.ModelName}}  {{.ModelVersion}}
@@ -126,12 +126,12 @@ {{TimeSinceUnix .Cloudbrain.CreatedUnix $.Lang}}
-
- {{.TrainJobDuration}} +
+ {{.TrainJobDuration}}
diff --git a/templates/repo/modelarts/trainjob/index.tmpl b/templates/repo/modelarts/trainjob/index.tmpl index ed94c0598..db077bebc 100755 --- a/templates/repo/modelarts/trainjob/index.tmpl +++ b/templates/repo/modelarts/trainjob/index.tmpl @@ -39,7 +39,7 @@
- {{if .Permission.CanWrite $.UnitTypeCloudBrain}} + {{if .Permission.CanWrite $.UnitTypeCloudBrain}} {{$.i18n.Tr "repo.modelarts.train_job.new_train"}} {{else}} {{$.i18n.Tr "repo.modelarts.train_job.new_train"}} @@ -49,13 +49,13 @@ {{if eq 0 (len .Tasks)}}
-
未创建过训练任务
+
{{$.i18n.Tr "repo.train_task_not_created"}}
{{if $.RepoIsEmpty}} -
代码版本:您还没有初始化代码仓库,请先创建代码版本;
+
{{$.i18n.Tr "repo.repo_not_initialized" .RepoLink | Safe}}
{{end}} -
数据集:云脑1提供 CPU / GPU 资源,云脑2提供 Ascend NPU 资源,调试使用的数据集也需要上传到对应的环境;
-
使用说明:可以参考启智AI协作平台小白训练营课程。
+
{{$.i18n.Tr "repo.dataset_desc"}}
+
{{$.i18n.Tr "repo.platform_instructions" | Safe}}
{{else}} @@ -85,31 +85,31 @@ {{$.i18n.Tr "repo.cloudbrain_status_runtime"}}
- {{$.i18n.Tr "repo.modelarts.computing_resources"}} + {{$.i18n.Tr "repo.modelarts.computing_resources"}}
- {{$.i18n.Tr "repo.cloudbrain_creator"}} + {{$.i18n.Tr "repo.cloudbrain_creator"}}
{{$.i18n.Tr "repo.cloudbrain_operate"}}
-
-
+
+
{{range .Tasks}}
- + -
- {{.VersionCount}} +
+ {{.VersionCount}}
@@ -122,12 +122,12 @@ {{TimeSinceUnix .Cloudbrain.CreatedUnix $.Lang}}
-
- {{.TrainJobDuration}} +
+ {{.TrainJobDuration}}
- {{.ComputeResource}} + {{.ComputeResource}}
@@ -205,4 +205,4 @@
-{{template "base/footer" .}} \ No newline at end of file +{{template "base/footer" .}} From f83103427757dd1733e60e934b0a56c3638afcee Mon Sep 17 00:00:00 2001 From: yanchao Date: Thu, 17 Mar 2022 15:23:54 +0800 Subject: [PATCH 040/109] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/home.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/home.go b/routers/home.go index 129c8a81c..f54125e5f 100755 --- a/routers/home.go +++ b/routers/home.go @@ -330,7 +330,7 @@ func ExploreDatasets(ctx *context.Context) { OwnerID: ownerID, ListOptions: models.ListOptions{ Page: page, - PageSize: setting.UI.ExplorePagingNum, + PageSize: 30, }, } From 5a36c1576fba2f0acd1af9e4492c1fb9f51da6be Mon Sep 17 00:00:00 2001 From: Gitea Date: Thu, 17 Mar 2022 15:52:33 +0800 Subject: [PATCH 041/109] fix issue --- templates/explore/dataset_left.tmpl | 32 ++++++++++--- templates/explore/datasets.tmpl | 61 ++++++++++++++++++++----- templates/repo/attachment/edit.tmpl | 9 ++-- templates/repo/datasets/create.tmpl | 2 +- templates/repo/datasets/edit.tmpl | 19 ++++---- templates/repo/datasets/index.tmpl | 30 +++++++----- web_src/js/components/MinioUploader.vue | 10 ++-- web_src/js/index.js | 37 ++++++++++++--- 8 files changed, 144 insertions(+), 56 deletions(-) diff --git a/templates/explore/dataset_left.tmpl b/templates/explore/dataset_left.tmpl index a6d093fc0..98cedc840 100644 --- a/templates/explore/dataset_left.tmpl +++ b/templates/explore/dataset_left.tmpl @@ -9,6 +9,7 @@
{{end}}
+
-

{{.i18n.Tr "dataset.category"}}

+

+ {{.i18n.Tr "dataset.category"}} + {{if $.Category}} + Clear + {{end}} +

{{range $category := categories}} - {{$.i18n.Tr (printf "dataset.category.%s" $category)}} + {{$Cate := $.i18n.Tr (printf "dataset.category.%s" $category)}} + {{$Cate}} {{end}}
-

{{.i18n.Tr "dataset.task"}}

+

+ {{.i18n.Tr "dataset.task"}} + {{if $.Task}} + Clear + {{end}} +

{{range $task := tasks}} - {{$.i18n.Tr (printf "dataset.task.%s" $task)}} + {{$Task := $.i18n.Tr (printf "dataset.task.%s" $task)}} + {{$Task}} {{end}}
-

{{.i18n.Tr "dataset.license"}}

+

+ {{.i18n.Tr "dataset.license"}} + {{if $.License}} + Clear + {{end}} +

{{range $license := licenses}} - {{$license}} + {{$license}} {{end}}
-
\ No newline at end of file + diff --git a/templates/explore/datasets.tmpl b/templates/explore/datasets.tmpl index 6ba2a19a8..0260db0df 100644 --- a/templates/explore/datasets.tmpl +++ b/templates/explore/datasets.tmpl @@ -6,7 +6,20 @@ .mg-b-2{ margin-bottom: 2rem; } - +.mg-l-1{ + margin-left: 1rem; +} +.text-gray-400 { + --tw-text-opacity: 1; + color: rgba(156,163,175,var(--tw-text-opacity)); +} +.text-sm { + font-size: .875rem; + line-height: 1.25rem; +} +.underline { + text-decoration: underline; +} .flex{ display: flex; } @@ -48,6 +61,10 @@ --tw-text-opacity: 1; color: rgba(30,64,175,var(--tw-text-opacity)); } +.tag.inactive { + filter: grayscale(100%); + opacity: .5; +} .tag { align-items: center; display: inline-flex; @@ -77,7 +94,7 @@
{{template "explore/dataset_search" .}} -
+
@@ -93,7 +110,7 @@ @@ -166,6 +206,5 @@
{{template "base/footer" .}} \ No newline at end of file diff --git a/templates/repo/attachment/edit.tmpl b/templates/repo/attachment/edit.tmpl index a4fe26a72..966e78b34 100644 --- a/templates/repo/attachment/edit.tmpl +++ b/templates/repo/attachment/edit.tmpl @@ -21,7 +21,7 @@ {{.CsrfTokenHtml}} - NPU + {{.Attachment.Type | AttachmentResourceType}} @@ -31,8 +31,8 @@ - 确定 - 取消 + 确定 + 取消 @@ -45,5 +45,6 @@ {{template "base/footer" .}} \ No newline at end of file diff --git a/templates/repo/datasets/create.tmpl b/templates/repo/datasets/create.tmpl index c701aa499..52c6a77d8 100644 --- a/templates/repo/datasets/create.tmpl +++ b/templates/repo/datasets/create.tmpl @@ -32,7 +32,7 @@ - + diff --git a/templates/repo/datasets/edit.tmpl b/templates/repo/datasets/edit.tmpl index 50f7afee2..24f4da529 100644 --- a/templates/repo/datasets/edit.tmpl +++ b/templates/repo/datasets/edit.tmpl @@ -20,7 +20,7 @@

- {{.i18n.Tr "repo.modelarts.train_job.new_infer"}} + 修改数据集

{{if .dataset.Task}} - {{.dataset.Task}} + {{.dataset.Task}} {{end}} {{if .dataset.Category}} - {{.dataset.Category}} + {{.dataset.Category}} {{end}} {{if .dataset.License}} - {{.dataset.License}} + {{.dataset.License}} {{end}}
@@ -143,10 +145,7 @@
- 浮动元素是如何定位的 - 正如我们前面提到的那样,当一个元素浮动之后,它会被移出正常的文档流,然后向左或者向右平移,一直平移直到碰到了所处的容器的边框,或者碰到另外一个浮动的元素。 - 浮动元素是如何定位的 - 正如我们前面提到的那样,当一个元素浮动之后,它会被移出正常的文档流,然后向左或者向右平移,一直平移直到碰到了所处的容器的边框,或者碰到另外一个浮动的元素。 + {{.dataset.Description}}
@@ -245,14 +244,19 @@ -->
- 下载 + {{if $.CanRead}} + 下载 + {{else}} + 下载 + {{end}} {{if eq .DecompressState 1}} 预览 {{end}} - - - 标注 - + {{if $.CanRead}} + 标注 + {{else}} + 标注 + {{end}} @@ -333,4 +337,6 @@ $('#dataset-range-value').find('.item').each(function(){ console.log(items) console.log({{$.IsStaringDataset}}) console.log({{.Attachments}}) +console.log({{$.CanRead}}) +console.log({{$.CanWrite}}) \ No newline at end of file diff --git a/web_src/js/components/MinioUploader.vue b/web_src/js/components/MinioUploader.vue index a2f07fac5..2c23ab2e9 100755 --- a/web_src/js/components/MinioUploader.vue +++ b/web_src/js/components/MinioUploader.vue @@ -9,7 +9,7 @@ {{ status }}

上传 - 取消 + 取消 @@ -37,10 +37,6 @@ export default { desc:{ type:String, default:'' - }, - backurl:{ - type:String, - default:'' } }, data() { @@ -60,7 +56,6 @@ export default { }, async mounted() { - console.log(this.backurl) this.dropzoneParams = $('div#minioUploader-params'); this.file_status_text = this.dropzoneParams.data('file-status'); this.status = this.dropzoneParams.data('file-init-status'); @@ -131,6 +126,9 @@ export default { this.dropzoneUploader = dropzoneUploader; }, methods: { + cancelDataset(){ + location.href = this.repoPath + }, resetStatus() { this.progress = 0; this.status = ''; diff --git a/web_src/js/index.js b/web_src/js/index.js index f1b876016..99f3a2d21 100755 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -3664,6 +3664,19 @@ function initVueDataset() { if (!el) { return; } + let link=$('#square-link').data('link') + const clearBtn = document.getElementsByClassName("clear_dataset_value"); + const params = new URLSearchParams(location.search) + for (let i = 0; i < clearBtn.length; i++) { + clearBtn[i].addEventListener('click',function(e){ + let searchType=e.target.getAttribute("data-clear-value") + if(params.has(searchType)){ + params.delete(searchType) + let clearSearch = params.toString() + location.href = link + '?' + clearSearch + } + }) + } const items = [] $('#dataset-range-value').find('.item').each(function(){ items.push($(this).data('private')) @@ -3814,6 +3827,7 @@ function initVueDataset() { this.taskLists = taskLists this.licenseLists = licenseLists this.descfile = dataset_file_desc + console.log(this.starItems,this.starActives) }, methods:{ createDataset(formName){ @@ -3850,6 +3864,8 @@ function initVueDataset() { } else{ console.log(attachment) + location.href = '/'+attachment + '/datasets' + } }, @@ -3929,13 +3945,20 @@ function initVueDataset() { }) }, - editDatasetFile(id){ - console.log(id) + editDatasetFile(id,backurl){ + console.log(id,backurl) let url = '/attachments/edit' - const params={id:id,description:this.descfile} + const params={id:id,description:this.descfile,_csrf:csrf} + console.log(this.qs.stringify(params)) // document.getElementById("mask").style.display = "block" this.$axios.post(url,this.qs.stringify(params)).then((res)=>{ - console.log(res) + if(res.data.Code===0){ + location.href = '/'+backurl + '/datasets' + }else{ + console.log(res.data.Message) + } + }).catch((err)=>{ + console.log(err) }) }, postStar(id,link){ @@ -3962,14 +3985,14 @@ function initVueDataset() { }, postSquareStar(id,link,index){ console.log(id,link,index) - if(this.starItems[index]){ + console.log(this.starItems,this.starActives) + if(this.starActives[index]){ let url = link+'/'+ id + '/unstar' this.$axios.put(url).then((res)=>{ console.log(res) if(res.data.Code===0){ this.$set(this.starActives,index,false) - this.$set(this.starItems,index,this.starItems[index]-1) - + this.$set(this.starItems,index,this.starItems[index]-1) } }) }else{ From 7c0b40ffd73b2e16117da0cb4ee39335b230e0f8 Mon Sep 17 00:00:00 2001 From: yanchao Date: Thu, 17 Mar 2022 19:43:42 +0800 Subject: [PATCH 042/109] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/dataset.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/models/dataset.go b/models/dataset.go index 7d04986d2..6c3bb9e02 100755 --- a/models/dataset.go +++ b/models/dataset.go @@ -1,11 +1,11 @@ package models import ( + logger "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/timeutil" "errors" "fmt" "sort" - - "code.gitea.io/gitea/modules/timeutil" "xorm.io/builder" ) @@ -198,6 +198,13 @@ func SearchDatasetByCondition(opts *SearchDatasetOptions, cond builder.Cond) (Da Join("INNER", "attachment", "attachment.dataset_id=dataset.id"). Where(cond).Count(new(Dataset)) + a, b := sess.LastSQL() + logger.Warn("sql:" + a) + + for _, v := range b { + logger.Warn("arg:" + v.(string)) + } + if err != nil { return nil, 0, fmt.Errorf("Count: %v", err) } @@ -205,6 +212,10 @@ func SearchDatasetByCondition(opts *SearchDatasetOptions, cond builder.Cond) (Da sess.Select(selectColumnsSql).Join("INNER", "repository", "repository.id = dataset.repo_id"). Join("INNER", "attachment", "attachment.dataset_id=dataset.id"). Where(cond).OrderBy(opts.SearchOrderBy.String()) + a, b = sess.LastSQL() + logger.Warn("sql:" + a) + + print(a, b) if opts.PageSize > 0 { sess.Limit(opts.PageSize, (opts.Page-1)*opts.PageSize) } From 24168084a0a4d6f1d3bbbd52fb7fa43220448f5a Mon Sep 17 00:00:00 2001 From: liuzx Date: Thu, 17 Mar 2022 19:58:58 +0800 Subject: [PATCH 043/109] fix-bug --- models/attachment.go | 7 +++++++ routers/repo/cloudbrain.go | 2 ++ routers/repo/modelarts.go | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/models/attachment.go b/models/attachment.go index a981aa987..45f86e8a0 100755 --- a/models/attachment.go +++ b/models/attachment.go @@ -61,6 +61,7 @@ type AttachmentUsername struct { type AttachmentInfo struct { Attachment `xorm:"extends"` Repo *Repository `xorm:"extends"` + User *User `xorm:"extends"` } type AttachmentsOptions struct { @@ -612,6 +613,12 @@ func Attachments(opts *AttachmentsOptions) ([]*AttachmentInfo, int64, error) { } else { return nil, 0, fmt.Errorf("GetRepositoryByID failed error: %v", err) } + user, err := GetUserByID(attachment.UploaderID) + if err == nil { + attachment.User = user + } else { + return nil, 0, fmt.Errorf("GetUserByID failed error: %v", err) + } } } diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 4cde5d40d..203d29e78 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -162,6 +162,8 @@ func cloudBrainNewDataPrepare(ctx *context.Context) error { ctx.Data["brainscore_path"] = cloudbrain.BrainScoreMountPath ctx.Data["is_brainscore_enabled"] = setting.IsBrainScoreEnabled + ctx.Data["cloudbraintype"] = models.TypeCloudBrainOne + return nil } diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index c60740b87..799f1f4c6 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -132,6 +132,8 @@ func notebookNewDataPrepare(ctx *context.Context) error { } ctx.Data["flavors"] = modelarts.FlavorInfos.FlavorInfo + ctx.Data["cloudbraintype"] = models.TypeCloudBrainTwo + return nil } @@ -578,6 +580,7 @@ func trainJobNewDataPrepare(ctx *context.Context) error { return err } ctx.Data["config_list"] = configList.ParaConfigs + ctx.Data["cloudbraintype"] = models.TypeCloudBrainTwo return nil } @@ -751,6 +754,7 @@ func trainJobNewVersionDataPrepare(ctx *context.Context) error { ctx.Data["uuid"] = task.Uuid ctx.Data["flavor_code"] = task.FlavorCode ctx.Data["engine_id"] = task.EngineID + ctx.Data["cloudbraintype"] = models.TypeCloudBrainTwo configList, err := getConfigList(modelarts.PerPage, 1, modelarts.SortByCreateTime, "desc", "", modelarts.ConfigTypeCustom) if err != nil { @@ -1955,6 +1959,7 @@ func inferenceJobNewDataPrepare(ctx *context.Context) error { New: MODEL_LATEST, }) ctx.Data["MODEL_COUNT"] = model_count + ctx.Data["cloudbraintype"] = models.TypeCloudBrainTwo return nil } From 0b9c4b2f6f825b9e13f297f69bb3ad40b28c1007 Mon Sep 17 00:00:00 2001 From: yanchao Date: Thu, 17 Mar 2022 20:48:33 +0800 Subject: [PATCH 044/109] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/dataset.go | 14 +++----------- routers/home.go | 3 +++ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/models/dataset.go b/models/dataset.go index 6c3bb9e02..8b1ad1420 100755 --- a/models/dataset.go +++ b/models/dataset.go @@ -1,11 +1,12 @@ package models import ( - logger "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/timeutil" "errors" "fmt" "sort" + "strconv" "xorm.io/builder" ) @@ -198,13 +199,6 @@ func SearchDatasetByCondition(opts *SearchDatasetOptions, cond builder.Cond) (Da Join("INNER", "attachment", "attachment.dataset_id=dataset.id"). Where(cond).Count(new(Dataset)) - a, b := sess.LastSQL() - logger.Warn("sql:" + a) - - for _, v := range b { - logger.Warn("arg:" + v.(string)) - } - if err != nil { return nil, 0, fmt.Errorf("Count: %v", err) } @@ -212,10 +206,7 @@ func SearchDatasetByCondition(opts *SearchDatasetOptions, cond builder.Cond) (Da sess.Select(selectColumnsSql).Join("INNER", "repository", "repository.id = dataset.repo_id"). Join("INNER", "attachment", "attachment.dataset_id=dataset.id"). Where(cond).OrderBy(opts.SearchOrderBy.String()) - a, b = sess.LastSQL() - logger.Warn("sql:" + a) - print(a, b) if opts.PageSize > 0 { sess.Limit(opts.PageSize, (opts.Page-1)*opts.PageSize) } @@ -226,6 +217,7 @@ func SearchDatasetByCondition(opts *SearchDatasetOptions, cond builder.Cond) (Da if err = datasets.loadAttributes(sess); err != nil { return nil, 0, fmt.Errorf("LoadAttributes: %v", err) } + log.Warn("datasetcout:" + strconv.FormatInt(count, 10)) return datasets, count, nil } diff --git a/routers/home.go b/routers/home.go index f54125e5f..a7693d1f5 100755 --- a/routers/home.go +++ b/routers/home.go @@ -8,6 +8,7 @@ package routers import ( "bytes" "net/http" + "strconv" "strings" "code.gitea.io/gitea/services/repository" @@ -335,6 +336,8 @@ func ExploreDatasets(ctx *context.Context) { } datasets, count, err = models.SearchDataset(opts) + + log.Warn("datasetcout:" + strconv.FormatInt(count, 10)) if err != nil { ctx.ServerError("SearchDatasets", err) return From 47ec57ae79bd97c524b627eccd0b08911c7dfb62 Mon Sep 17 00:00:00 2001 From: yanchao Date: Fri, 18 Mar 2022 00:17:50 +0800 Subject: [PATCH 045/109] =?UTF-8?q?=E8=A7=A3=E5=86=B3bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/dataset.go | 5 +---- routers/home.go | 2 -- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/models/dataset.go b/models/dataset.go index 8b1ad1420..44d285bda 100755 --- a/models/dataset.go +++ b/models/dataset.go @@ -1,12 +1,10 @@ package models import ( - "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/timeutil" "errors" "fmt" "sort" - "strconv" "xorm.io/builder" ) @@ -195,7 +193,7 @@ func SearchDatasetByCondition(opts *SearchDatasetOptions, cond builder.Cond) (Da datasets := make(DatasetList, 0, opts.PageSize) selectColumnsSql := "distinct dataset.id,dataset.title, dataset.status, dataset.category, dataset.description, dataset.download_times, dataset.license, dataset.task, dataset.release_id, dataset.user_id, dataset.repo_id, dataset.created_unix,dataset.updated_unix,dataset.num_stars" - count, err := sess.Select("distinct dataset.id").Join("INNER", "repository", "repository.id = dataset.repo_id"). + count, err := sess.Distinct("dataset.id").Join("INNER", "repository", "repository.id = dataset.repo_id"). Join("INNER", "attachment", "attachment.dataset_id=dataset.id"). Where(cond).Count(new(Dataset)) @@ -217,7 +215,6 @@ func SearchDatasetByCondition(opts *SearchDatasetOptions, cond builder.Cond) (Da if err = datasets.loadAttributes(sess); err != nil { return nil, 0, fmt.Errorf("LoadAttributes: %v", err) } - log.Warn("datasetcout:" + strconv.FormatInt(count, 10)) return datasets, count, nil } diff --git a/routers/home.go b/routers/home.go index a7693d1f5..c33d7a049 100755 --- a/routers/home.go +++ b/routers/home.go @@ -8,7 +8,6 @@ package routers import ( "bytes" "net/http" - "strconv" "strings" "code.gitea.io/gitea/services/repository" @@ -337,7 +336,6 @@ func ExploreDatasets(ctx *context.Context) { datasets, count, err = models.SearchDataset(opts) - log.Warn("datasetcout:" + strconv.FormatInt(count, 10)) if err != nil { ctx.ServerError("SearchDatasets", err) return From b8a097b598952748fed7ad5b2b31cb69dd3eafe5 Mon Sep 17 00:00:00 2001 From: liuzx Date: Fri, 18 Mar 2022 16:24:06 +0800 Subject: [PATCH 046/109] fix-bug --- models/attachment.go | 4 +- routers/repo/dataset.go | 115 ++++++++++++++++++++++------------------ 2 files changed, 66 insertions(+), 53 deletions(-) diff --git a/models/attachment.go b/models/attachment.go index 45f86e8a0..a0cd624b4 100755 --- a/models/attachment.go +++ b/models/attachment.go @@ -70,6 +70,7 @@ type AttachmentsOptions struct { DecompressState int Type int UploaderID int64 + NeedDatasetIDs bool NeedIsPrivate bool IsPrivate bool NeedRepoInfo bool @@ -543,8 +544,7 @@ func Attachments(opts *AttachmentsOptions) ([]*AttachmentInfo, int64, error) { defer sess.Close() var cond = builder.NewCond() - - if len(opts.DatasetIDs) > 0 { + if opts.NeedDatasetIDs { cond = cond.And( builder.In("attachment.dataset_id", opts.DatasetIDs), ) diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index b3fbbe1dd..014162be6 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -319,12 +319,13 @@ func CurrentRepoDataset(ctx *context.Context) { Page: page, PageSize: setting.UI.IssuePagingNum, }, - Keyword: keyword, - DatasetIDs: datasetIDs, - UploaderID: uploaderID, - Type: cloudbrainType, - NeedIsPrivate: false, - NeedRepoInfo: true, + Keyword: keyword, + NeedDatasetIDs: true, + DatasetIDs: datasetIDs, + UploaderID: uploaderID, + Type: cloudbrainType, + NeedIsPrivate: false, + NeedRepoInfo: true, }) if err != nil { ctx.ServerError("datasets", err) @@ -359,11 +360,12 @@ func MyDatasets(ctx *context.Context) { Page: page, PageSize: setting.UI.IssuePagingNum, }, - Keyword: keyword, - UploaderID: uploaderID, - Type: cloudbrainType, - NeedIsPrivate: false, - NeedRepoInfo: true, + Keyword: keyword, + NeedDatasetIDs: false, + UploaderID: uploaderID, + Type: cloudbrainType, + NeedIsPrivate: false, + NeedRepoInfo: true, }) if err != nil { ctx.ServerError("datasets", err) @@ -397,11 +399,12 @@ func PublicDataset(ctx *context.Context) { Page: page, PageSize: setting.UI.IssuePagingNum, }, - Keyword: keyword, - NeedIsPrivate: true, - IsPrivate: false, - Type: cloudbrainType, - NeedRepoInfo: true, + Keyword: keyword, + NeedDatasetIDs: false, + NeedIsPrivate: true, + IsPrivate: false, + Type: cloudbrainType, + NeedRepoInfo: true, }) if err != nil { ctx.ServerError("datasets", err) @@ -431,45 +434,55 @@ func MyFavoriteDataset(ctx *context.Context) { keyword := strings.Trim(ctx.Query("q"), " ") var datasetIDs []int64 - - datasetStars, err := models.GetDatasetStarByUser(ctx.User) - if err != nil { - ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr("GetDatasetByRepo failed", err))) - } - for i, _ := range datasetStars { - datasetIDs = append(datasetIDs, datasetStars[i].DatasetID) - } - - datasets, count, err := models.Attachments(&models.AttachmentsOptions{ - ListOptions: models.ListOptions{ - Page: page, - PageSize: setting.UI.IssuePagingNum, - }, - Keyword: keyword, - DatasetIDs: datasetIDs, - NeedIsPrivate: true, - IsPrivate: false, - Type: cloudbrainType, - NeedRepoInfo: true, - }) - if err != nil { - ctx.ServerError("datasets", err) - return - } - - data, err := json.Marshal(datasets) - if err != nil { - log.Error("json.Marshal failed:", err.Error()) + if !ctx.IsSigned { + log.Error("user not login!") ctx.JSON(200, map[string]string{ "result_code": "-1", - "error_msg": err.Error(), + "error_msg": "user not login!", "data": "", }) return + } else { + datasetStars, err := models.GetDatasetStarByUser(ctx.User) + if err != nil { + ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr("GetDatasetStarByUser failed", err))) + } + for i, _ := range datasetStars { + datasetIDs = append(datasetIDs, datasetStars[i].DatasetID) + } + + datasets, count, err := models.Attachments(&models.AttachmentsOptions{ + ListOptions: models.ListOptions{ + Page: page, + PageSize: setting.UI.IssuePagingNum, + }, + Keyword: keyword, + NeedDatasetIDs: true, + DatasetIDs: datasetIDs, + NeedIsPrivate: true, + IsPrivate: false, + Type: cloudbrainType, + NeedRepoInfo: true, + }) + if err != nil { + ctx.ServerError("datasets", err) + return + } + + data, err := json.Marshal(datasets) + if err != nil { + log.Error("json.Marshal failed:", err.Error()) + ctx.JSON(200, map[string]string{ + "result_code": "-1", + "error_msg": err.Error(), + "data": "", + }) + return + } + ctx.JSON(200, map[string]string{ + "result_code": "0", + "data": string(data), + "count": strconv.FormatInt(count, 10), + }) } - ctx.JSON(200, map[string]string{ - "result_code": "0", - "data": string(data), - "count": strconv.FormatInt(count, 10), - }) } From 899b9ae87d54f39d92a623629c9f5136b5e3aa61 Mon Sep 17 00:00:00 2001 From: liuzx Date: Fri, 18 Mar 2022 16:53:32 +0800 Subject: [PATCH 047/109] fix-bug --- models/dataset.go | 5 +++-- routers/repo/dataset.go | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/models/dataset.go b/models/dataset.go index 44d285bda..af47c53fe 100755 --- a/models/dataset.go +++ b/models/dataset.go @@ -1,10 +1,11 @@ package models import ( - "code.gitea.io/gitea/modules/timeutil" "errors" "fmt" "sort" + + "code.gitea.io/gitea/modules/timeutil" "xorm.io/builder" ) @@ -353,7 +354,7 @@ func GetDatasetByRepo(repo *Repository) (*Dataset, error) { func GetDatasetStarByUser(user *User) ([]*DatasetStar, error) { datasetStars := make([]*DatasetStar, 0) - err := x.Cols("id", "uid", "DatasetID", "CreatedUnix").Where("uid=?", user.ID).Find(&datasetStars) + err := x.Cols("id", "uid", "dataset_id", "created_unix").Where("uid=?", user.ID).Find(&datasetStars) return datasetStars, err } diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index 014162be6..546706419 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -446,6 +446,13 @@ func MyFavoriteDataset(ctx *context.Context) { datasetStars, err := models.GetDatasetStarByUser(ctx.User) if err != nil { ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr("GetDatasetStarByUser failed", err))) + log.Error("GetDatasetStarByUser failed:", err.Error()) + ctx.JSON(200, map[string]string{ + "result_code": "-1", + "error_msg": err.Error(), + "data": "", + }) + return } for i, _ := range datasetStars { datasetIDs = append(datasetIDs, datasetStars[i].DatasetID) From 15468ee231dd117429a44135d1cb37c1629f6383 Mon Sep 17 00:00:00 2001 From: liuzx Date: Fri, 18 Mar 2022 17:45:58 +0800 Subject: [PATCH 048/109] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/repo/dataset.go | 88 ++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 49 deletions(-) diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index 546706419..c51194965 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -433,63 +433,53 @@ func MyFavoriteDataset(ctx *context.Context) { cloudbrainType := ctx.QueryInt("type") keyword := strings.Trim(ctx.Query("q"), " ") - var datasetIDs []int64 - if !ctx.IsSigned { - log.Error("user not login!") + datasetStars, err := models.GetDatasetStarByUser(ctx.User) + if err != nil { + ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr("GetDatasetStarByUser failed", err))) + log.Error("GetDatasetStarByUser failed:", err.Error()) ctx.JSON(200, map[string]string{ "result_code": "-1", - "error_msg": "user not login!", + "error_msg": err.Error(), "data": "", }) return - } else { - datasetStars, err := models.GetDatasetStarByUser(ctx.User) - if err != nil { - ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr("GetDatasetStarByUser failed", err))) - log.Error("GetDatasetStarByUser failed:", err.Error()) - ctx.JSON(200, map[string]string{ - "result_code": "-1", - "error_msg": err.Error(), - "data": "", - }) - return - } - for i, _ := range datasetStars { - datasetIDs = append(datasetIDs, datasetStars[i].DatasetID) - } + } + for i, _ := range datasetStars { + datasetIDs = append(datasetIDs, datasetStars[i].DatasetID) + } - datasets, count, err := models.Attachments(&models.AttachmentsOptions{ - ListOptions: models.ListOptions{ - Page: page, - PageSize: setting.UI.IssuePagingNum, - }, - Keyword: keyword, - NeedDatasetIDs: true, - DatasetIDs: datasetIDs, - NeedIsPrivate: true, - IsPrivate: false, - Type: cloudbrainType, - NeedRepoInfo: true, - }) - if err != nil { - ctx.ServerError("datasets", err) - return - } + datasets, count, err := models.Attachments(&models.AttachmentsOptions{ + ListOptions: models.ListOptions{ + Page: page, + PageSize: setting.UI.IssuePagingNum, + }, + Keyword: keyword, + NeedDatasetIDs: true, + DatasetIDs: datasetIDs, + NeedIsPrivate: true, + IsPrivate: false, + Type: cloudbrainType, + NeedRepoInfo: true, + }) + if err != nil { + ctx.ServerError("datasets", err) + return + } - data, err := json.Marshal(datasets) - if err != nil { - log.Error("json.Marshal failed:", err.Error()) - ctx.JSON(200, map[string]string{ - "result_code": "-1", - "error_msg": err.Error(), - "data": "", - }) - return - } + data, err := json.Marshal(datasets) + if err != nil { + log.Error("json.Marshal failed:", err.Error()) ctx.JSON(200, map[string]string{ - "result_code": "0", - "data": string(data), - "count": strconv.FormatInt(count, 10), + "result_code": "-1", + "error_msg": err.Error(), + "data": "", }) + return } + ctx.JSON(200, map[string]string{ + "result_code": "0", + "data": string(data), + "count": strconv.FormatInt(count, 10), + }) + } From 26badc5a3a9745235f79b1fa4d36f7a4918355d9 Mon Sep 17 00:00:00 2001 From: liuzx Date: Fri, 18 Mar 2022 18:06:02 +0800 Subject: [PATCH 049/109] fix-bug --- models/attachment.go | 10 +++++----- modules/setting/setting.go | 8 +++++--- routers/repo/dataset.go | 8 ++++---- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/models/attachment.go b/models/attachment.go index a0cd624b4..086426bf2 100755 --- a/models/attachment.go +++ b/models/attachment.go @@ -59,9 +59,9 @@ type AttachmentUsername struct { } type AttachmentInfo struct { - Attachment `xorm:"extends"` - Repo *Repository `xorm:"extends"` - User *User `xorm:"extends"` + Attachment `xorm:"extends"` + Repo *Repository `xorm:"extends"` + RelAvatarLink string `xorm:"extends"` } type AttachmentsOptions struct { @@ -595,7 +595,7 @@ func Attachments(opts *AttachmentsOptions) ([]*AttachmentInfo, int64, error) { } sess.OrderBy("attachment.created_unix DESC") - attachments := make([]*AttachmentInfo, 0, setting.UI.IssuePagingNum) + attachments := make([]*AttachmentInfo, 0, setting.UI.DatasetPagingNum) if err := sess.Table(&Attachment{}).Where(cond). Find(&attachments); err != nil { return nil, 0, fmt.Errorf("Find: %v", err) @@ -615,7 +615,7 @@ func Attachments(opts *AttachmentsOptions) ([]*AttachmentInfo, int64, error) { } user, err := GetUserByID(attachment.UploaderID) if err == nil { - attachment.User = user + attachment.RelAvatarLink = user.RelAvatarLink() } else { return nil, 0, fmt.Errorf("GetUserByID failed error: %v", err) } diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 2a29dd700..946fb73b4 100755 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -165,6 +165,7 @@ var ( ExplorePagingNum int ContributorPagingNum int IssuePagingNum int + DatasetPagingNum int RepoSearchPagingNum int MembersPagingNum int FeedMaxCommitNum int @@ -207,6 +208,7 @@ var ( ExplorePagingNum: 20, ContributorPagingNum: 50, IssuePagingNum: 10, + DatasetPagingNum: 5, RepoSearchPagingNum: 10, MembersPagingNum: 20, FeedMaxCommitNum: 5, @@ -512,9 +514,9 @@ var ( ProfileID string PoolInfos string Flavor string - DebugHost string - ImageInfos string - Capacity int + DebugHost string + ImageInfos string + Capacity int //train-job ResourcePools string Engines string diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index c51194965..4e460097c 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -317,7 +317,7 @@ func CurrentRepoDataset(ctx *context.Context) { datasets, count, err := models.Attachments(&models.AttachmentsOptions{ ListOptions: models.ListOptions{ Page: page, - PageSize: setting.UI.IssuePagingNum, + PageSize: setting.UI.DatasetPagingNum, }, Keyword: keyword, NeedDatasetIDs: true, @@ -358,7 +358,7 @@ func MyDatasets(ctx *context.Context) { datasets, count, err := models.Attachments(&models.AttachmentsOptions{ ListOptions: models.ListOptions{ Page: page, - PageSize: setting.UI.IssuePagingNum, + PageSize: setting.UI.DatasetPagingNum, }, Keyword: keyword, NeedDatasetIDs: false, @@ -397,7 +397,7 @@ func PublicDataset(ctx *context.Context) { datasets, count, err := models.Attachments(&models.AttachmentsOptions{ ListOptions: models.ListOptions{ Page: page, - PageSize: setting.UI.IssuePagingNum, + PageSize: setting.UI.DatasetPagingNum, }, Keyword: keyword, NeedDatasetIDs: false, @@ -451,7 +451,7 @@ func MyFavoriteDataset(ctx *context.Context) { datasets, count, err := models.Attachments(&models.AttachmentsOptions{ ListOptions: models.ListOptions{ Page: page, - PageSize: setting.UI.IssuePagingNum, + PageSize: setting.UI.DatasetPagingNum, }, Keyword: keyword, NeedDatasetIDs: true, From 6ca53375d1e510f9c8369309aa5441aa023a113d Mon Sep 17 00:00:00 2001 From: liuzx Date: Fri, 18 Mar 2022 18:09:27 +0800 Subject: [PATCH 050/109] fix-bug --- routers/repo/dataset.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index 4e460097c..f3d464ad3 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -432,7 +432,7 @@ func MyFavoriteDataset(ctx *context.Context) { page := ctx.QueryInt("page") cloudbrainType := ctx.QueryInt("type") keyword := strings.Trim(ctx.Query("q"), " ") - + var datasetIDs []int64 datasetStars, err := models.GetDatasetStarByUser(ctx.User) if err != nil { ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr("GetDatasetStarByUser failed", err))) From edf4ff3815ed931a36469daea3e89a9b8babc7fc Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Fri, 18 Mar 2022 19:22:53 +0800 Subject: [PATCH 051/109] #1627 update --- options/locale/locale_en-US.ini | 30 ++++- options/locale/locale_zh-CN.ini | 24 ++++ templates/admin/cloudbrain/list.tmpl | 46 +++---- templates/explore/repo_left.tmpl | 28 ++-- templates/explore/repo_list.tmpl | 4 +- .../repo/cloudbrain/benchmark/index.tmpl | 8 +- templates/repo/cloudbrain/benchmark/new.tmpl | 30 ++--- templates/repo/cloudbrain/benchmark/show.tmpl | 86 ++++++------ templates/repo/cloudbrain/new.tmpl | 4 +- templates/repo/debugjob/index.tmpl | 8 +- .../repo/modelarts/inferencejob/index.tmpl | 8 +- .../repo/modelarts/inferencejob/new.tmpl | 46 +++---- .../repo/modelarts/inferencejob/show.tmpl | 118 ++++++++--------- templates/repo/modelarts/trainjob/index.tmpl | 8 +- templates/repo/modelarts/trainjob/new.tmpl | 42 +++--- .../repo/modelarts/trainjob/para_manage.tmpl | 30 ++--- templates/repo/modelarts/trainjob/show.tmpl | 122 +++++++++--------- .../repo/modelarts/trainjob/version_new.tmpl | 42 +++--- templates/repo/modelmanage/index.tmpl | 22 ++-- 19 files changed, 378 insertions(+), 328 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index a0acb05ec..aba6bfbf3 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -273,6 +273,20 @@ code_search_results = Search results for '%s' code_last_indexed_at = Last indexed %s save=Save cancel=Cancel +hot_repo=Hot Repositories +active_repo=Active Repositories +all_fields = All fields +large_model = Large model +ai_development_tools = AI tools +computer_version = Computer version +natural_language_processing = NLP +machine_learning = Machine learning +neural_networks = Neural networks +autopilot = Autopilot +robot = Robot +federated_learning = Federated learning +data_mining = Data mining +RISC-V_development = RISC-V development [auth] create_new_account = Register Account @@ -982,6 +996,7 @@ modelarts.infer_job_model_file = Model File modelarts.infer_job = Inference Job modelarts.infer_job.model_version = Model/Version modelarts.infer_job.select_model = Select Model +modelarts.infer_job.boot_file_helper=The startup file is the entry file for your program execution and must end in.py.Such as inference.py, main.py, example/inference. Py, case/main.py. modelarts.infer_job.tooltip = The model has been deleted and cannot be viewed. @@ -991,7 +1006,7 @@ inference_job_not_created = Inference job has not been created model_Evaluation_not_created = Model evaluation has not been created repo_not_initialized = Code version: You have not initialized the code repository, please
initialized first ; debug_task_running_limit =Running time: no more than 4 hours, it will automatically stop if it exceeds 4 hours; -dataset_desc = Dataset: Cloud Brain 1 provides CPU/GPU,Cloud Brain 2 provides Ascend NPU.Dataset also needs to be uploaded to the corresponding environment; +dataset_desc = Dataset: Cloud Brain 1 provides CPU/GPU,Cloud Brain 2 provides Ascend NPU.And dataset also needs to be uploaded to the corresponding environment; platform_instructions = Instructions for use: You can refer to the Xiaobai training camp course of Qizhi AI collaboration platform. model_not_exist = Model file: You do not have a model file yet, please generate and export the model through the training task first ; benchmark_leaderboards = Benchmark leaderboards @@ -2828,4 +2843,15 @@ benchmark_path = Benchmark script path snn4imagenet_path = Snn4imagenet script path brainscore_path = Brainscore script path start_command = Start command -choose_mirror = select mirror +choose_mirror = select mirror or enter mirror path + +job_name_rule = Please enter letters, numbers, _ and - up to 64 characters and cannot end with a dash (-). +dataset_path_rule = The dataset location is stored in the environment variable data_url, and the training output path is stored in the environment variable train_url. +view_sample = View sample +inference_output_path_rule = The inference output path is stored in the environment variable result_url. +model_file_path_rule=The model file location is stored in the environment variable ckpt_url + +delete_task = Delete task +task_delete_confirm = Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered. +operate_confirm = confirm +operate_cancel = cancel diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index fd5cde4d1..5a86801d0 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -275,6 +275,20 @@ code_search_results=“%s” 的搜索结果是 code_last_indexed_at=最后索引于 %s save=保存 cancel=取消 +hot_repo=热门项目 +active_repo=活跃项目 +all_fields = 全部领域 +large_model = 大模型 +ai_development_tools = AI开发工具 +computer_version = 计算机视觉 +natural_language_processing = 自然语言处理 +machine_learning = 机器学习 +neural_networks = 神经网络 +autopilot = 自动驾驶 +robot = 机器人 +federated_learning = 联邦学习 +data_mining = 数据挖掘 +RISC-V_development = RISC-V开发 [auth] create_new_account=注册帐号 @@ -2838,3 +2852,13 @@ brainscore_path = brainscore脚本存放路径 start_command = 启动命令 choose_mirror = 选择镜像或输入镜像地址 +job_name_rule = 请输入字母、数字、_和-,最长64个字符,且不能以中划线(-)结尾。 +dataset_path_rule = 数据集位置存储在环境变量data_url中,训练输出路径存储在环境变量train_url中。 +view_sample = 查看样例 +inference_output_path_rule = 推理输出路径存储在环境变量result_url中。 +model_file_path_rule = 模型文件位置存储在环境变量ckpt_url中。 + +delete_task = 删除任务 +task_delete_confirm = 你确认删除该任务么?此任务一旦删除不可恢复。 +operate_confirm = 确定操作 +operate_cancel = 取消操作 diff --git a/templates/admin/cloudbrain/list.tmpl b/templates/admin/cloudbrain/list.tmpl index 9aac97e70..39b2c21de 100644 --- a/templates/admin/cloudbrain/list.tmpl +++ b/templates/admin/cloudbrain/list.tmpl @@ -43,26 +43,26 @@ {{$.i18n.Tr "repo.cloudbrain_status_runtime"}}
- {{$.i18n.Tr "repo.modelarts.computing_resources"}} + {{$.i18n.Tr "repo.modelarts.computing_resources"}}
- {{$.i18n.Tr "repo.cloudbrain_creator"}} + {{$.i18n.Tr "repo.cloudbrain_creator"}}
- {{$.i18n.Tr "repository"}} + {{$.i18n.Tr "repository"}}
- {{.i18n.Tr "admin.cloudbrain.cloudbrain_name"}} + {{.i18n.Tr "admin.cloudbrain.cloudbrain_name"}}
{{$.i18n.Tr "repo.cloudbrain_operate"}}
-
-
+ + {{range .Tasks}} {{if .Repo}}
-
+
{{$JobID := '0'}} {{if eq .JobType "DEBUG" "SNN4IMAGENET" "BRAINSCORE" "BENCHMARK"}} @@ -91,8 +91,8 @@ {{end}}
-
- {{.JobType}} +
+ {{.JobType}}
@@ -105,12 +105,12 @@ {{TimeSinceUnix1 .Cloudbrain.CreatedUnix}}
-
- {{if .TrainJobDuration}}{{.TrainJobDuration}}{{else}}--{{end}} +
+ {{if .TrainJobDuration}}{{.TrainJobDuration}}{{else}}--{{end}}
- {{if .ComputeResource}}{{.ComputeResource}}{{else}}--{{end}} + {{if .ComputeResource}}{{.ComputeResource}}{{else}}--{{end}}
@@ -178,7 +178,7 @@ {{$JobID = .JobID}} {{end}}
-
+
{{if eq .JobType "DEBUG"}} @@ -200,8 +200,8 @@ {{end}}
-
- {{.JobType}} +
+ {{.JobType}}
@@ -214,12 +214,12 @@ {{TimeSinceUnix1 .Cloudbrain.CreatedUnix}}
-
- {{if .TrainJobDuration}}{{.TrainJobDuration}}{{else}}--{{end}} +
+ {{if .TrainJobDuration}}{{.TrainJobDuration}}{{else}}--{{end}}
- {{if .ComputeResource}}{{.ComputeResource}}{{else}}--{{end}} + {{if .ComputeResource}}{{.ComputeResource}}{{else}}--{{end}}
@@ -296,18 +296,18 @@
diff --git a/templates/explore/repo_left.tmpl b/templates/explore/repo_left.tmpl index ca6a3b3dd..66c46e1ba 100755 --- a/templates/explore/repo_left.tmpl +++ b/templates/explore/repo_left.tmpl @@ -4,73 +4,73 @@ - 全部领域 + {{.i18n.Tr "explore.all_fields"}} - 大模型 + {{.i18n.Tr "explore.large_model"}} - AI开发工具 + {{.i18n.Tr "explore.ai_development_tools"}} - 计算机视觉 + {{.i18n.Tr "explore.computer_version"}} - 自然语言处理 + {{.i18n.Tr "explore.natural_language_processing"}} - 机器学习 + {{.i18n.Tr "explore.machine_learning"}} - 神经网络 + {{.i18n.Tr "explore.neural_networks"}} - 自动驾驶 + {{.i18n.Tr "explore.autopilot"}} - 机器人 + {{.i18n.Tr "explore.robot"}} - 联邦学习 + {{.i18n.Tr "explore.federated_learning"}} - 数据挖掘 + {{.i18n.Tr "explore.data_mining"}} - RISC-V开发 - + {{.i18n.Tr "explore.RISC-V_development"}} +
-
\ No newline at end of file +
diff --git a/templates/explore/repo_list.tmpl b/templates/explore/repo_list.tmpl index 0e01186b0..b6bb49da9 100755 --- a/templates/explore/repo_list.tmpl +++ b/templates/explore/repo_list.tmpl @@ -44,13 +44,13 @@ - 热门{{.i18n.Tr "explore.repos"}} + {{.i18n.Tr "explore.hot_repo"}} - 活跃{{.i18n.Tr "explore.repos"}} + {{.i18n.Tr "explore.active_repo"}} {{end}} diff --git a/templates/repo/cloudbrain/benchmark/index.tmpl b/templates/repo/cloudbrain/benchmark/index.tmpl index 902a04fac..a816a3e2b 100755 --- a/templates/repo/cloudbrain/benchmark/index.tmpl +++ b/templates/repo/cloudbrain/benchmark/index.tmpl @@ -204,18 +204,18 @@
@@ -217,7 +217,7 @@ setChildType(); } } - + function validate(){ $('.ui.form') .form({ @@ -239,7 +239,7 @@ // $('.ui.page.dimmer').dimmer('show') document.getElementById("mask").style.display = "block" }, - onFailure: function(e){ + onFailure: function(e){ return false; } }) @@ -247,6 +247,6 @@ $('.ui.create_train_job.green.button').click(function(e) { - validate() + validate() }) - \ No newline at end of file + diff --git a/templates/repo/cloudbrain/benchmark/show.tmpl b/templates/repo/cloudbrain/benchmark/show.tmpl index a6c529597..3c8f91528 100755 --- a/templates/repo/cloudbrain/benchmark/show.tmpl +++ b/templates/repo/cloudbrain/benchmark/show.tmpl @@ -82,7 +82,7 @@ vertical-align: inherit; } .ti-text-form-label { - + padding-bottom: 20px; padding-right: 20px; color: #8a8e99; @@ -152,7 +152,7 @@ td, th { opacity: .45 !important; } .pad20{ - + border:0px !important; } .model_file_bread{ @@ -196,14 +196,14 @@ td, th {
- {{TimeSinceUnix1 .CreatedUnix}} - + {{TimeSinceUnix1 .CreatedUnix}} + {{$.i18n.Tr "repo.modelarts.status"}}: {{.Status}} {{$.i18n.Tr "repo.modelarts.train_job.dura_time"}}: {{$.duration}} - +
@@ -244,12 +244,12 @@ td, th {
- + - {{$.i18n.Tr "repo.modelarts.train_job.start_time"}} + {{$.i18n.Tr "repo.modelarts.train_job.start_time"}} - +
{{TimeSinceUnix1 .CreatedUnix}} @@ -258,9 +258,9 @@ td, th { - {{$.i18n.Tr "repo.modelarts.train_job.dura_time"}} + {{$.i18n.Tr "repo.modelarts.train_job.dura_time"}} - +
{{$.duration}} @@ -269,9 +269,9 @@ td, th { - 镜像 + 镜像 - +
{{.Image}} @@ -280,30 +280,30 @@ td, th { - 类型 + 类型 - +
{{$.BenchmarkTypeName}}
- - + +
- - + + - + - + - + - + - + - + - + - + --> - + - + - + - + - + - + - + - + - + - + - + - + - + " html += "" html += "" - + } html += "" html += "
训练程序
train.py @@ -314,19 +314,19 @@ td, th {
测试程序
test.py
- {{$.i18n.Tr "repo.modelarts.train_job.description"}} + {{$.i18n.Tr "repo.modelarts.train_job.description"}}
{{.Description}} @@ -336,9 +336,9 @@ td, th {
- {{$.i18n.Tr "repo.modelarts.train_job.standard"}} + {{$.i18n.Tr "repo.modelarts.train_job.standard"}}
{{$.resource_spec}} @@ -348,9 +348,9 @@ td, th {
- 创建者 + 创建者
{{.User.Name}} @@ -359,9 +359,9 @@ td, th {
- 子类型 + 子类型
{{$.BenchmarkChildTypeName}} @@ -373,7 +373,7 @@ td, th {
- +
@@ -386,11 +386,11 @@ td, th {

                             
- + - + - + @@ -400,24 +400,24 @@ td, th {
- - + + {{template "base/footer" .}} @@ -430,7 +430,7 @@ td, th { $(document).ready(function(){ $('.secondary.menu .item').tab(); }); - + let userName let repoPath let jobName @@ -454,5 +454,5 @@ td, th { document.getElementById("mask").style.display = "none" }); } - - \ No newline at end of file + + diff --git a/templates/repo/cloudbrain/new.tmpl b/templates/repo/cloudbrain/new.tmpl index 6b5388b5a..53ec56f8a 100755 --- a/templates/repo/cloudbrain/new.tmpl +++ b/templates/repo/cloudbrain/new.tmpl @@ -147,12 +147,12 @@
- +
- {{if .is_snn4imagenet_enabled}} diff --git a/templates/repo/debugjob/index.tmpl b/templates/repo/debugjob/index.tmpl index 1b6f0ffc6..ab6e266af 100755 --- a/templates/repo/debugjob/index.tmpl +++ b/templates/repo/debugjob/index.tmpl @@ -458,18 +458,18 @@
diff --git a/templates/repo/modelarts/inferencejob/index.tmpl b/templates/repo/modelarts/inferencejob/index.tmpl index 5e2ecd730..b9724d3d8 100644 --- a/templates/repo/modelarts/inferencejob/index.tmpl +++ b/templates/repo/modelarts/inferencejob/index.tmpl @@ -205,18 +205,18 @@
diff --git a/templates/repo/modelarts/inferencejob/new.tmpl b/templates/repo/modelarts/inferencejob/new.tmpl index 5bb7aee6d..6f174bbbb 100644 --- a/templates/repo/modelarts/inferencejob/new.tmpl +++ b/templates/repo/modelarts/inferencejob/new.tmpl @@ -68,9 +68,9 @@
- 请输入字母、数字、_和-,最长64个字符,且不能以中划线(-)结尾。 + {{.i18n.Tr "cloudbrain.job_name_rule"}}
- +
   @@ -107,7 +107,7 @@ - +
@@ -123,10 +123,10 @@
- +
- +
@@ -181,7 +181,7 @@ {{end}} - + @@ -195,9 +195,9 @@ - 查看样例 + {{.i18n.Tr "cloudbrain.view_sample"}} - +
   @@ -222,7 +222,7 @@ {{end}}
- + - 推理输出路径存储在环境变量result_url中。 + {{.i18n.Tr "cloudbrain.inference_output_path_rule"}}
@@ -255,7 +255,7 @@ {{.i18n.Tr "repo.cloudbrain.new"}} {{.i18n.Tr "repo.cloudbrain.cancel"}} -
+ @@ -283,7 +283,7 @@ $("#select_model").dropdown('set text',nameList[0]) $("#select_model").dropdown('set value',nameList[0],nameList[0]) } - + $('#select_model').removeClass("loading") }) // 根据选中的模型名称获取相应的模型版本 @@ -323,7 +323,7 @@ if(!element.IsDir && loadCheckpointFile.includes(ckptSuffix[ckptSuffix.length-1])){ html += `
${element.FileName}
` } - + }) $('#model_checkpoint').append(html) $("#select_model_checkpoint").removeClass("loading") @@ -332,7 +332,7 @@ $("#select_model_checkpoint").dropdown('set text',initVersionText) $("#select_model_checkpoint").dropdown('set value',initVersionValue,initVersionText,$('#model_name_version div.item:first-child')) }) - + $("input#ai_model_version").val(text) $("input#ai_model_label").val(label) @@ -348,15 +348,15 @@ } $('.question.circle.icon').hover(function(){ - $(this).popup('show') + $(this).popup('show') }); // 参数增加、删除、修改、保存 function Add_parameter(i){ value = '
' + - '
' + - ' ' + - '
' + + '
' + + ' ' + + '
' + '
' + '' + '
'+ @@ -366,7 +366,7 @@ '' + '
' $(".dynamic.field").append(value) - } + } $('#add_run_para').click(function(){ var len = $(".dynamic.field .two.fields").length @@ -459,7 +459,7 @@ onSuccess: function(){ document.getElementById("mask").style.display = "block" }, - onFailure: function(e){ + onFailure: function(e){ return false; } }) @@ -470,8 +470,8 @@ } } $('.ui.create_train_job.green.button').click(function(e) { - send_run_para() + send_run_para() get_name() validate() }) - \ No newline at end of file + diff --git a/templates/repo/modelarts/inferencejob/show.tmpl b/templates/repo/modelarts/inferencejob/show.tmpl index 4e221acd4..e11919b71 100644 --- a/templates/repo/modelarts/inferencejob/show.tmpl +++ b/templates/repo/modelarts/inferencejob/show.tmpl @@ -82,7 +82,7 @@ vertical-align: inherit; } .ti-text-form-label { - + padding-bottom: 20px; padding-right: 20px; color: #8a8e99; @@ -152,7 +152,7 @@ td, th { opacity: .45 !important; } .pad20{ - + border:0px !important; } .model_file_bread{ @@ -180,12 +180,12 @@ td, th { {{with .task}}
{{$.i18n.Tr "repo.modelarts.run_version"}}
{{.VersionName}} @@ -227,9 +227,9 @@ td, th {
- {{$.i18n.Tr "repo.modelarts.train_job.start_time"}} + {{$.i18n.Tr "repo.modelarts.train_job.start_time"}}
{{TimeSinceUnix1 .CreatedUnix}} @@ -238,9 +238,9 @@ td, th {
- {{$.i18n.Tr "repo.modelarts.train_job.dura_time"}} + {{$.i18n.Tr "repo.modelarts.train_job.dura_time"}}
{{.TrainJobDuration}} @@ -248,23 +248,23 @@ td, th {
- {{$.i18n.Tr "repo.modelarts.train_job.AI_driver"}} + {{$.i18n.Tr "repo.modelarts.train_job.AI_driver"}}
{{.EngineName}}
{{$.i18n.Tr "repo.model.manage.description"}}
{{if .Description}} @@ -279,7 +279,7 @@ td, th {
创建人
{{$.userName}} @@ -288,7 +288,7 @@ td, th {
- {{$.i18n.Tr "repo.modelarts.train_job.compute_node"}} + {{$.i18n.Tr "repo.modelarts.train_job.compute_node"}}
@@ -304,19 +304,19 @@ td, th {
- {{$.i18n.Tr "repo.modelarts.infer_job_model"}} + {{$.i18n.Tr "repo.modelarts.infer_job_model"}}
{{.ModelName}}   {{$.i18n.Tr "repo.modelarts.version"}}:{{.ModelVersion}}   - +
- {{$.i18n.Tr "repo.modelarts.infer_job_model_file"}} + {{$.i18n.Tr "repo.modelarts.infer_job_model_file"}}
@@ -328,10 +328,10 @@ td, th {
{{$.i18n.Tr "repo.modelarts.model_label"}}
- + {{if .LabelName}} {{range $.labelName}} {{.}} @@ -342,7 +342,7 @@ td, th {
{{$.i18n.Tr "repo.modelarts.code_version"}} @@ -358,7 +358,7 @@ td, th { {{$.i18n.Tr "repo.modelarts.train_job.start_file"}}
{{.BootFile}} @@ -367,9 +367,9 @@ td, th {
- {{$.i18n.Tr "repo.modelarts.infer_dataset"}} + {{$.i18n.Tr "repo.modelarts.infer_dataset"}}
{{.DatasetName}} @@ -378,9 +378,9 @@ td, th {
- {{$.i18n.Tr "repo.modelarts.train_job.run_parameter"}} + {{$.i18n.Tr "repo.modelarts.train_job.run_parameter"}}
{{if .Parameters}} @@ -393,9 +393,9 @@ td, th {
- {{$.i18n.Tr "repo.modelarts.train_job.standard"}} + {{$.i18n.Tr "repo.modelarts.train_job.standard"}}
{{.FlavorName}} @@ -407,10 +407,10 @@ td, th {
- + - +
- +
- +
@@ -434,34 +434,34 @@ td, th {
- +
- + {{end}} - - - - - + + + + +
@@ -493,7 +493,7 @@ function loadLog(version_name){ }); } function logScroll(version_name) { - + let container = document.querySelector(`#log${version_name}`) let scrollTop = container.scrollTop let scrollHeight = container.scrollHeight @@ -506,7 +506,7 @@ function logScroll(version_name) { $(`.message${version_name} #header`).text('您已翻阅至日志底部') $(`.message${version_name}`).css('display', 'block') setTimeout(function(){ - $(`.message${version_name}`).css('display', 'none') + $(`.message${version_name}`).css('display', 'none') }, 1000) }else{ if(end_line===data.EndLine){ @@ -514,9 +514,9 @@ function logScroll(version_name) { } else{ $(`#log${version_name} input[name=end_line]`).val(data.EndLine) - $(`#log${version_name}`).append('
' + data.Content) 
+                    $(`#log${version_name}`).append('
' + data.Content)
                 }
-                
+
             }
         }).fail(function(err) {
             console.log(err);
@@ -529,7 +529,7 @@ function logScroll(version_name) {
                 $(`.message${version_name} #header`).text('您已翻阅至日志顶部')
                 $(`.message${version_name}`).css('display', 'block')
                 setTimeout(function(){
-                    $(`.message${version_name}`).css('display', 'none')     
+                    $(`.message${version_name}`).css('display', 'none')
                 }, 1000)
             }else{
                 $(`#log${version_name} input[name=start_line]`).val(data.StartLine)   //如果变动就改变所对应的值
@@ -557,7 +557,7 @@ function loadModelFile(version_name,parents,filename,init){
     filename = filename || ''
     init = init || ''
     $.get(`/api/v1/repos/${userName}/${repoPath}/modelarts/inference-job/${jobID}/result_list?version_name=${version_name}&parentDir=${parents}`, (data) => {
-            $(`#dir_list${version_name}`).empty() 
+            $(`#dir_list${version_name}`).empty()
             renderDir(data,version_name)
             if(init==="init"){
                 $(`input[name=model${version_name}]`).val("")
@@ -565,7 +565,7 @@ function loadModelFile(version_name,parents,filename,init){
                 $(`#file_breadcrumb${version_name}`).empty()
                 let htmlBread = ""
                 htmlBread += `
result
` - htmlBread += "
/
" + htmlBread += "
/
" $(`#file_breadcrumb${version_name}`).append(htmlBread) }else{ renderBrend(version_name,parents,filename,init) @@ -573,7 +573,7 @@ function loadModelFile(version_name,parents,filename,init){ }).fail(function(err) { console.log(err,version_name); }); - + } function renderBrend(version_name,parents,filename,init){ if(init=="folder"){ @@ -586,9 +586,9 @@ function renderBrend(version_name,parents,filename,init){ }else{ $(`#file_breadcrumb${version_name} .active.section`).replaceWith(`${sectionName}`) } - + htmlBrend += `
${filename}
` - htmlBrend += "
/
" + htmlBrend += "
/
" $(`#file_breadcrumb${version_name}`).append(htmlBrend) $(`input[name=model${version_name}]`).val(parents) $(`input[name=modelback${version_name}]`).val(filename) @@ -599,7 +599,7 @@ function renderBrend(version_name,parents,filename,init){ $(`#file_breadcrumb${version_name} a.section:contains(${filename})`).replaceWith(`
${filename}
`) $(`#file_breadcrumb${version_name} div.section:contains(${filename})`).append("
/
") } - + } function renderDir(data,version_name){ let html="" @@ -638,14 +638,14 @@ function renderDir(data,version_name){ }else{ html += ""+ `${dirs_size}` + "" } - + html += "
" html += "" + data.Dirs[i].ModTime + "" html += "
" @@ -655,4 +655,4 @@ function renderDir(data,version_name){ html += "
" $(`#dir_list${version_name}`).append(html) } - \ No newline at end of file + diff --git a/templates/repo/modelarts/trainjob/index.tmpl b/templates/repo/modelarts/trainjob/index.tmpl index db077bebc..19c6b3841 100755 --- a/templates/repo/modelarts/trainjob/index.tmpl +++ b/templates/repo/modelarts/trainjob/index.tmpl @@ -188,18 +188,18 @@
diff --git a/templates/repo/modelarts/trainjob/new.tmpl b/templates/repo/modelarts/trainjob/new.tmpl index 0854f487c..6ec48bc7d 100755 --- a/templates/repo/modelarts/trainjob/new.tmpl +++ b/templates/repo/modelarts/trainjob/new.tmpl @@ -81,9 +81,9 @@
- 请输入字母、数字、_和-,最长64个字符,且不能以中划线(-)结尾。 + {{.i18n.Tr "cloudbrain.job_name_rule"}}
- +
@@ -91,7 +91,7 @@

{{.i18n.Tr "repo.modelarts.train_job.parameter_setting"}}:

- +
@@ -147,7 +147,7 @@ - 查看样例 + {{.i18n.Tr "cloudbrain.view_sample"}}
@@ -160,9 +160,9 @@ {{end}} - 数据集位置存储在环境变量data_url中,训练输出路径存储在环境变量train_url中。 + {{.i18n.Tr "cloudbrain.dataset_path_rule"}}
- +
{{.i18n.Tr "repo.modelarts.train_job.add_run_parameter"}} @@ -223,24 +223,24 @@
- +
- +
- +
{{.i18n.Tr "repo.cloudbrain.cancel"}}
- + - +
@@ -272,9 +272,9 @@ // 参数增加、删除、修改、保存 function Add_parameter(i){ value = '
' + - '
' + - ' ' + - '
' + + '
' + + ' ' + + '
' + '
' + '' + '
'+ @@ -284,7 +284,7 @@ '' + '
' $(".dynamic.field").append(value) - } + } $('#add_run_para').click(function(){ var len = $(".dynamic.field .two.fields").length @@ -310,7 +310,7 @@ $(this).find('input').each(function(){ parameters.push($(this).text()) }) - + }); $('.ui.parameter.modal') .modal('hide'); @@ -353,9 +353,9 @@ onChange: function(){ if ($('.ui.save.checkbox').checkbox('is checked')){ $('#save_para').removeClass("disabled") - + }else{ - $('#save_para').addClass("disabled") + $('#save_para').addClass("disabled") } } }); @@ -421,7 +421,7 @@ // $('.ui.page.dimmer').dimmer('show') document.getElementById("mask").style.display = "block" }, - onFailure: function(e){ + onFailure: function(e){ return false; } }) @@ -453,6 +453,6 @@ $('.ui.create_train_job.green.button').click(function(e) { get_name() send_run_para() - validate() + validate() }) - \ No newline at end of file + diff --git a/templates/repo/modelarts/trainjob/para_manage.tmpl b/templates/repo/modelarts/trainjob/para_manage.tmpl index e7e48f13b..64e769fa0 100755 --- a/templates/repo/modelarts/trainjob/para_manage.tmpl +++ b/templates/repo/modelarts/trainjob/para_manage.tmpl @@ -2,11 +2,11 @@
{{template "repo/header" .}} -
+
- {{template "repo/modelarts/navbar" .}} + {{template "repo/modelarts/navbar" .}} -
+

{{.i18n.Tr "repo.modelarts.train_job_para_admin"}}

@@ -29,7 +29,7 @@
- +
{{range .Tasks}} @@ -38,12 +38,12 @@ - - + +
{{.Status}}
@@ -59,7 +59,7 @@ 编辑
- +
@@ -69,7 +69,7 @@
- +
{{end}} {{template "base/paginate" .}} @@ -78,7 +78,7 @@
-
+
@@ -86,18 +86,18 @@
@@ -105,7 +105,7 @@
{{template "base/footer" .}} - \ No newline at end of file + diff --git a/templates/repo/modelarts/trainjob/version_new.tmpl b/templates/repo/modelarts/trainjob/version_new.tmpl index 0af0778ba..ed7334cac 100644 --- a/templates/repo/modelarts/trainjob/version_new.tmpl +++ b/templates/repo/modelarts/trainjob/version_new.tmpl @@ -97,7 +97,7 @@ {{end}}
- +
@@ -105,7 +105,7 @@

{{.i18n.Tr "repo.modelarts.train_job.parameter_setting"}}:

- +
@@ -119,7 +119,7 @@ {{end}} {{end}} - +
@@ -160,7 +160,7 @@ - 查看样例 + {{.i18n.Tr "cloudbrain.view_sample"}}
@@ -175,9 +175,9 @@ {{end}} {{end}} - 数据集位置存储在环境变量data_url中,训练输出路径存储在环境变量train_url中。 + {{.i18n.Tr "cloudbrain.dataset_path_rule"}}
- +
{{.i18n.Tr "repo.modelarts.train_job.add_run_parameter"}} @@ -243,24 +243,24 @@
- +
- +
- +
{{.i18n.Tr "repo.cloudbrain.cancel"}}
- + - +
@@ -298,9 +298,9 @@ // 参数增加、删除、修改、保存 function Add_parameter(i){ value = '
' + - '
' + - ' ' + - '
' + + '
' + + ' ' + + '
' + '
' + '' + '
'+ @@ -310,7 +310,7 @@ '' + '
' $(".dynamic.field").append(value) - } + } $('#add_run_para').click(function(){ var len = $(".dynamic.field .two.fields").length @@ -336,7 +336,7 @@ $(this).find('input').each(function(){ parameters.push($(this).text()) }) - + }); $('.ui.parameter.modal') .modal('hide'); @@ -379,9 +379,9 @@ onChange: function(){ if ($('.ui.save.checkbox').checkbox('is checked')){ $('#save_para').removeClass("disabled") - + }else{ - $('#save_para').addClass("disabled") + $('#save_para').addClass("disabled") } } }); @@ -535,7 +535,7 @@ // $('.ui.page.dimmer').dimmer('show') document.getElementById("mask").style.display = "block" }, - onFailure: function(e){ + onFailure: function(e){ return false; } }) @@ -569,6 +569,6 @@ $('.ui.create_train_job.green.button').click(function(e) { get_name() send_run_para() - validate() + validate() }) - \ No newline at end of file + diff --git a/templates/repo/modelmanage/index.tmpl b/templates/repo/modelmanage/index.tmpl index 66d66ef16..e270da017 100644 --- a/templates/repo/modelmanage/index.tmpl +++ b/templates/repo/modelmanage/index.tmpl @@ -38,7 +38,7 @@
训练任务:您还没创建过训练任务,请先创建训练任务
{{end}}
使用说明:可以参考启智AI协作平台小白训练营课程。
- +
@@ -79,10 +79,10 @@
- 取消操作 + {{.i18n.Tr "cloudbrain.operate_cancel"}}
- 确定操作 + {{.i18n.Tr "cloudbrain.operate_confirm"}}
@@ -99,7 +99,7 @@
-
+
@@ -149,8 +149,8 @@
- - + + @@ -179,7 +179,7 @@ $("#job-name").empty() createModelName() loadTrainList() - + }, onHide:function(){ document.getElementById("formId").reset(); @@ -188,7 +188,7 @@ $('.ui.dimmer').css({"background-color":""}) $('.ui.error.message').text() $('.ui.error.message').css('display','none') - + } }) .modal('show') @@ -233,7 +233,7 @@ $('#choice_model .default.text').text(data[0].DisplayJobName) $('#choice_model input[name="JobId"]').val(data[0].JobID) loadTrainVersion() - + }) } function loadTrainVersion(value){ @@ -251,7 +251,7 @@ $('#choice_version .default.text').text(data[0].VersionName) $('#choice_version input[name="VersionName"]').val(data[0].VersionName) } - + }) } From 6b85192feb6987e35f879c2a4d48fc7f1515236b Mon Sep 17 00:00:00 2001 From: Gitea Date: Sun, 20 Mar 2022 20:29:03 +0800 Subject: [PATCH 052/109] fix issue --- templates/custom/select_dataset.tmpl | 107 +++++++++++++++ templates/explore/datasets.tmpl | 4 +- templates/repo/cloudbrain/new.tmpl | 77 +++++------ templates/repo/datasets/edit.tmpl | 3 - templates/repo/datasets/index.tmpl | 17 ++- templates/repo/debugjob/index.tmpl | 1 + templates/repo/editor/upload.tmpl | 2 +- templates/repo/header.tmpl | 2 +- templates/repo/modelarts/notebook/new.tmpl | 12 +- web_src/js/components/MinioUploader.vue | 3 + web_src/js/index.js | 145 +++++++++++++++++++-- 11 files changed, 295 insertions(+), 78 deletions(-) create mode 100644 templates/custom/select_dataset.tmpl diff --git a/templates/custom/select_dataset.tmpl b/templates/custom/select_dataset.tmpl new file mode 100644 index 000000000..ef1544e74 --- /dev/null +++ b/templates/custom/select_dataset.tmpl @@ -0,0 +1,107 @@ + +
+ + + + + 选择数据集 + +
+ + +
+ + + +
+
+
${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} +
+
+
+ +
+
+ +
+
+
+ + +
+
+ + +
\ No newline at end of file diff --git a/templates/explore/datasets.tmpl b/templates/explore/datasets.tmpl index 0260db0df..f161b78da 100644 --- a/templates/explore/datasets.tmpl +++ b/templates/explore/datasets.tmpl @@ -181,7 +181,7 @@ {{end}} - {{.Page.Paginater.Total}} + @@ -206,5 +206,5 @@ {{template "base/footer" .}} \ No newline at end of file diff --git a/templates/repo/cloudbrain/new.tmpl b/templates/repo/cloudbrain/new.tmpl index c8a93ee8f..d992ecdcc 100755 --- a/templates/repo/cloudbrain/new.tmpl +++ b/templates/repo/cloudbrain/new.tmpl @@ -101,6 +101,32 @@ } + .panel_creator_reponam{ + display: inline-block; + border-radius: 4px; + padding: 4px; + font-size: 12px; + text-align: center; + background-color: rgba(161, 220, 255, 0.2); + color: #101010; + } + .panel_dataset_name{ + font-size: 15px; + color: #0366D6; + text-align: center; + margin-left: 1rem; + } + .panel_datset_desc{ + white-space: nowrap; + display: inline-block; + overflow: hidden; + width: 90%; + + text-overflow: ellipsis; + } + .el-dialog__body{ + padding-top:0 + }
@@ -116,6 +142,7 @@
{{template "repo/header" .}}
+
{{template "base/alert" .}}
@@ -200,53 +227,8 @@ {{end}}
- -
- - - - 点击打开 Dialog - -
- - -
- - - - -
-
-
asdasd
-
asdasdsd
-
-
- -
-
-
- - - - - - - - - -
-
-
- + + {{template "custom/select_dataset" .}}
- 选择数据集 + {{.i18n.Tr "dataset.select_dataset"}} @@ -21,7 +15,7 @@
- +
${dataset.Repo.OwnerName}/${dataset.Repo.Alias} ${dataset.Name}
@@ -39,7 +33,7 @@ - +
${dataset.Repo.OwnerName}/${dataset.Repo.Alias}${dataset.Name}
@@ -56,7 +50,7 @@
- +
${dataset.Repo.OwnerName}/${dataset.Repo.Alias}${dataset.Name}
@@ -73,7 +67,7 @@
- +
${dataset.Repo.OwnerName}/${dataset.Repo.Alias}${dataset.Name}
From 7d6272e23bc8ab015a9a0eabe7780008fe046732 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Mon, 21 Mar 2022 14:52:49 +0800 Subject: [PATCH 057/109] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E5=85=AC=E5=BC=80=E6=95=B0=E6=8D=AE=E9=9B=86=E5=85=AC=E5=BC=80?= =?UTF-8?q?(=E9=87=8C=E9=9D=A2=E7=9A=84=E6=96=87=E4=BB=B6=E4=B8=8D?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=85=AC=E5=BC=80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/repo.go | 11 ++++++++++- routers/repo/dataset.go | 10 ---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/models/repo.go b/models/repo.go index 9bb4b9d03..d8dda45f9 100755 --- a/models/repo.go +++ b/models/repo.go @@ -1583,7 +1583,7 @@ func updateRepository(e Engine, repo *Repository, visibilityChanged bool) (err e return err } //If repo has become private, we need set dataset and dataset_file to private - _, err = e.Where("repo_id = ?", repo.ID).Cols("status").Update(&Dataset{ + _, err = e.Where("repo_id = ? and status <> 2", repo.ID).Cols("status").Update(&Dataset{ Status: 0, }) if err != nil { @@ -1601,6 +1601,15 @@ func updateRepository(e Engine, repo *Repository, visibilityChanged bool) (err e return err } + } else { + //If repo has become public, we need set dataset to public + _, err = e.Where("repo_id = ? and status <> 2", repo.ID).Cols("status").Update(&Dataset{ + Status: 1, + }) + if err != nil { + return err + } + } // Create/Remove git-daemon-export-ok for git-daemon... diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index f3d464ad3..fefb84af3 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -110,16 +110,6 @@ func DatasetIndex(ctx *context.Context) { repo := ctx.Repo.Repository dataset, err := models.GetDatasetByRepo(repo) - canRead := false - if ctx.IsSigned { - isCollaborator, err := repo.IsCollaborator(ctx.User.ID) - if err != nil { - canRead = false - } else if ctx.User.IsAdmin || isCollaborator { - canRead = true - } - } - ctx.Data["CanRead"] = canRead ctx.Data["CanWrite"] = ctx.Repo.CanWrite(models.UnitTypeDatasets) if err != nil { log.Warn("query dataset, not found.") From 436d91b700816f24653a6cadc3795176ca7c6276 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Mon, 21 Mar 2022 14:57:57 +0800 Subject: [PATCH 058/109] fix issue --- templates/repo/debugjob/index.tmpl | 2 +- web_src/js/features/cloudrbanin.js | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/templates/repo/debugjob/index.tmpl b/templates/repo/debugjob/index.tmpl index ab6e266af..ddcccc926 100755 --- a/templates/repo/debugjob/index.tmpl +++ b/templates/repo/debugjob/index.tmpl @@ -208,7 +208,7 @@ {{template "repo/header" .}} {{template "base/alert" .}} - +
diff --git a/web_src/js/features/cloudrbanin.js b/web_src/js/features/cloudrbanin.js index d069c6840..216226e14 100644 --- a/web_src/js/features/cloudrbanin.js +++ b/web_src/js/features/cloudrbanin.js @@ -1,4 +1,6 @@ export default async function initCloudrain() { + let debug_button = $('.cloudbrain_debug').data('debug') + let debug_again_button = $('.cloudbrain_debug').data('debug-again') let timeid = window.setInterval(loadJobStatus, 15000); $(document).ready(loadJobStatus); function loadJobStatus() { @@ -24,7 +26,7 @@ export default async function initCloudrain() { finalState.includes(status) && $('#' + ID + '-stop').removeClass('blue').addClass('disabled') } if(status==="RUNNING"){ - $('#ai-debug-'+ID).removeClass('disabled').addClass('blue').text('调试').css("margin","0 1rem") + $('#ai-debug-'+ID).removeClass('disabled').addClass('blue').text(debug_button).css("margin","0 1rem") $('#model-image-'+ID).removeClass('disabled').addClass('blue') } if(status!=="RUNNING"){ @@ -36,7 +38,7 @@ export default async function initCloudrain() { $('#ai-debug-'+ID).removeClass('blue').addClass('disabled') } if(['STOPPED','FAILED','START_FAILED','CREATE_FAILED','SUCCEEDED'].includes(status)){ - $('#ai-debug-'+ID).removeClass('disabled').addClass('blue').text('再次调试').css("margin","0") + $('#ai-debug-'+ID).removeClass('disabled').addClass('blue').text(debug_again_button).css("margin","0") } if(["RUNNING","WAITING"].includes(status)){ $('#ai-stop-'+ID).removeClass('disabled').addClass('blue') @@ -114,7 +116,7 @@ export default async function initCloudrain() { $('#' + ID+'-icon').removeClass().addClass(res.status) $('#' + ID+ '-text').text(res.status) if(res.status==="STOPPED"){ - $('#ai-debug-'+ID).removeClass('disabled').addClass('blue').text("再次调试").css("margin","0") + $('#ai-debug-'+ID).removeClass('disabled').addClass('blue').text(debug_again_button).css("margin","0") $('#ai-image-'+ID).removeClass('blue').addClass('disabled') $('#ai-model-debug-'+ID).removeClass('blue').addClass('disabled') $('#ai-delete-'+ID).removeClass('disabled').addClass('blue') @@ -214,7 +216,7 @@ export default async function initCloudrain() { $('#' + ID+ '-text').text(res.status) $('#ai-debug-'+ID).removeClass('blue').addClass('disabled') $('#ai-delete-'+ID).removeClass('blue').addClass('disabled') - $('#ai-debug-'+ID).text("调试").css("margin","0 1rem") + $('#ai-debug-'+ID).text(debug_button).css("margin","0 1rem") } }else{ $('.alert').html(res.error_msg).removeClass('alert-success').addClass('alert-danger').show().delay(2000).fadeOut(); From fed732b86a48f847128aafc5bede369c282497b3 Mon Sep 17 00:00:00 2001 From: liuzx Date: Mon, 21 Mar 2022 15:00:28 +0800 Subject: [PATCH 059/109] fix-bug --- models/attachment.go | 9 +++++++ routers/repo/dataset.go | 57 ++++++++++++++++++++++------------------- 2 files changed, 40 insertions(+), 26 deletions(-) diff --git a/models/attachment.go b/models/attachment.go index 086426bf2..50bb89192 100755 --- a/models/attachment.go +++ b/models/attachment.go @@ -73,6 +73,7 @@ type AttachmentsOptions struct { NeedDatasetIDs bool NeedIsPrivate bool IsPrivate bool + JustNeedZipFile bool NeedRepoInfo bool Keyword string } @@ -568,6 +569,14 @@ func Attachments(opts *AttachmentsOptions) ([]*AttachmentInfo, int64, error) { ) } + if opts.JustNeedZipFile { + var DecompressState []int + DecompressState = append(DecompressState, 1, 2, 3) + cond = cond.And( + builder.In("attachment.decompress_state", DecompressState), + ) + } + var count int64 var err error if len(opts.Keyword) == 0 { diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index f3d464ad3..22a15b172 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -311,6 +311,7 @@ func CurrentRepoDataset(ctx *context.Context) { dataset, err := models.GetDatasetByRepo(repo) if err != nil { ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr("GetDatasetByRepo failed", err))) + return } datasetIDs = append(datasetIDs, dataset.ID) uploaderID := ctx.User.ID @@ -319,13 +320,14 @@ func CurrentRepoDataset(ctx *context.Context) { Page: page, PageSize: setting.UI.DatasetPagingNum, }, - Keyword: keyword, - NeedDatasetIDs: true, - DatasetIDs: datasetIDs, - UploaderID: uploaderID, - Type: cloudbrainType, - NeedIsPrivate: false, - NeedRepoInfo: true, + Keyword: keyword, + NeedDatasetIDs: true, + DatasetIDs: datasetIDs, + UploaderID: uploaderID, + Type: cloudbrainType, + NeedIsPrivate: false, + JustNeedZipFile: true, + NeedRepoInfo: true, }) if err != nil { ctx.ServerError("datasets", err) @@ -360,12 +362,13 @@ func MyDatasets(ctx *context.Context) { Page: page, PageSize: setting.UI.DatasetPagingNum, }, - Keyword: keyword, - NeedDatasetIDs: false, - UploaderID: uploaderID, - Type: cloudbrainType, - NeedIsPrivate: false, - NeedRepoInfo: true, + Keyword: keyword, + NeedDatasetIDs: false, + UploaderID: uploaderID, + Type: cloudbrainType, + NeedIsPrivate: false, + JustNeedZipFile: true, + NeedRepoInfo: true, }) if err != nil { ctx.ServerError("datasets", err) @@ -399,12 +402,13 @@ func PublicDataset(ctx *context.Context) { Page: page, PageSize: setting.UI.DatasetPagingNum, }, - Keyword: keyword, - NeedDatasetIDs: false, - NeedIsPrivate: true, - IsPrivate: false, - Type: cloudbrainType, - NeedRepoInfo: true, + Keyword: keyword, + NeedDatasetIDs: false, + NeedIsPrivate: true, + IsPrivate: false, + Type: cloudbrainType, + JustNeedZipFile: true, + NeedRepoInfo: true, }) if err != nil { ctx.ServerError("datasets", err) @@ -453,13 +457,14 @@ func MyFavoriteDataset(ctx *context.Context) { Page: page, PageSize: setting.UI.DatasetPagingNum, }, - Keyword: keyword, - NeedDatasetIDs: true, - DatasetIDs: datasetIDs, - NeedIsPrivate: true, - IsPrivate: false, - Type: cloudbrainType, - NeedRepoInfo: true, + Keyword: keyword, + NeedDatasetIDs: true, + DatasetIDs: datasetIDs, + NeedIsPrivate: true, + IsPrivate: false, + Type: cloudbrainType, + JustNeedZipFile: true, + NeedRepoInfo: true, }) if err != nil { ctx.ServerError("datasets", err) From 13c19dd5040b75e025f8d1074031523e1040b42c Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Mon, 21 Mar 2022 15:03:39 +0800 Subject: [PATCH 060/109] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/templates/helper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 9732e8537..77c6fca8d 100755 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -752,5 +752,5 @@ func licenses() []string { // Dataset tasks func tasks() []string { - return []string{"machine_translation", "question_answering_system", "information_retrieval", "knowledge_graph", "text_annotation", "text_categorization", "emotion_analysis", "language_modeling", "speech_recognition", "automatic_digest", "information_extraction", "description_generation", "image_classification", "face_recognition", "image_search", "target_detection", "image_description_generation", "vehicle_license_plate_recognition", "medical_image_analysis", "unmanned", "unmanned_security", "drone", "vr_ar", "2_d_vision", "2.5_d_vision", "3_d_reconstruction", "image_processing", "video_processing", "visual_input_system", "speech_coding", "speech_enhancement", "speech_recognition", "speech_synthesis"} + return []string{"machine_translation", "question_answering_system", "information_retrieval", "knowledge_graph", "text_annotation", "text_categorization", "emotion_analysis", "language_modeling", "speech_recognition", "automatic_digest", "information_extraction", "description_generation", "image_classification", "face_recognition", "image_search", "target_detection", "image_description_generation", "vehicle_license_plate_recognition", "medical_image_analysis", "unmanned", "unmanned_security", "drone", "vr_ar", "2_d_vision", "2.5_d_vision", "3_d_reconstruction", "image_processing", "video_processing", "visual_input_system", "speech_coding", "speech_enhancement", "speech_synthesis"} } From a4ad2cb7c834c1121bb39c163f94f89cf8dc1284 Mon Sep 17 00:00:00 2001 From: wangjr Date: Mon, 21 Mar 2022 15:10:03 +0800 Subject: [PATCH 061/109] =?UTF-8?q?fix-1657=20=E5=89=8D=E7=AB=AF=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=B1=95=E7=A4=BA=E6=96=B0=E5=A2=9E=E5=8A=A0=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web_src/js/components/ProAnalysis.vue | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/web_src/js/components/ProAnalysis.vue b/web_src/js/components/ProAnalysis.vue index 88ea67d94..d92eb6df9 100755 --- a/web_src/js/components/ProAnalysis.vue +++ b/web_src/js/components/ProAnalysis.vue @@ -148,6 +148,31 @@ prop="contributor" label="贡献者数" align="center"> + + + + + + + + +
@@ -1140,6 +1165,17 @@ return " " +value.user+ "" } + }, + transformTimestamp(timestamp){ + let a = new Date(timestamp*1000); + const date = new Date(a); + const Y = date.getFullYear() + '/'; + const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '/'; + const D = (date.getDate() < 10 ? '0'+date.getDate() : date.getDate()) + ' '; + const h = (date.getHours() < 10 ? '0'+date.getHours() : date.getHours()) + ':'; + const m = (date.getMinutes() <10 ? '0'+date.getMinutes() : date.getMinutes()); + const dateString = Y + M + D + h + m ;//+ s; + return dateString; }, }, From f059d9e4def08ab55afc7e5171f644e069f7781d Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Mon, 21 Mar 2022 15:12:39 +0800 Subject: [PATCH 062/109] fix issue --- options/locale/locale_en-US.ini | 1 + options/locale/locale_zh-CN.ini | 3 ++- templates/custom/select_dataset.tmpl | 8 ++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index c98871f57..6fc5baeb7 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -795,6 +795,7 @@ current_project=Current Project owner_dataset=Owner Dataset public_dataset=Public Dataset I_liked = I Liked +use = Use [repo] owner = Owner repo_name = Repository Name diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 27f2bf23b..5bedfd0bf 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -799,7 +799,8 @@ select_dataset=选择数据集 current_project=当前项目 owner_dataset=我的数据集 public_dataset=公开数据集 -I_liked=我点赞的 +I_liked=我收藏的 +use=使用 [repo] owner=拥有者 repo_name=项目名称 diff --git a/templates/custom/select_dataset.tmpl b/templates/custom/select_dataset.tmpl index a09849817..c782efc28 100644 --- a/templates/custom/select_dataset.tmpl +++ b/templates/custom/select_dataset.tmpl @@ -27,7 +27,7 @@
- +
@@ -45,7 +45,7 @@
- +
@@ -62,7 +62,7 @@
- +
@@ -79,7 +79,7 @@
- +
From 8e11b7bef37661393998a4f9c327844a78301f40 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Mon, 21 Mar 2022 15:13:36 +0800 Subject: [PATCH 063/109] #1627 update --- options/locale/locale_en-US.ini | 2 ++ options/locale/locale_zh-CN.ini | 2 +- routers/repo/cloudbrain.go | 25 ++++++++++++++----------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index e01eddcd4..dbe9c8985 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -992,6 +992,8 @@ cloudbrain.benchmark.evaluate_child_type=Child Type cloudbrain.benchmark.evaluate_mirror=Mirror cloudbrain.benchmark.evaluate_train=Train Script cloudbrain.benchmark.evaluate_test=Test Script +cloudbrain.benchmark.types={"type":[{"id":1,"first":"Target detection","second":[{"id":1,"value":"None","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"yangzhx","repo_name":"detection_benchmark_script"}]},{"id":2,"first":"Target Re-identification","second":[{"id":1,"value":"Vehicle re-identification","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"},{"id":2,"value":"Image-based person re-identification","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"}]}]} + modelarts.infer_job_model = Model modelarts.infer_job_model_file = Model File modelarts.infer_job = Inference Job diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 9a01ae4c8..09cf839c7 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -998,7 +998,7 @@ cloudbrain.benchmark.evaluate_child_type=子类型 cloudbrain.benchmark.evaluate_mirror=镜像 cloudbrain.benchmark.evaluate_train=训练程序 cloudbrain.benchmark.evaluate_test=测试程序 - +cloudbrain.benchmark.types={"type":[{"id":1,"first":"目标检测","second":[{"id":1,"value":"无","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"yangzhx","repo_name":"detection_benchmark_script"}]},{"id":2,"first":"目标重识别","second":[{"id":1,"value":"车辆重识别","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"},{"id":2,"value":"基于图像的行人重识别","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"}]}]} modelarts.infer_job_model = 模型名称 modelarts.infer_job_model_file = 模型文件 diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 6e88b266d..78ea8ea72 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + "github.com/unknwon/i18n" "io" "net/http" "os" @@ -45,6 +46,8 @@ var ( benchmarkResourceSpecs *models.ResourceSpecs ) +const BENCHMARK_TYPE_CODE = "repo.cloudbrain.benchmark.types" + var jobNamePattern = regexp.MustCompile(`^[a-z0-9][a-z0-9-_]{1,34}[a-z0-9-]$`) // MustEnableDataset check if repository enable internal cb @@ -131,8 +134,8 @@ func cloudBrainNewDataPrepare(ctx *context.Context) error { ctx.Data["benchmark_categories"] = categories.Category if benchmarkTypes == nil { - if err := json.Unmarshal([]byte(setting.BenchmarkTypes), &benchmarkTypes); err != nil { - log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", setting.BenchmarkTypes, err, ctx.Data["MsgID"]) + if err := json.Unmarshal([]byte(i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE)), &benchmarkTypes); err != nil { + log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE), err, ctx.Data["MsgID"]) } } ctx.Data["benchmark_types"] = benchmarkTypes.BenchmarkType @@ -340,8 +343,8 @@ func CloudBrainRestart(ctx *context.Context) { func CloudBrainBenchMarkShow(ctx *context.Context) { if benchmarkTypes == nil { - if err := json.Unmarshal([]byte(setting.BenchmarkTypes), &benchmarkTypes); err != nil { - log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", setting.BenchmarkTypes, err, ctx.Data["MsgID"]) + if err := json.Unmarshal([]byte(i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE)), &benchmarkTypes); err != nil { + log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE), err, ctx.Data["MsgID"]) ctx.ServerError(err.Error(), err) return } @@ -1060,7 +1063,7 @@ func CloudBrainBenchmarkIndex(ctx *context.Context) { } if benchmarkTypes == nil { - if err := json.Unmarshal([]byte(setting.BenchmarkTypes), &benchmarkTypes); err != nil { + if err := json.Unmarshal([]byte(i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE)), &benchmarkTypes); err != nil { ctx.ServerError("Get BenchmarkTypes faild:", err) return } @@ -1103,8 +1106,8 @@ func GetChildTypes(ctx *context.Context) { re := make(map[string]interface{}) for { if benchmarkTypes == nil { - if err := json.Unmarshal([]byte(setting.BenchmarkTypes), &benchmarkTypes); err != nil { - log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", setting.BenchmarkTypes, err, ctx.Data["MsgID"]) + if err := json.Unmarshal([]byte(i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE)), &benchmarkTypes); err != nil { + log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE), err, ctx.Data["MsgID"]) re["errMsg"] = "system error" break } @@ -1141,11 +1144,11 @@ func CloudBrainBenchmarkNew(ctx *context.Context) { ctx.HTML(200, tplCloudBrainBenchmarkNew) } -func getBenchmarkAttachment(benchmarkTypeID, benchmarkChildTypeID int) (*models.BenchmarkDataset, error) { +func getBenchmarkAttachment(benchmarkTypeID, benchmarkChildTypeID int, ctx *context.Context) (*models.BenchmarkDataset, error) { var childInfo *models.BenchmarkDataset if benchmarkTypes == nil { - if err := json.Unmarshal([]byte(setting.BenchmarkTypes), &benchmarkTypes); err != nil { - log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", setting.BenchmarkTypes, err) + if err := json.Unmarshal([]byte(i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE)), &benchmarkTypes); err != nil { + log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE), err) return childInfo, err } } @@ -1265,7 +1268,7 @@ func CloudBrainBenchmarkCreate(ctx *context.Context, form auth.CreateCloudBrainF return } - childInfo, err := getBenchmarkAttachment(benchmarkTypeID, benchmarkChildTypeID) + childInfo, err := getBenchmarkAttachment(benchmarkTypeID, benchmarkChildTypeID, ctx) if err != nil { log.Error("getBenchmarkAttachment failed:%v", err, ctx.Data["MsgID"]) cloudBrainNewDataPrepare(ctx) From 71e43839eab41dbaa3476336151e83fb4de7a524 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Mon, 21 Mar 2022 15:22:52 +0800 Subject: [PATCH 064/109] #1627 update --- templates/repo/modelarts/inferencejob/new.tmpl | 4 ++-- templates/repo/modelarts/trainjob/new.tmpl | 4 ++-- templates/repo/modelarts/trainjob/version_new.tmpl | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/templates/repo/modelarts/inferencejob/new.tmpl b/templates/repo/modelarts/inferencejob/new.tmpl index 6f174bbbb..27d047783 100644 --- a/templates/repo/modelarts/inferencejob/new.tmpl +++ b/templates/repo/modelarts/inferencejob/new.tmpl @@ -171,12 +171,12 @@
     - {{if $.uuid}} {{end}} {{range .attachments}} - + {{end}} diff --git a/templates/repo/modelarts/trainjob/new.tmpl b/templates/repo/modelarts/trainjob/new.tmpl index 6ec48bc7d..8366f8a37 100755 --- a/templates/repo/modelarts/trainjob/new.tmpl +++ b/templates/repo/modelarts/trainjob/new.tmpl @@ -151,12 +151,12 @@
- {{if $.uuid}} {{end}} {{range .attachments}} - + {{end}} diff --git a/templates/repo/modelarts/trainjob/version_new.tmpl b/templates/repo/modelarts/trainjob/version_new.tmpl index ed7334cac..e69709a7c 100644 --- a/templates/repo/modelarts/trainjob/version_new.tmpl +++ b/templates/repo/modelarts/trainjob/version_new.tmpl @@ -164,12 +164,12 @@
- {{if .dataset_name}} {{end}} {{range .attachments}} - + {{if ne $.uuid .UUID}} {{end}} From e4390b601f51d3f00d7dceb9fc2122128d0bc5ea Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Mon, 21 Mar 2022 15:28:59 +0800 Subject: [PATCH 065/109] #1627 update --- templates/repo/modelarts/inferencejob/new.tmpl | 2 +- templates/repo/modelarts/trainjob/new.tmpl | 2 +- templates/repo/modelarts/trainjob/version_new.tmpl | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/repo/modelarts/inferencejob/new.tmpl b/templates/repo/modelarts/inferencejob/new.tmpl index 27d047783..5e7347abf 100644 --- a/templates/repo/modelarts/inferencejob/new.tmpl +++ b/templates/repo/modelarts/inferencejob/new.tmpl @@ -176,7 +176,7 @@ {{end}} {{range .attachments}} - + {{end}} diff --git a/templates/repo/modelarts/trainjob/new.tmpl b/templates/repo/modelarts/trainjob/new.tmpl index 8366f8a37..afa09cf29 100755 --- a/templates/repo/modelarts/trainjob/new.tmpl +++ b/templates/repo/modelarts/trainjob/new.tmpl @@ -156,7 +156,7 @@ {{end}} {{range .attachments}} - + {{end}} diff --git a/templates/repo/modelarts/trainjob/version_new.tmpl b/templates/repo/modelarts/trainjob/version_new.tmpl index e69709a7c..b7fcd36ad 100644 --- a/templates/repo/modelarts/trainjob/version_new.tmpl +++ b/templates/repo/modelarts/trainjob/version_new.tmpl @@ -169,7 +169,7 @@ {{end}} {{range .attachments}} - + {{if ne $.uuid .UUID}} {{end}} From 2087b2d410a5f4b6356408554cbdd4b302d01b77 Mon Sep 17 00:00:00 2001 From: liuzx Date: Mon, 21 Mar 2022 15:30:07 +0800 Subject: [PATCH 066/109] fix-bug --- routers/api/v1/api.go | 3 --- routers/api/v1/repo/dataset.go | 27 --------------------------- routers/repo/dataset.go | 26 ++++++++++++++++++++++++++ routers/routes/routes.go | 4 ++++ 4 files changed, 30 insertions(+), 30 deletions(-) delete mode 100644 routers/api/v1/repo/dataset.go diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index f31c0da9e..ef5ee6699 100755 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -879,9 +879,6 @@ func RegisterRoutes(m *macaron.Macaron) { Delete(reqToken(), repo.DeleteTopic) }, reqAdmin()) }, reqAnyRepoReader()) - m.Group("/dataset", func() { - m.Get("/:uuid", repo.GetAttachmentStatus) - }, reqRepoReader(models.UnitTypeCloudBrain)) m.Group("/cloudbrain", func() { m.Get("/:jobid", repo.GetCloudbrainTask) m.Get("/:jobname/log", repo.CloudbrainGetLog) diff --git a/routers/api/v1/repo/dataset.go b/routers/api/v1/repo/dataset.go deleted file mode 100644 index b9a725cd9..000000000 --- a/routers/api/v1/repo/dataset.go +++ /dev/null @@ -1,27 +0,0 @@ -package repo - -import ( - "net/http" - - "code.gitea.io/gitea/models" - "code.gitea.io/gitea/modules/context" -) - -func GetAttachmentStatus(ctx *context.APIContext) { - - var ( - err error - ) - - UUID := ctx.Params(":uuid") - attachment, err := models.GetAttachmentByUUID(UUID) - if err != nil { - ctx.Data["error"] = err.Error() - } - - ctx.JSON(http.StatusOK, map[string]interface{}{ - "UUID": UUID, - "AttachmentStatus": attachment.DecompressState, - }) - -} diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index ad1944b1e..1d5ad39ae 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -2,6 +2,7 @@ package repo import ( "encoding/json" + "fmt" "net/http" "regexp" "sort" @@ -478,3 +479,28 @@ func MyFavoriteDataset(ctx *context.Context) { }) } + +func GetDatasetStatus(ctx *context.Context) { + + var ( + err error + ) + + UUID := ctx.Params(":uuid") + attachment, err := models.GetAttachmentByUUID(UUID) + if err != nil { + log.Error("GetDatasetStarByUser failed:", err.Error()) + ctx.JSON(200, map[string]string{ + "result_code": "-1", + "error_msg": err.Error(), + "data": "", + }) + return + } + + ctx.JSON(200, map[string]string{ + "result_code": "0", + "UUID": UUID, + "AttachmentStatus": fmt.Sprint(attachment.DecompressState), + }) +} diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 226c4c34d..92bf86471 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -992,6 +992,10 @@ func RegisterRoutes(m *macaron.Macaron) { m.Get("/public_datasets", repo.PublicDataset) m.Get("/my_favorite", repo.MyFavoriteDataset) + m.Group("/status", func() { + m.Get("/:uuid", repo.GetDatasetStatus) + }) + m.Group("/dirs", func() { m.Get("/:uuid", reqRepoDatasetReader, repo.DirIndex) }) From 5db959d68f9ada7b50a1751b8391abdedbf31d83 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Mon, 21 Mar 2022 15:40:49 +0800 Subject: [PATCH 067/109] #1627 update --- options/locale/locale_en-US.ini | 2 +- options/locale/locale_zh-CN.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index dbe9c8985..0b486117e 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -992,7 +992,7 @@ cloudbrain.benchmark.evaluate_child_type=Child Type cloudbrain.benchmark.evaluate_mirror=Mirror cloudbrain.benchmark.evaluate_train=Train Script cloudbrain.benchmark.evaluate_test=Test Script -cloudbrain.benchmark.types={"type":[{"id":1,"first":"Target detection","second":[{"id":1,"value":"None","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"yangzhx","repo_name":"detection_benchmark_script"}]},{"id":2,"first":"Target Re-identification","second":[{"id":1,"value":"Vehicle re-identification","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"},{"id":2,"value":"Image-based person re-identification","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"}]}]} +cloudbrain.benchmark.types={"type":[{"id":1,"rank_link":"https://git.openi.org.cn/benchmark/?username=admin&algType=detection","first":"Target detection","second":[{"id":1,"value":"None","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"yangzhx","repo_name":"detection_benchmark_script"}]},{"id":2,"rank_link":"https://git.openi.org.cn/benchmark/?username=admin&algType=reid","first":"Target re-identification","second":[{"id":1,"value":"Vehicle re-identification","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"},{"id":2,"value":"Image-based person re-identification","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"}]},{"id":3,"rank_link":"https://git.openi.org.cn/benchmark/?username=admin&algType=tracking","first":"Multi-target tracking","second":[{"id":1,"value":"None","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"lix07","repo_name":"MOT_benchmark_script"}]}]} modelarts.infer_job_model = Model modelarts.infer_job_model_file = Model File diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 09cf839c7..5ef5cb8e6 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -998,7 +998,7 @@ cloudbrain.benchmark.evaluate_child_type=子类型 cloudbrain.benchmark.evaluate_mirror=镜像 cloudbrain.benchmark.evaluate_train=训练程序 cloudbrain.benchmark.evaluate_test=测试程序 -cloudbrain.benchmark.types={"type":[{"id":1,"first":"目标检测","second":[{"id":1,"value":"无","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"yangzhx","repo_name":"detection_benchmark_script"}]},{"id":2,"first":"目标重识别","second":[{"id":1,"value":"车辆重识别","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"},{"id":2,"value":"基于图像的行人重识别","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"}]}]} +cloudbrain.benchmark.types={"type":[{"id":1,"rank_link":"https://git.openi.org.cn/benchmark/?username=admin&algType=detection","first":"目标检测","second":[{"id":1,"value":"无","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"yangzhx","repo_name":"detection_benchmark_script"}]},{"id":2,"rank_link":"https://git.openi.org.cn/benchmark/?username=admin&algType=reid","first":"目标重识别","second":[{"id":1,"value":"车辆重识别","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"},{"id":2,"value":"基于图像的行人重识别","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"JiahongXu","repo_name":"benchmark_reID_script"}]},{"id":3,"rank_link":"https://git.openi.org.cn/benchmark/?username=admin&algType=tracking","first":"多目标跟踪","second":[{"id":1,"value":"无","attachment":"84cf39c4-d8bc-41aa-aaa3-182ce289b105","owner":"lix07","repo_name":"MOT_benchmark_script"}]}]} modelarts.infer_job_model = 模型名称 modelarts.infer_job_model_file = 模型文件 From 4af02f5997955cea87ece96563213f0a234a250d Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Mon, 21 Mar 2022 16:23:33 +0800 Subject: [PATCH 068/109] #1627 fix bug --- routers/repo/cloudbrain.go | 58 ++++++++++++++------------------------ 1 file changed, 21 insertions(+), 37 deletions(-) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 78ea8ea72..65db818a0 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -48,6 +48,8 @@ var ( const BENCHMARK_TYPE_CODE = "repo.cloudbrain.benchmark.types" +var benchmarkTypesMap = make(map[string]*models.BenchmarkTypes, 0) + var jobNamePattern = regexp.MustCompile(`^[a-z0-9][a-z0-9-_]{1,34}[a-z0-9-]$`) // MustEnableDataset check if repository enable internal cb @@ -133,12 +135,7 @@ func cloudBrainNewDataPrepare(ctx *context.Context) error { } ctx.Data["benchmark_categories"] = categories.Category - if benchmarkTypes == nil { - if err := json.Unmarshal([]byte(i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE)), &benchmarkTypes); err != nil { - log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE), err, ctx.Data["MsgID"]) - } - } - ctx.Data["benchmark_types"] = benchmarkTypes.BenchmarkType + ctx.Data["benchmark_types"] = GetBenchmarkTypes(ctx).BenchmarkType if gpuInfos == nil { json.Unmarshal([]byte(setting.GpuTypes), &gpuInfos) @@ -342,13 +339,6 @@ func CloudBrainRestart(ctx *context.Context) { } func CloudBrainBenchMarkShow(ctx *context.Context) { - if benchmarkTypes == nil { - if err := json.Unmarshal([]byte(i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE)), &benchmarkTypes); err != nil { - log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE), err, ctx.Data["MsgID"]) - ctx.ServerError(err.Error(), err) - return - } - } cloudBrainShow(ctx, tplCloudBrainBenchmarkShow) } @@ -415,7 +405,7 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName) { duration = int64(task.UpdatedUnix) - int64(task.CreatedUnix) } if task.BenchmarkTypeID > 0 { - for _, benchmarkType := range benchmarkTypes.BenchmarkType { + for _, benchmarkType := range GetBenchmarkTypes(ctx).BenchmarkType { if task.BenchmarkTypeID == benchmarkType.Id { ctx.Data["BenchmarkTypeName"] = benchmarkType.First for _, benchmarkChildType := range benchmarkType.Second { @@ -1062,13 +1052,6 @@ func CloudBrainBenchmarkIndex(ctx *context.Context) { return } - if benchmarkTypes == nil { - if err := json.Unmarshal([]byte(i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE)), &benchmarkTypes); err != nil { - ctx.ServerError("Get BenchmarkTypes faild:", err) - return - } - } - for i, task := range ciTasks { ciTasks[i].CanDel = cloudbrain.CanDeleteJob(ctx, &task.Cloudbrain) ciTasks[i].Cloudbrain.ComputeResource = task.ComputeResource @@ -1081,7 +1064,7 @@ func CloudBrainBenchmarkIndex(ctx *context.Context) { ciTasks[i].TrainJobDuration = util.AddZero(duration/3600000) + ":" + util.AddZero(duration%3600000/60000) + ":" + util.AddZero(duration%60000/1000) ciTasks[i].BenchmarkTypeName = "" if task.BenchmarkTypeID > 0 { - for _, benchmarkType := range benchmarkTypes.BenchmarkType { + for _, benchmarkType := range GetBenchmarkTypes(ctx).BenchmarkType { if task.BenchmarkTypeID == benchmarkType.Id { ciTasks[i].BenchmarkTypeRankLink = benchmarkType.RankLink ciTasks[i].BenchmarkTypeName = benchmarkType.First @@ -1105,15 +1088,8 @@ func GetChildTypes(ctx *context.Context) { benchmarkTypeID := ctx.QueryInt("benchmark_type_id") re := make(map[string]interface{}) for { - if benchmarkTypes == nil { - if err := json.Unmarshal([]byte(i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE)), &benchmarkTypes); err != nil { - log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE), err, ctx.Data["MsgID"]) - re["errMsg"] = "system error" - break - } - } var isExist bool - for _, benchmarkType := range benchmarkTypes.BenchmarkType { + for _, benchmarkType := range GetBenchmarkTypes(ctx).BenchmarkType { if benchmarkTypeID == benchmarkType.Id { isExist = true re["child_types"] = benchmarkType.Second @@ -1146,15 +1122,9 @@ func CloudBrainBenchmarkNew(ctx *context.Context) { func getBenchmarkAttachment(benchmarkTypeID, benchmarkChildTypeID int, ctx *context.Context) (*models.BenchmarkDataset, error) { var childInfo *models.BenchmarkDataset - if benchmarkTypes == nil { - if err := json.Unmarshal([]byte(i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE)), &benchmarkTypes); err != nil { - log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", i18n.Tr(ctx.Locale.Language(), BENCHMARK_TYPE_CODE), err) - return childInfo, err - } - } var isExist bool - for _, benchmarkType := range benchmarkTypes.BenchmarkType { + for _, benchmarkType := range GetBenchmarkTypes(ctx).BenchmarkType { if benchmarkType.Id == benchmarkTypeID { for _, childType := range benchmarkType.Second { if childType.Id == benchmarkChildTypeID { @@ -1398,3 +1368,17 @@ func BenchmarkDel(ctx *context.Context) { ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/cloudbrain/benchmark") } } + +func GetBenchmarkTypes(ctx *context.Context) *models.BenchmarkTypes { + var lang = ctx.Locale.Language() + if benchmarkTypesMap[lang] == nil { + var val = i18n.Tr(lang, BENCHMARK_TYPE_CODE) + var tempType *models.BenchmarkTypes + if err := json.Unmarshal([]byte(val), &tempType); err != nil { + log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", val, err, ctx.Data["MsgID"]) + return &models.BenchmarkTypes{} + } + benchmarkTypesMap[lang] = tempType + } + return benchmarkTypesMap[lang] +} From d78c61488282d3801ae3c05effaf13448c1dab5d Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Mon, 21 Mar 2022 16:32:23 +0800 Subject: [PATCH 069/109] fix-1694 --- models/cloudbrain.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/cloudbrain.go b/models/cloudbrain.go index 06c2e98b4..f501d8e91 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -1117,7 +1117,7 @@ func Cloudbrains(opts *CloudbrainsOptions) ([]*CloudbrainInfo, int64, error) { } else { lowerKeyWord := strings.ToLower(opts.Keyword) - cond = cond.And(builder.Or(builder.Like{"LOWER(cloudbrain.job_name)", lowerKeyWord}, builder.Like{"`user`.lower_name", lowerKeyWord})) + cond = cond.And(builder.Or(builder.Like{"LOWER(cloudbrain.job_name)", lowerKeyWord}, builder.Like{"LOWER(cloudbrain.display_job_name)", lowerKeyWord}, builder.Like{"`user`.lower_name", lowerKeyWord})) count, err = sess.Table(&Cloudbrain{}).Where(cond). Join("left", "`user`", condition).Count(new(CloudbrainInfo)) From a1d029efb0ad1ebc32447cd7bdd926ee24d20674 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Tue, 22 Mar 2022 11:51:26 +0800 Subject: [PATCH 070/109] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E9=A1=B5=E9=80=89=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/repo/attachment.go | 2 ++ routers/repo/dataset.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index 54d7076c6..ebe787303 100755 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -71,6 +71,7 @@ func renderAttachmentSettings(ctx *context.Context) { func UploadAttachmentUI(ctx *context.Context) { ctx.Data["datasetId"] = ctx.Query("datasetId") + ctx.Data["PageIsDataset"] = true dataset, _ := models.GetDatasetByID(ctx.QueryInt64("datasetId")) if dataset == nil { ctx.Error(404, "The dataset does not exits.") @@ -84,6 +85,7 @@ func UploadAttachmentUI(ctx *context.Context) { func EditAttachmentUI(ctx *context.Context) { id, _ := strconv.ParseInt(ctx.Params(":id"), 10, 64) + ctx.Data["PageIsDataset"] = true attachment, _ := models.GetAttachmentByID(id) if attachment == nil { ctx.Error(404, "The attachment does not exits.") diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index 1d5ad39ae..b59d4b429 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -185,6 +185,7 @@ func getPageAttachments(attachments []*models.Attachment, page int, pagesize int func CreateDataset(ctx *context.Context) { MustEnableDataset(ctx) + ctx.Data["PageIsDataset"] = true ctx.HTML(200, tplDatasetCreate) } @@ -192,6 +193,7 @@ func CreateDataset(ctx *context.Context) { func EditDataset(ctx *context.Context) { MustEnableDataset(ctx) + ctx.Data["PageIsDataset"] = true datasetId, _ := strconv.ParseInt(ctx.Params(":id"), 10, 64) dataset, _ := models.GetDatasetByID(datasetId) From fe62c80d28903378501a648d2d81e030dc3a0078 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Tue, 22 Mar 2022 14:24:30 +0800 Subject: [PATCH 071/109] =?UTF-8?q?=E8=B7=AF=E7=94=B1=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/repo/attachment.go | 10 +--------- routers/routes/routes.go | 8 ++++++-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index ebe787303..3b1c7a643 100755 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -72,12 +72,7 @@ func renderAttachmentSettings(ctx *context.Context) { func UploadAttachmentUI(ctx *context.Context) { ctx.Data["datasetId"] = ctx.Query("datasetId") ctx.Data["PageIsDataset"] = true - 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) } @@ -90,9 +85,6 @@ func EditAttachmentUI(ctx *context.Context) { if attachment == nil { ctx.Error(404, "The attachment does not exits.") } - dataset, _ := models.GetDatasetByID(attachment.DatasetID) - r, _ := models.GetRepositoryByID(dataset.RepoID) - ctx.Data["Repo"] = r ctx.Data["Attachment"] = attachment ctx.HTML(200, tplAttachmentEdit) diff --git a/routers/routes/routes.go b/routers/routes/routes.go index d6ffd9bd9..c1ff24216 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -587,8 +587,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Post("/delete", repo.DeleteAttachment) m.Get("/get_pre_url", repo.GetPresignedPutObjectURL) m.Post("/add", repo.AddAttachment) - m.Get("/upload", repo.UploadAttachmentUI) - m.Get("/edit/:id", repo.EditAttachmentUI) + m.Post("/edit", bindIgnErr(auth.EditAttachmentForm{}), repo.EditAttachment) m.Post("/private", repo.UpdatePublicAttachment) m.Get("/get_chunks", repo.GetSuccessChunks) @@ -996,6 +995,11 @@ func RegisterRoutes(m *macaron.Macaron) { m.Get("/:uuid", repo.GetDatasetStatus) }) + m.Group("/attachments", func() { + m.Get("/upload", repo.UploadAttachmentUI) + m.Get("/edit/:id", repo.EditAttachmentUI) + }, reqSignIn) + m.Group("/dirs", func() { m.Get("/:uuid", reqRepoDatasetReader, repo.DirIndex) }) From a63a22ea1c984078bdcc2080f35dd5edd250e5eb Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Tue, 22 Mar 2022 17:17:55 +0800 Subject: [PATCH 072/109] #1654 add task duration --- models/cloudbrain.go | 18 ++++++++++++++++-- routers/api/v1/repo/cloudbrain.go | 5 +++++ routers/repo/cloudbrain.go | 24 +++++++++++++++++++++++- routers/repo/modelarts.go | 5 +++++ 4 files changed, 49 insertions(+), 3 deletions(-) diff --git a/models/cloudbrain.go b/models/cloudbrain.go index f501d8e91..a7a0cbd98 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -150,6 +150,19 @@ type Cloudbrain struct { Repo *Repository `xorm:"-"` BenchmarkTypeName string `xorm:"-"` BenchmarkTypeRankLink string `xorm:"-"` + StartTime timeutil.TimeStamp + EndTime timeutil.TimeStamp +} + +func (task *Cloudbrain) ComputeDuration() int64 { + if task.StartTime == 0 || task.EndTime == 0 { + return 0 + } + d := task.EndTime.AsTime().Unix() - task.StartTime.AsTime().Unix() + if d < 0 { + d = 0 + } + return d } type CloudbrainInfo struct { @@ -1019,6 +1032,7 @@ type GetTrainJobResult struct { NasShareAddr string `json:"nas_share_addr"` DatasetName string ModelMetricList string `json:"model_metric_list"` //列表里包含f1_score,recall,precision,accuracy,若有的话 + StartTime int64 `json:"start_time"` //训练作业开始时间。 } type GetTrainJobLogResult struct { @@ -1327,13 +1341,13 @@ func GetCloudbrainByJobIDAndIsLatestVersion(jobID string, isLatestVersion string func GetCloudbrainsNeededStopByUserID(userID int64) ([]*Cloudbrain, error) { cloudBrains := make([]*Cloudbrain, 0) - err := x.Cols("job_id", "status", "type", "job_type", "version_id").Where("user_id=? AND status !=?", userID, string(JobStopped)).Find(&cloudBrains) + err := x.Cols("job_id", "status", "type", "job_type", "version_id", "start_time").Where("user_id=? AND status !=?", userID, string(JobStopped)).Find(&cloudBrains) return cloudBrains, err } func GetCloudbrainsNeededStopByRepoID(repoID int64) ([]*Cloudbrain, error) { cloudBrains := make([]*Cloudbrain, 0) - err := x.Cols("job_id", "status", "type", "job_type", "version_id").Where("repo_id=? AND status !=?", repoID, string(JobStopped)).Find(&cloudBrains) + err := x.Cols("job_id", "status", "type", "job_type", "version_id", "start_time").Where("repo_id=? AND status !=?", repoID, string(JobStopped)).Find(&cloudBrains) return cloudBrains, err } diff --git a/routers/api/v1/repo/cloudbrain.go b/routers/api/v1/repo/cloudbrain.go index f92259c3d..53a3d9545 100755 --- a/routers/api/v1/repo/cloudbrain.go +++ b/routers/api/v1/repo/cloudbrain.go @@ -6,6 +6,7 @@ package repo import ( + "code.gitea.io/gitea/modules/timeutil" "net/http" "sort" "time" @@ -77,6 +78,10 @@ func GetCloudbrainTask(ctx *context.APIContext) { job.ContainerIp = taskRes.TaskStatuses[0].ContainerIP job.ContainerID = taskRes.TaskStatuses[0].ContainerID job.Status = taskRes.TaskStatuses[0].State + + if job.StartTime == 0 { + job.StartTime = timeutil.TimeStamp(taskRes.TaskStatuses[0].StartAt.Unix()) + } } if result.JobStatus.State != string(models.JobWaiting) { diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 6e88b266d..86f111641 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -2,6 +2,7 @@ package repo import ( "bufio" + "code.gitea.io/gitea/modules/timeutil" "encoding/json" "errors" "fmt" @@ -380,6 +381,9 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName) { task.Status = taskRes.TaskStatuses[0].State task.ContainerID = taskRes.TaskStatuses[0].ContainerID task.ContainerIp = taskRes.TaskStatuses[0].ContainerIP + if task.StartTime == 0 { + task.StartTime = timeutil.TimeStamp(taskRes.TaskStatuses[0].StartAt.Unix()) + } err = models.UpdateJob(task) if err != nil { ctx.Data["error"] = err.Error() @@ -489,6 +493,8 @@ func CloudBrainStop(ctx *context.Context) { } task.Status = string(models.JobStopped) + task.EndTime = timeutil.TimeStampNow() + task.Duration = task.ComputeDuration() err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob(%s) failed:%v", task.JobName, err, ctx.Data["msgID"]) @@ -582,6 +588,8 @@ func logErrorAndUpdateJobStatus(err error, taskInfo *models.Cloudbrain) { log.Warn("Failed to stop cloudBrain job:"+taskInfo.JobID, err) } else { taskInfo.Status = string(models.JobStopped) + taskInfo.EndTime = timeutil.TimeStampNow() + taskInfo.Duration = taskInfo.ComputeDuration() err = models.UpdateJob(taskInfo) if err != nil { log.Warn("UpdateJob failed", err) @@ -953,6 +961,13 @@ func SyncCloudbrainStatus() { task.Status = taskRes.TaskStatuses[0].State if task.Status != string(models.JobWaiting) { task.Duration = time.Now().Unix() - taskRes.TaskStatuses[0].StartAt.Unix() + if task.StartTime == 0 { + task.StartTime = timeutil.TimeStamp(taskRes.TaskStatuses[0].StartAt.Unix()) + } + //if task.Status == string(models.JobFailed) { + // task.EndTime = timeutil.TimeStampNow() + // task.Duration = task.ComputeDuration() + //} err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob(%s) failed:%v", task.JobName, err) @@ -973,6 +988,8 @@ func SyncCloudbrainStatus() { continue } task.Status = string(models.JobStopped) + task.EndTime = timeutil.TimeStampNow() + task.Duration = task.ComputeDuration() err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob(%s) failed:%v", task.JobName, err) @@ -991,7 +1008,9 @@ func SyncCloudbrainStatus() { if result != nil { task.Status = result.Status - + if task.StartTime == 0 { + task.StartTime = timeutil.TimeStamp(result.Lease.CreateTime / 1000) + } err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob(%s) failed:%v", task.JobName, err) @@ -1010,6 +1029,9 @@ func SyncCloudbrainStatus() { task.Duration = result.Duration task.TrainJobDuration = result.TrainJobDuration + if task.StartTime == 0 { + task.StartTime = timeutil.TimeStamp(result.StartTime) + } if result.Duration != 0 { task.TrainJobDuration = util.AddZero(result.Duration/3600000) + ":" + util.AddZero(result.Duration%3600000/60000) + ":" + util.AddZero(result.Duration%60000/1000) diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index 9c670e203..6b5eeffbf 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -2,6 +2,7 @@ package repo import ( "archive/zip" + "code.gitea.io/gitea/modules/timeutil" "encoding/json" "errors" "io" @@ -408,6 +409,10 @@ func NotebookManage(ctx *context.Context) { } task.Status = res.Status + if task.Status == string(models.ModelArtsStopped) { + task.EndTime = timeutil.TimeStampNow() + task.Duration = task.ComputeDuration() + } err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob(%s) failed:%v", task.JobName, err.Error(), ctx.Data["MsgID"]) From e46903c41424b4d72bfb2d740e3c6001a9436489 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Tue, 22 Mar 2022 17:56:42 +0800 Subject: [PATCH 073/109] #1654 update --- routers/api/v1/repo/modelarts.go | 9 ++++++++- routers/repo/cloudbrain.go | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/routers/api/v1/repo/modelarts.go b/routers/api/v1/repo/modelarts.go index 893f2a32c..cc311c446 100755 --- a/routers/api/v1/repo/modelarts.go +++ b/routers/api/v1/repo/modelarts.go @@ -6,6 +6,7 @@ package repo import ( + "code.gitea.io/gitea/modules/timeutil" "net/http" "strconv" "strings" @@ -67,8 +68,14 @@ func GetModelArtsNotebook2(ctx *context.APIContext) { ctx.NotFound(err) return } - + if job.StartTime == 0 { + job.StartTime = timeutil.TimeStamp(result.Lease.CreateTime / 1000) + } job.Status = result.Status + if job.EndTime == 0 && job.Status == string(models.ModelArtsStopped) { + job.EndTime = timeutil.TimeStampNow() + job.Duration = job.ComputeDuration() + } err = models.UpdateJob(job) if err != nil { log.Error("UpdateJob failed:", err) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 86f111641..9225433cf 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -1011,6 +1011,10 @@ func SyncCloudbrainStatus() { if task.StartTime == 0 { task.StartTime = timeutil.TimeStamp(result.Lease.CreateTime / 1000) } + if task.EndTime == 0 && task.Status == string(models.ModelArtsStopped) { + task.EndTime = timeutil.TimeStampNow() + task.Duration = task.ComputeDuration() + } err = models.UpdateJob(task) if err != nil { log.Error("UpdateJob(%s) failed:%v", task.JobName, err) From 89f38638483b36c094b2e8b121d4a9c0c88b6a25 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Wed, 23 Mar 2022 09:29:22 +0800 Subject: [PATCH 074/109] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=88=97=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/api/v1/repo/repo_dashbord.go | 38 ++++++++++++++-------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/routers/api/v1/repo/repo_dashbord.go b/routers/api/v1/repo/repo_dashbord.go index b1f344d55..2c42f8a16 100644 --- a/routers/api/v1/repo/repo_dashbord.go +++ b/routers/api/v1/repo/repo_dashbord.go @@ -292,41 +292,41 @@ func getFileName(ctx *context.Context, beginTime time.Time, endTime time.Time, p func allProjectsPeroidHeader(ctx *context.Context) map[string]string { - return map[string]string{"A1": ctx.Tr("admin.repos.id"), "B1": ctx.Tr("admin.repos.projectName"), "C1": ctx.Tr("repo.owner"), "D1": ctx.Tr("admin.repos.isPrivate"), "E1": ctx.Tr("admin.repos.isFork"), "F1": ctx.Tr("admin.repos.isMirror"), "G1": ctx.Tr("admin.repos.openi"), "H1": ctx.Tr("admin.repos.visit"), "I1": ctx.Tr("admin.repos.download"), "J1": ctx.Tr("admin.repos.pr"), "K1": ctx.Tr("admin.repos.commit"), - "L1": ctx.Tr("admin.repos.watches"), "M1": ctx.Tr("admin.repos.stars"), "N1": ctx.Tr("admin.repos.forks"), "O1": ctx.Tr("admin.repos.issues"), "P1": ctx.Tr("admin.repos.closedIssues"), "Q1": ctx.Tr("admin.repos.contributor"), "R1": ctx.Tr("admin.repos.create")} + return map[string]string{"A1": ctx.Tr("admin.repos.id"), "B1": ctx.Tr("admin.repos.projectName"), "C1": ctx.Tr("repo.owner"), "D1": ctx.Tr("admin.repos.isPrivate"), "E1": ctx.Tr("admin.repos.openi"), "F1": ctx.Tr("admin.repos.visit"), "G1": ctx.Tr("admin.repos.download"), "H1": ctx.Tr("admin.repos.pr"), "I1": ctx.Tr("admin.repos.commit"), + "J1": ctx.Tr("admin.repos.watches"), "K1": ctx.Tr("admin.repos.stars"), "L1": ctx.Tr("admin.repos.forks"), "M1": ctx.Tr("admin.repos.issues"), "N1": ctx.Tr("admin.repos.closedIssues"), "O1": ctx.Tr("admin.repos.contributor"), "P1": ctx.Tr("admin.repos.isFork"), "Q1": ctx.Tr("admin.repos.isMirror"), "R1": ctx.Tr("admin.repos.create")} } func allProjectsPeroidValues(row int, rs *models.RepoStatistic, ctx *context.Context) map[string]string { - return map[string]string{getCellName("A", row): strconv.FormatInt(rs.RepoID, 10), getCellName("B", row): rs.DisplayName(), getCellName("C", row): rs.OwnerName, getCellName("D", row): getBoolDisplay(rs.IsPrivate, ctx), getCellName("E", row): getBoolDisplay(rs.IsFork, ctx), getCellName("F", row): getBoolDisplay(rs.IsMirror, ctx), getCellName("G", row): strconv.FormatFloat(rs.RadarTotal, 'f', 2, 64), - getCellName("H", row): strconv.FormatInt(rs.NumVisits, 10), getCellName("I", row): strconv.FormatInt(rs.NumDownloads, 10), getCellName("J", row): strconv.FormatInt(rs.NumPulls, 10), getCellName("K", row): strconv.FormatInt(rs.NumCommits, 10), - getCellName("L", row): strconv.FormatInt(rs.NumWatches, 10), getCellName("M", row): strconv.FormatInt(rs.NumStars, 10), getCellName("N", row): strconv.FormatInt(rs.NumForks, 10), getCellName("O", row): strconv.FormatInt(rs.NumIssues, 10), - getCellName("P", row): strconv.FormatInt(rs.NumClosedIssues, 10), getCellName("Q", row): strconv.FormatInt(rs.NumContributor, 10), getCellName("R", row): time.Unix(int64(rs.RepoCreatedUnix), 0).Format(CREATE_TIME_FORMAT), + return map[string]string{getCellName("A", row): strconv.FormatInt(rs.RepoID, 10), getCellName("B", row): rs.DisplayName(), getCellName("C", row): rs.OwnerName, getCellName("D", row): getBoolDisplay(rs.IsPrivate, ctx), getCellName("E", row): strconv.FormatFloat(rs.RadarTotal, 'f', 2, 64), + getCellName("F", row): strconv.FormatInt(rs.NumVisits, 10), getCellName("G", row): strconv.FormatInt(rs.NumDownloads, 10), getCellName("H", row): strconv.FormatInt(rs.NumPulls, 10), getCellName("I", row): strconv.FormatInt(rs.NumCommits, 10), + getCellName("J", row): strconv.FormatInt(rs.NumWatches, 10), getCellName("K", row): strconv.FormatInt(rs.NumStars, 10), getCellName("L", row): strconv.FormatInt(rs.NumForks, 10), getCellName("M", row): strconv.FormatInt(rs.NumIssues, 10), + getCellName("N", row): strconv.FormatInt(rs.NumClosedIssues, 10), getCellName("O", row): strconv.FormatInt(rs.NumContributor, 10), getCellName("P", row): getBoolDisplay(rs.IsFork, ctx), getCellName("Q", row): getBoolDisplay(rs.IsMirror, ctx), getCellName("R", row): time.Unix(int64(rs.RepoCreatedUnix), 0).Format(CREATE_TIME_FORMAT), } } func allProjectsOpenIHeader() map[string]string { - return map[string]string{"A1": "ID", "B1": "项目名称", "C1": "拥有者", "D1": "私有", "E1": "迁移", "F1": "镜像", "G1": "OpenI指数", - "H1": "影响力", "I1": "成熟度", "J1": "活跃度", "K1": "项目健康度", "L1": "团队健康度", "M1": "项目发展趋势", - "N1": "关注数", "O1": "点赞数", "P1": "派生数", "Q1": "代码下载量", "R1": "评论数", "S1": "浏览量", "T1": "已解决任务数", "U1": "版本发布数量", "V1": "有效开发年龄", - "W1": "数据集", "X1": "模型数", "Y1": "百科页面数量", "Z1": "提交数", "AA1": "任务数", "AB1": "PR数", "AC1": "版本发布数量", "AD1": "任务完成比例", "AE1": "贡献者数", "AF1": "关键贡献者数", - "AG1": "新人增长量", "AH1": "代码规模增长量", "AI1": "任务增长量", "AJ1": "新人增长量", "AK1": "提交增长量", "AL1": "评论增长量", "AM1": "项目创建时间", + return map[string]string{"A1": "ID", "B1": "项目名称", "C1": "拥有者", "D1": "私有", "E1": "OpenI指数", + "F1": "影响力", "G1": "成熟度", "H1": "活跃度", "I1": "项目健康度", "J1": "团队健康度", "K1": "项目发展趋势", + "L1": "关注数", "M1": "点赞数", "N1": "派生数", "O1": "代码下载量", "P1": "评论数", "Q1": "浏览量", "R1": "已解决任务数", "S1": "版本发布数量", "T1": "有效开发年龄", + "U1": "数据集", "V1": "模型数", "W1": "百科页面数量", "X1": "提交数", "Y1": "任务数", "Z1": "PR数", "AA1": "版本发布数量", "AB1": "任务完成比例", "AC1": "贡献者数", "AD1": "关键贡献者数", + "AE1": "新人增长量", "AF1": "代码规模增长量", "AG1": "任务增长量", "AH1": "新人增长量", "AI1": "提交增长量", "AJ1": "评论增长量", "AK1": "迁移", "AL1": "镜像", "AM1": "项目创建时间", } } func allProjectsOpenIValues(row int, rs *models.RepoStatistic, ctx *context.Context) map[string]string { - return map[string]string{getCellName("A", row): strconv.FormatInt(rs.RepoID, 10), getCellName("B", row): rs.DisplayName(), getCellName("C", row): rs.OwnerName, getCellName("D", row): getBoolDisplay(rs.IsPrivate, ctx), getCellName("E", row): getBoolDisplay(rs.IsFork, ctx), getCellName("F", row): getBoolDisplay(rs.IsMirror, ctx), getCellName("G", row): strconv.FormatFloat(rs.RadarTotal, 'f', 2, 64), - getCellName("H", row): strconv.FormatFloat(rs.Impact, 'f', 2, 64), getCellName("I", row): strconv.FormatFloat(rs.Completeness, 'f', 2, 64), getCellName("J", row): strconv.FormatFloat(rs.Liveness, 'f', 2, 64), getCellName("K", row): strconv.FormatFloat(rs.ProjectHealth, 'f', 2, 64), getCellName("L", row): strconv.FormatFloat(rs.TeamHealth, 'f', 2, 64), getCellName("M", row): strconv.FormatFloat(rs.Growth, 'f', 2, 64), - getCellName("N", row): strconv.FormatInt(rs.NumWatches, 10), getCellName("O", row): strconv.FormatInt(rs.NumStars, 10), getCellName("P", row): strconv.FormatInt(rs.NumForks, 10), getCellName("Q", row): strconv.FormatInt(rs.NumDownloads, 10), + return map[string]string{getCellName("A", row): strconv.FormatInt(rs.RepoID, 10), getCellName("B", row): rs.DisplayName(), getCellName("C", row): rs.OwnerName, getCellName("D", row): getBoolDisplay(rs.IsPrivate, ctx), getCellName("E", row): strconv.FormatFloat(rs.RadarTotal, 'f', 2, 64), + getCellName("F", row): strconv.FormatFloat(rs.Impact, 'f', 2, 64), getCellName("G", row): strconv.FormatFloat(rs.Completeness, 'f', 2, 64), getCellName("H", row): strconv.FormatFloat(rs.Liveness, 'f', 2, 64), getCellName("I", row): strconv.FormatFloat(rs.ProjectHealth, 'f', 2, 64), getCellName("J", row): strconv.FormatFloat(rs.TeamHealth, 'f', 2, 64), getCellName("K", row): strconv.FormatFloat(rs.Growth, 'f', 2, 64), + getCellName("L", row): strconv.FormatInt(rs.NumWatches, 10), getCellName("M", row): strconv.FormatInt(rs.NumStars, 10), getCellName("N", row): strconv.FormatInt(rs.NumForks, 10), getCellName("O", row): strconv.FormatInt(rs.NumDownloads, 10), - getCellName("R", row): strconv.FormatInt(rs.NumComments, 10), getCellName("S", row): strconv.FormatInt(rs.NumVisits, 10), getCellName("T", row): strconv.FormatInt(rs.NumClosedIssues, 10), getCellName("U", row): strconv.FormatInt(rs.NumVersions, 10), - getCellName("V", row): strconv.FormatInt(rs.NumDevMonths, 10), getCellName("W", row): strconv.FormatInt(rs.DatasetSize, 10), getCellName("X", row): strconv.FormatInt(rs.NumModels, 10), getCellName("Y", row): strconv.FormatInt(rs.NumWikiViews, 10), - getCellName("Z", row): strconv.FormatInt(rs.NumCommits, 10), getCellName("AA", row): strconv.FormatInt(rs.NumIssues, 10), getCellName("AB", row): strconv.FormatInt(rs.NumPulls, 10), getCellName("AC", row): strconv.FormatInt(rs.NumVersions, 10), - getCellName("AD", row): strconv.FormatFloat(float64(rs.IssueFixedRate), 'f', 2, 64), getCellName("AE", row): strconv.FormatInt(rs.NumContributor, 10), getCellName("AF", row): strconv.FormatInt(rs.NumKeyContributor, 10), getCellName("AG", row): strconv.FormatInt(rs.NumContributorsGrowth, 10), - getCellName("AH", row): strconv.FormatInt(rs.NumCommitLinesGrowth, 10), getCellName("AI", row): strconv.FormatInt(rs.NumIssuesGrowth, 10), getCellName("AJ", row): strconv.FormatInt(rs.NumContributorsGrowth, 10), getCellName("AK", row): strconv.FormatInt(rs.NumCommitsGrowth, 10), getCellName("AL", row): strconv.FormatInt(rs.NumCommentsGrowth, 10), getCellName("AM", row): time.Unix(int64(rs.RepoCreatedUnix), 0).Format(CREATE_TIME_FORMAT), + getCellName("P", row): strconv.FormatInt(rs.NumComments, 10), getCellName("Q", row): strconv.FormatInt(rs.NumVisits, 10), getCellName("R", row): strconv.FormatInt(rs.NumClosedIssues, 10), getCellName("S", row): strconv.FormatInt(rs.NumVersions, 10), + getCellName("T", row): strconv.FormatInt(rs.NumDevMonths, 10), getCellName("U", row): strconv.FormatInt(rs.DatasetSize, 10), getCellName("V", row): strconv.FormatInt(rs.NumModels, 10), getCellName("W", row): strconv.FormatInt(rs.NumWikiViews, 10), + getCellName("X", row): strconv.FormatInt(rs.NumCommits, 10), getCellName("Y", row): strconv.FormatInt(rs.NumIssues, 10), getCellName("Z", row): strconv.FormatInt(rs.NumPulls, 10), getCellName("AA", row): strconv.FormatInt(rs.NumVersions, 10), + getCellName("AB", row): strconv.FormatFloat(float64(rs.IssueFixedRate), 'f', 2, 64), getCellName("AC", row): strconv.FormatInt(rs.NumContributor, 10), getCellName("AD", row): strconv.FormatInt(rs.NumKeyContributor, 10), getCellName("AE", row): strconv.FormatInt(rs.NumContributorsGrowth, 10), + getCellName("AF", row): strconv.FormatInt(rs.NumCommitLinesGrowth, 10), getCellName("AG", row): strconv.FormatInt(rs.NumIssuesGrowth, 10), getCellName("AH", row): strconv.FormatInt(rs.NumContributorsGrowth, 10), getCellName("AI", row): strconv.FormatInt(rs.NumCommitsGrowth, 10), getCellName("AJ", row): strconv.FormatInt(rs.NumCommentsGrowth, 10), getCellName("AK", row): getBoolDisplay(rs.IsFork, ctx), getCellName("AL", row): getBoolDisplay(rs.IsMirror, ctx), getCellName("AM", row): time.Unix(int64(rs.RepoCreatedUnix), 0).Format(CREATE_TIME_FORMAT), } } From f8d2c82f3f06eef4477db26e7f2e63fa6b252e95 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Wed, 23 Mar 2022 10:29:23 +0800 Subject: [PATCH 075/109] #1654 update --- models/cloudbrain.go | 4 ++++ routers/api/v1/repo/modelarts.go | 4 +++- routers/repo/cloudbrain.go | 5 ++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/models/cloudbrain.go b/models/cloudbrain.go index a7a0cbd98..4ee0b7b33 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -165,6 +165,10 @@ func (task *Cloudbrain) ComputeDuration() int64 { return d } +func IsTrainJobTerminal(status string) bool { + return status == string(ModelArtsTrainJobCompleted) || status == string(ModelArtsTrainJobFailed) || status == string(ModelArtsTrainJobKilled) +} + type CloudbrainInfo struct { Cloudbrain `xorm:"extends"` User `xorm:"extends"` diff --git a/routers/api/v1/repo/modelarts.go b/routers/api/v1/repo/modelarts.go index cc311c446..4d0e94160 100755 --- a/routers/api/v1/repo/modelarts.go +++ b/routers/api/v1/repo/modelarts.go @@ -140,7 +140,9 @@ func GetModelArtsTrainJobVersion(ctx *context.APIContext) { ctx.NotFound(err) return } - + if job.StartTime == 0 { + job.StartTime = timeutil.TimeStamp(result.StartTime / 1000) + } job.Status = modelarts.TransTrainJobStatus(result.IntStatus) job.Duration = result.Duration job.TrainJobDuration = result.TrainJobDuration diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 9225433cf..dae8506f0 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -1034,7 +1034,7 @@ func SyncCloudbrainStatus() { task.TrainJobDuration = result.TrainJobDuration if task.StartTime == 0 { - task.StartTime = timeutil.TimeStamp(result.StartTime) + task.StartTime = timeutil.TimeStamp(result.StartTime / 1000) } if result.Duration != 0 { task.TrainJobDuration = util.AddZero(result.Duration/3600000) + ":" + util.AddZero(result.Duration%3600000/60000) + ":" + util.AddZero(result.Duration%60000/1000) @@ -1042,6 +1042,9 @@ func SyncCloudbrainStatus() { } else { task.TrainJobDuration = "00:00:00" } + if models.IsTrainJobTerminal(task.Status) { + task.EndTime = task.StartTime.Add(task.Duration / 1000) + } err = models.UpdateJob(task) if err != nil { From 39b5f6291ca5a563a768d610cf168fb2647f03a1 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Wed, 23 Mar 2022 10:33:46 +0800 Subject: [PATCH 076/109] #1654 update --- routers/api/v1/repo/modelarts.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/routers/api/v1/repo/modelarts.go b/routers/api/v1/repo/modelarts.go index 4d0e94160..618f6c48d 100755 --- a/routers/api/v1/repo/modelarts.go +++ b/routers/api/v1/repo/modelarts.go @@ -154,6 +154,10 @@ func GetModelArtsTrainJobVersion(ctx *context.APIContext) { job.TrainJobDuration = "00:00:00" } + if models.IsTrainJobTerminal(job.Status) { + job.EndTime = job.StartTime.Add(job.Duration / 1000) + } + err = models.UpdateTrainJobVersion(job) if err != nil { log.Error("UpdateJob failed:", err) From 594b059a73e785e6bb2464f1935f39071a59acae Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Wed, 23 Mar 2022 10:43:41 +0800 Subject: [PATCH 077/109] #1654 update --- models/cloudbrain.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/cloudbrain.go b/models/cloudbrain.go index 4ee0b7b33..11368f076 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -1395,7 +1395,7 @@ func UpdateTrainJobVersion(job *Cloudbrain) error { func updateJobTrainVersion(e Engine, job *Cloudbrain) error { var sess *xorm.Session sess = e.Where("job_id = ? AND version_name=?", job.JobID, job.VersionName) - _, err := sess.Cols("status", "train_job_duration").Update(job) + _, err := sess.Cols("status", "train_job_duration", "start_time", "end_time").Update(job) return err } From 796af34cc1cd669bc76288c74f0aaa87d12eb436 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Wed, 23 Mar 2022 11:09:24 +0800 Subject: [PATCH 078/109] #1654 add train job endtime --- models/cloudbrain.go | 6 +++--- routers/api/v1/repo/modelarts.go | 15 ++++++++++----- routers/repo/cloudbrain.go | 4 ++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/models/cloudbrain.go b/models/cloudbrain.go index 11368f076..87a2ebd2c 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -102,7 +102,7 @@ type Cloudbrain struct { ContainerIp string CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` - Duration int64 + Duration int64 //运行时长 单位秒 TrainJobDuration string Image string //镜像名称 GpuQueue string //GPU类型即GPU队列 @@ -1395,7 +1395,7 @@ func UpdateTrainJobVersion(job *Cloudbrain) error { func updateJobTrainVersion(e Engine, job *Cloudbrain) error { var sess *xorm.Session sess = e.Where("job_id = ? AND version_name=?", job.JobID, job.VersionName) - _, err := sess.Cols("status", "train_job_duration", "start_time", "end_time").Update(job) + _, err := sess.Cols("status", "train_job_duration", "duration", "start_time", "end_time").Update(job) return err } @@ -1475,7 +1475,7 @@ func UpdateInferenceJob(job *Cloudbrain) error { func updateInferenceJob(e Engine, job *Cloudbrain) error { var sess *xorm.Session sess = e.Where("job_id = ?", job.JobID) - _, err := sess.Cols("status", "train_job_duration").Update(job) + _, err := sess.Cols("status", "train_job_duration", "duration", "start_time", "end_time").Update(job) return err } func RestartCloudbrain(old *Cloudbrain, new *Cloudbrain) (err error) { diff --git a/routers/api/v1/repo/modelarts.go b/routers/api/v1/repo/modelarts.go index 618f6c48d..28756699c 100755 --- a/routers/api/v1/repo/modelarts.go +++ b/routers/api/v1/repo/modelarts.go @@ -144,11 +144,11 @@ func GetModelArtsTrainJobVersion(ctx *context.APIContext) { job.StartTime = timeutil.TimeStamp(result.StartTime / 1000) } job.Status = modelarts.TransTrainJobStatus(result.IntStatus) - job.Duration = result.Duration + job.Duration = result.Duration / 1000 job.TrainJobDuration = result.TrainJobDuration if result.Duration != 0 { - job.TrainJobDuration = util.AddZero(result.Duration/3600000) + ":" + util.AddZero(result.Duration%3600000/60000) + ":" + util.AddZero(result.Duration%60000/1000) + job.TrainJobDuration = util.AddZero(result.Duration/3600) + ":" + util.AddZero(result.Duration%3600/60) + ":" + util.AddZero(result.Duration%60) } else { job.TrainJobDuration = "00:00:00" @@ -379,17 +379,22 @@ func GetModelArtsInferenceJob(ctx *context.APIContext) { ctx.NotFound(err) return } - + if job.StartTime == 0 { + job.StartTime = timeutil.TimeStamp(result.StartTime / 1000) + } job.Status = modelarts.TransTrainJobStatus(result.IntStatus) - job.Duration = result.Duration + job.Duration = result.Duration / 1000 job.TrainJobDuration = result.TrainJobDuration if result.Duration != 0 { - job.TrainJobDuration = util.AddZero(result.Duration/3600000) + ":" + util.AddZero(result.Duration%3600000/60000) + ":" + util.AddZero(result.Duration%60000/1000) + job.TrainJobDuration = util.AddZero(result.Duration/3600) + ":" + util.AddZero(result.Duration%3600/60) + ":" + util.AddZero(result.Duration%60) } else { job.TrainJobDuration = "00:00:00" } + if models.IsTrainJobTerminal(job.Status) { + job.EndTime = job.StartTime.Add(job.Duration / 1000) + } err = models.UpdateInferenceJob(job) if err != nil { diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index dae8506f0..7f907dd52 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -1030,14 +1030,14 @@ func SyncCloudbrainStatus() { if result != nil { task.Status = modelarts.TransTrainJobStatus(result.IntStatus) - task.Duration = result.Duration + task.Duration = result.Duration / 1000 task.TrainJobDuration = result.TrainJobDuration if task.StartTime == 0 { task.StartTime = timeutil.TimeStamp(result.StartTime / 1000) } if result.Duration != 0 { - task.TrainJobDuration = util.AddZero(result.Duration/3600000) + ":" + util.AddZero(result.Duration%3600000/60000) + ":" + util.AddZero(result.Duration%60000/1000) + task.TrainJobDuration = util.AddZero(result.Duration/3600) + ":" + util.AddZero(result.Duration%3600/60) + ":" + util.AddZero(result.Duration%60) } else { task.TrainJobDuration = "00:00:00" From ef55b63c497995975962a68d643fca313c47519a Mon Sep 17 00:00:00 2001 From: liuzx Date: Wed, 23 Mar 2022 11:19:02 +0800 Subject: [PATCH 079/109] fix-bug --- models/attachment.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/models/attachment.go b/models/attachment.go index 50bb89192..dc2763ba6 100755 --- a/models/attachment.go +++ b/models/attachment.go @@ -62,6 +62,7 @@ type AttachmentInfo struct { Attachment `xorm:"extends"` Repo *Repository `xorm:"extends"` RelAvatarLink string `xorm:"extends"` + UserName string `xorm:"extends"` } type AttachmentsOptions struct { @@ -625,6 +626,7 @@ func Attachments(opts *AttachmentsOptions) ([]*AttachmentInfo, int64, error) { user, err := GetUserByID(attachment.UploaderID) if err == nil { attachment.RelAvatarLink = user.RelAvatarLink() + attachment.UserName = user.Name } else { return nil, 0, fmt.Errorf("GetUserByID failed error: %v", err) } From 8ad955372d71298467ddb652b0f065273030e727 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Wed, 23 Mar 2022 14:16:32 +0800 Subject: [PATCH 080/109] #1654 fix bug --- routers/api/v1/repo/modelarts.go | 4 ++-- routers/repo/cloudbrain.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/routers/api/v1/repo/modelarts.go b/routers/api/v1/repo/modelarts.go index 28756699c..5476f7bf2 100755 --- a/routers/api/v1/repo/modelarts.go +++ b/routers/api/v1/repo/modelarts.go @@ -155,7 +155,7 @@ func GetModelArtsTrainJobVersion(ctx *context.APIContext) { } if models.IsTrainJobTerminal(job.Status) { - job.EndTime = job.StartTime.Add(job.Duration / 1000) + job.EndTime = job.StartTime.Add(job.Duration) } err = models.UpdateTrainJobVersion(job) @@ -393,7 +393,7 @@ func GetModelArtsInferenceJob(ctx *context.APIContext) { job.TrainJobDuration = "00:00:00" } if models.IsTrainJobTerminal(job.Status) { - job.EndTime = job.StartTime.Add(job.Duration / 1000) + job.EndTime = job.StartTime.Add(job.Duration) } err = models.UpdateInferenceJob(job) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 7f907dd52..39780f8fb 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -1043,7 +1043,7 @@ func SyncCloudbrainStatus() { task.TrainJobDuration = "00:00:00" } if models.IsTrainJobTerminal(task.Status) { - task.EndTime = task.StartTime.Add(task.Duration / 1000) + task.EndTime = task.StartTime.Add(task.Duration) } err = models.UpdateJob(task) From 95329d8f074adfc8c64dccc48e4f33f0ac3b3e0f Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Wed, 23 Mar 2022 15:06:45 +0800 Subject: [PATCH 081/109] #1654 fix bug --- routers/api/v1/repo/modelarts.go | 4 ++-- routers/repo/cloudbrain.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/routers/api/v1/repo/modelarts.go b/routers/api/v1/repo/modelarts.go index 5476f7bf2..5675ed20a 100755 --- a/routers/api/v1/repo/modelarts.go +++ b/routers/api/v1/repo/modelarts.go @@ -148,7 +148,7 @@ func GetModelArtsTrainJobVersion(ctx *context.APIContext) { job.TrainJobDuration = result.TrainJobDuration if result.Duration != 0 { - job.TrainJobDuration = util.AddZero(result.Duration/3600) + ":" + util.AddZero(result.Duration%3600/60) + ":" + util.AddZero(result.Duration%60) + job.TrainJobDuration = util.AddZero(job.Duration/3600) + ":" + util.AddZero(job.Duration%3600/60) + ":" + util.AddZero(job.Duration%60) } else { job.TrainJobDuration = "00:00:00" @@ -387,7 +387,7 @@ func GetModelArtsInferenceJob(ctx *context.APIContext) { job.TrainJobDuration = result.TrainJobDuration if result.Duration != 0 { - job.TrainJobDuration = util.AddZero(result.Duration/3600) + ":" + util.AddZero(result.Duration%3600/60) + ":" + util.AddZero(result.Duration%60) + job.TrainJobDuration = util.AddZero(job.Duration/3600) + ":" + util.AddZero(job.Duration%3600/60) + ":" + util.AddZero(job.Duration%60) } else { job.TrainJobDuration = "00:00:00" diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 39780f8fb..cdaa8b515 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -1037,7 +1037,7 @@ func SyncCloudbrainStatus() { task.StartTime = timeutil.TimeStamp(result.StartTime / 1000) } if result.Duration != 0 { - task.TrainJobDuration = util.AddZero(result.Duration/3600) + ":" + util.AddZero(result.Duration%3600/60) + ":" + util.AddZero(result.Duration%60) + task.TrainJobDuration = util.AddZero(task.Duration/3600) + ":" + util.AddZero(task.Duration%3600/60) + ":" + util.AddZero(task.Duration%60) } else { task.TrainJobDuration = "00:00:00" From b1e33ebb1564d087aee2e7e944cb3e953bdbb17c Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Wed, 23 Mar 2022 15:40:44 +0800 Subject: [PATCH 082/109] fix issue --- options/locale/locale_en-US.ini | 29 +++++- options/locale/locale_zh-CN.ini | 30 +++++- templates/custom/select_dataset.tmpl | 63 +++++++++++-- templates/explore/datasets.tmpl | 12 ++- templates/repo/attachment/edit.tmpl | 6 +- templates/repo/attachment/upload.tmpl | 49 +++------- templates/repo/cloudbrain/new.tmpl | 27 +----- templates/repo/datasets/create.tmpl | 28 +++--- templates/repo/datasets/edit.tmpl | 28 +++--- templates/repo/datasets/index.tmpl | 97 +++++++++++--------- templates/repo/modelarts/notebook/new.tmpl | 27 ++---- web_src/js/components/MinioUploader.vue | 10 +- web_src/js/index.js | 101 ++++++++++++++++++--- web_src/less/_dataset.less | 35 +++++++ 14 files changed, 360 insertions(+), 182 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 5d7517aae..a52f02b79 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -796,6 +796,33 @@ owner_dataset=Owner Dataset public_dataset=Public Dataset I_liked = I Liked use = Use +create_new_dataset = Create New Dataset +dataset_name = Dataset Name +dataset_description = Dataset Description +select_category = Select Category +select_task = Select Research Direction/Application Area +dataset_name_tooltips = Please enter letters, numbers, _ and - up to 64 characters and cannot end with a dash (-). +dataset_no_create = No dataset has been created yet +dataset_explain = Dataset: CloudBrain I provides CPU/GPU resources, Cloudbrain II provides Ascend NPU resources, and the data set used for debugging also needs to be uploaded to the corresponding environment; +dataset_instructions_for_use = Instructions for use: You can refer to Qizhi AI Collaboration Platform +dataset_camp_course = Newcomer Training Camp Course; +dataset_upload = Upload +dataset_file_name = File Name +dataset_available_clusters = Available Clusters +dataset_upload_time = Upload Time +download = Download +modify_description = Modify Description +set_public = Set Public +set_private = Set Private +annotation = Annotation +upload_dataset_file = Upload Dataset File +file_description = File Description +data_upload = Dataset Upload +illustrate = Illustrate +illustrate.only = Only Datasets In +illustrate.zip = Zip Format +illustrate.fisrt_end = Can Initiate Cloudbrain Tasks +modify_dataset = Modify Dataset [repo] owner = Owner repo_name = Repository Name @@ -825,7 +852,7 @@ repo_label_helpe = Press Enter to complete issue_labels = Issue Labels issue_labels_helper = Select an issue label set. license = License -license_helper = Select a license file. +license_helper = Select a license file readme = README readme_helper = Select a README file template. auto_init = Initialize Repository (Adds .gitignore, License and README) diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 885d987fc..e1595e36d 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -801,6 +801,34 @@ owner_dataset=我的数据集 public_dataset=公开数据集 I_liked=我收藏的 use=使用 +create_new_dataset = 新建数据集 +dataset_name=数据集名称 +dataset_description = 数据集描述 +select_category = 选择分类 +select_task = 选择研究方向/应用领域 +dataset_name_tooltips = 请输入字母、数字、_和-,最长64个字符,且不能以中划线(-)结尾。 +dataset_no_create = 还未创建过数据集 +dataset_explain = 数据集:云脑1提供 CPU / GPU 资源,云脑2提供 Ascend NPU 资源,调试使用的数据集也需要上传到对应的环境; +dataset_instructions_for_use = 使用说明:可以参考启智AI协作平台 +dataset_camp_course = 小白训练营课程 +dataset_upload = 上传 +dataset_file_name = 文件名字 +dataset_available_clusters = 可用集群 +dataset_upload_time = 上传时间 +download = 下载 +modify_description = 修改描述 +set_public = 设为公开 +set_private = 设为私有 +annotation = 标注 +upload_dataset_file = 上传数据集文件 +file_description = 文件描述 +data_upload = 数据上传 +illustrate = 说明 +illustrate.only = 只有 +illustrate.zip = zip格式 +illustrate.fisrt_end = 的数据集才能发起云脑任务 +modify_dataset = 修改数据集 + [repo] owner=拥有者 repo_name=项目名称 @@ -830,7 +858,7 @@ repo_label_helpe=输入完成后回车键完成标签确定。 issue_labels=任务标签 issue_labels_helper=选择一个任务标签集 license=授权许可 -license_helper=选择授权许可文件。 +license_helper=选择授权许可文件 readme=自述 readme_helper=选择自述文件模板。 auto_init=初始化存储库 (添加. gitignore、许可证和自述文件) diff --git a/templates/custom/select_dataset.tmpl b/templates/custom/select_dataset.tmpl index c782efc28..e63b38202 100644 --- a/templates/custom/select_dataset.tmpl +++ b/templates/custom/select_dataset.tmpl @@ -1,8 +1,27 @@ +
- + {{.i18n.Tr "dataset.select_dataset"}}
- + + + + 解压中 + + + + 解压失败 +
@@ -45,7 +72,15 @@
- + + + + 解压中 + + + + 解压失败 +
@@ -55,14 +90,22 @@
${dataset.Repo.OwnerName}/${dataset.Repo.Alias}${dataset.Name}
- + ${dataset.Description}
- + + + + 解压中 + + + + 解压失败 +
@@ -79,7 +122,15 @@
- + + + + 解压中 + + + + 解压失败 +
diff --git a/templates/explore/datasets.tmpl b/templates/explore/datasets.tmpl index f161b78da..924f6efba 100644 --- a/templates/explore/datasets.tmpl +++ b/templates/explore/datasets.tmpl @@ -117,7 +117,7 @@ {{.i18n.Tr "repo.issues.filter_sort.oldest"}} {{.i18n.Tr "repo.issues.filter_sort.recentupdate"}} {{.i18n.Tr "repo.issues.filter_sort.leastupdate"}} - {{.i18n.Tr "repo.issues.filter_sort.downloadtimes"}} + @@ -155,11 +155,13 @@
{{.Title}}
- {{if .Task}} - {{.Task}} - {{end}} {{if .Category}} - {{.Category}} + {{$category := .Category}} + {{$.i18n.Tr (printf "dataset.category.%s" $category)}} + {{end}} + {{if .Task}} + {{$task := .Task}} + {{$.i18n.Tr (printf "dataset.task.%s" $task)}} {{end}} {{if .License}} {{.License}} diff --git a/templates/repo/attachment/edit.tmpl b/templates/repo/attachment/edit.tmpl index 966e78b34..611447548 100644 --- a/templates/repo/attachment/edit.tmpl +++ b/templates/repo/attachment/edit.tmpl @@ -31,8 +31,8 @@ - 确定 - 取消 + 确定 + 取消 @@ -45,6 +45,6 @@ {{template "base/footer" .}} \ No newline at end of file diff --git a/templates/repo/attachment/upload.tmpl b/templates/repo/attachment/upload.tmpl index 167a65aae..a600d3357 100644 --- a/templates/repo/attachment/upload.tmpl +++ b/templates/repo/attachment/upload.tmpl @@ -1,12 +1,4 @@ - {{template "base/head" .}}
{{template "repo/header" .}} @@ -14,42 +6,28 @@

- 上传数据集文件 + {{$.i18n.Tr "dataset.upload_dataset_file"}}

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

--> -

说明:

-

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

+

{{$.i18n.Tr "dataset.illustrate"}}:

+

{{$.i18n.Tr "dataset.illustrate.only"}}{{$.i18n.Tr "dataset.illustrate.zip"}}{{$.i18n.Tr "dataset.illustrate.fisrt_end"}};
+ {{$.i18n.Tr "dataset.dataset_explain"}}

{{template "base/footer" .}} \ No newline at end of file diff --git a/templates/repo/cloudbrain/new.tmpl b/templates/repo/cloudbrain/new.tmpl index e179efe7a..08cd6144a 100755 --- a/templates/repo/cloudbrain/new.tmpl +++ b/templates/repo/cloudbrain/new.tmpl @@ -101,32 +101,7 @@ } - .panel_creator_reponam{ - display: inline-block; - border-radius: 4px; - padding: 4px; - font-size: 12px; - text-align: center; - background-color: rgba(161, 220, 255, 0.2); - color: #101010; - } - .panel_dataset_name{ - font-size: 15px; - color: #0366D6; - text-align: center; - margin-left: 1rem; - } - .panel_datset_desc{ - white-space: nowrap; - display: inline-block; - overflow: hidden; - width: 90%; - - text-overflow: ellipsis; - } - .el-dialog__body{ - padding-top:0 - } +
diff --git a/templates/repo/datasets/create.tmpl b/templates/repo/datasets/create.tmpl index 52c6a77d8..bd2a4136d 100644 --- a/templates/repo/datasets/create.tmpl +++ b/templates/repo/datasets/create.tmpl @@ -20,45 +20,45 @@

- {{.i18n.Tr "repo.modelarts.train_job.new_infer"}} + {{.i18n.Tr "dataset.create_new_dataset"}}

{{.CsrfTokenHtml}} - + - 请输入字母、数字、_和-,最长64个字符,且不能以中划线(-)结尾。 + {{.i18n.Tr "dataset.dataset_name_tooltips"}} - + - - + + {{range $category := categories}} - + {{end}} - - + + {{range $task := tasks}} - + {{end}} - - + + {{range $license := licenses}} {{end}} - 确定 - 取消 + {{.i18n.Tr "repo.confirm_choice"}} + {{.i18n.Tr "cancel"}}
diff --git a/templates/repo/datasets/edit.tmpl b/templates/repo/datasets/edit.tmpl index 4aaaa5f24..6de84a4c9 100644 --- a/templates/repo/datasets/edit.tmpl +++ b/templates/repo/datasets/edit.tmpl @@ -20,7 +20,7 @@

- 修改数据集 + {{.i18n.Tr "dataset.modify_dataset"}}

${num_stars} {{end}} - 修改 + {{.i18n.Tr "repo.modelarts.modify"}}
- {{if .dataset.Task}} - {{.dataset.Task}} - {{end}} {{if .dataset.Category}} - {{.dataset.Category}} + {{$category := .dataset.Category}} + {{$.i18n.Tr (printf "dataset.category.%s" $category)}} + {{end}} + {{if .dataset.Task}} + {{$task := .dataset.Task}} + {{$.i18n.Tr (printf "dataset.task.%s" $task)}} {{end}} {{if .dataset.License}} {{.dataset.License}} @@ -157,11 +159,11 @@
- + - 上传 + {{$.i18n.Tr "dataset.dataset_upload"}}
@@ -170,25 +172,25 @@
- 文件名称 + {{$.i18n.Tr "dataset.dataset_file_name"}}
- 大小 + {{$.i18n.Tr "repo.model.manage.size"}}
- 存储位置 + {{$.i18n.Tr "dataset.dataset_available_clusters"}}
- 状态 + {{$.i18n.Tr "repo.modelarts.status"}}
- 创建者 + {{$.i18n.Tr "repo.cloudbrain_creator"}}
- 上传时间 + {{$.i18n.Tr "dataset.dataset_upload_time"}}
- 操作 + {{$.i18n.Tr "repo.cloudbrain_operate"}}
@@ -197,23 +199,26 @@
-
+
{{if .Description}} -
{{.Description}}
下载:{{.DownloadCount}}
- +
{{.Description}}
{{$.i18n.Tr "dataset.download"}}:{{.DownloadCount}}
+
{{.Name}}
{{else}} -
下载:{{.DownloadCount}}
- +
{{$.i18n.Tr "dataset.download"}}:{{.DownloadCount}}
+
{{.Name}}
{{end}} +
{{.Size | FileSize}} @@ -251,32 +256,38 @@ -->
- {{if $.CanRead}} - 下载 - {{else}} - 下载 - {{end}} + + {{$.i18n.Tr "dataset.download"}} + {{if eq .DecompressState 1}} - 预览 + {{$.i18n.Tr "preview"}} {{end}} - {{if $.CanRead}} + {{if .CanDel}} + {{$.i18n.Tr "dataset.set_public"}} + {{$.i18n.Tr "dataset.set_private"}} + {{else}} + {{$.i18n.Tr "dataset.set_public"}} + {{$.i18n.Tr "dataset.set_private"}} + {{end}} + - 更多 + {{$.i18n.Tr "repo.more"}} - 复制下载链接 - 复制文件MD5 + {{$.i18n.Tr "dataset.copy_url"}} + {{$.i18n.Tr "dataset.copy_md5"}} + {{if $.CanWrite}} + {{$.i18n.Tr "dataset.annotation"}} + {{end}} {{if .CanDel}} - 设为公有 - 设为私有 - 修改描述 - 删除 + {{$.i18n.Tr "dataset.modify_description"}} + {{$.i18n.Tr "dataset.delete"}} {{end}} @@ -310,13 +321,13 @@ {{else}}
-
还未创建过数据集
+
{{.i18n.Tr "dataset.dataset_no_create"}}
{{if $.CanWrite}} -
新建数据集 + {{.i18n.Tr "dataset.create_new_dataset"}} {{end}}
-
数据集:云脑1提供 CPU / GPU 资源,云脑2提供 Ascend NPU 资源,调试使用的数据集也需要上传到对应的环境;
-
使用说明:可以参考启智AI协作平台小白训练营课程。
+
{{.i18n.Tr "dataset.dataset_explain"}}
+
{{.i18n.Tr "dataset.dataset_instructions_for_use"}}{{.i18n.Tr "dataset.dataset_camp_course"}}
{{end}} @@ -336,7 +347,7 @@ \ No newline at end of file diff --git a/web_src/js/components/MinioUploader.vue b/web_src/js/components/MinioUploader.vue index 0b73f55ca..6e40c924e 100755 --- a/web_src/js/components/MinioUploader.vue +++ b/web_src/js/components/MinioUploader.vue @@ -8,8 +8,8 @@ {{ file_status_text }} {{ status }}

- 上传 - 取消 + {{upload}} + {{cancel}} @@ -51,7 +51,9 @@ export default { file_status_text: '', file:{}, repoPath:'', - btnFlag:false + btnFlag:false, + cancel:'', + upload:'', }; }, @@ -60,6 +62,8 @@ export default { this.file_status_text = this.dropzoneParams.data('file-status'); this.status = this.dropzoneParams.data('file-init-status'); this.repoPath = this.dropzoneParams.data('repopath'); + this.cancel = this.dropzoneParams.data('cancel'); + this.upload = this.dropzoneParams.data('upload'); // let previewTemplate = ''; // previewTemplate += '
\n '; // previewTemplate += '
\n '; diff --git a/web_src/js/index.js b/web_src/js/index.js index 6e308e973..41ca26a50 100755 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -3681,8 +3681,10 @@ function initVueDataset() { }) } const items = [] + const zipStatus = [] $('#dataset-range-value').find('.item').each(function(){ items.push($(this).data('private')) + zipStatus.push($(this).data('decompress-state')) }) let num_stars = $('#dataset-range-value').data('num-stars') let star_active = $('#dataset-range-value').data('star-active') @@ -3739,6 +3741,7 @@ function initVueDataset() { descfile:'', datasetType:'', privates:[], + zipStatus:[], starItems:[], starActives:[], taskLists:[], @@ -3763,6 +3766,7 @@ function initVueDataset() { dataset_uuid:'', dataset_name:'', loadingDataIndex:true, + timer:null, ruleForm:{ title:'', description:'', @@ -3835,6 +3839,7 @@ function initVueDataset() { this.url = document.getElementById('postPath').value } this.privates = items + this.zipStatus = zipStatus this.num_stars = num_stars this.star_active = star_active this.ruleForm1 = ruleForm @@ -3847,7 +3852,7 @@ function initVueDataset() { this.descfile = dataset_file_desc this.repolink = repolink this.cloudbrainType = cloudbrainType - console.log(this.starItems,this.starActives) + console.log(this.starItems,this.starActives,this.zipStatus) }, methods:{ handleCurrentChange(val) { @@ -3904,18 +3909,21 @@ function initVueDataset() { } else{ console.log(attachment) - location.href = '/'+attachment + '/datasets' + location.href = `${AppSubUrl}${attachment}/datasets` } }, - gotoUpload(datsetId){ - location.href = `${AppSubUrl}/attachments/upload?datasetId=${datsetId}` + gotoUpload(repolink,datsetId){ + location.href = `${AppSubUrl}${repolink}/datasets/attachments/upload?datasetId=${datsetId}` }, gotoDataset(datsetUrl){ console.log(datsetUrl) location.href = datsetUrl }, + gotoAnnotate(repolink,uuid,type){ + location.href = `${AppSubUrl}${repolink}/datasets/label/${uuid}?type=${type}` + }, uploadGpu(){ this.type=0 }, @@ -3993,7 +4001,7 @@ function initVueDataset() { // document.getElementById("mask").style.display = "block" this.$axios.post(url,this.qs.stringify(params)).then((res)=>{ if(res.data.Code===0){ - location.href = '/'+backurl + '/datasets' + location.href = `${AppSubUrl}${backurl}/datasets` }else{ console.log(res.data.Message) } @@ -4082,8 +4090,8 @@ function initVueDataset() { }, - gotoDatasetEidt(id){ - location.href = `/attachments/edit/${id}` + gotoDatasetEidt(repolink,id){ + location.href = `${repolink}/datasets/attachments/edit/${id}` }, handleClick(repoLink, tabName,type) { @@ -4110,7 +4118,57 @@ function initVueDataset() { this.getStarDataset(repoLink,type) } }, + polling (checkStatuDataset,repoLink) { + console.log("===polling===checkStatuDataset===",checkStatuDataset,repoLink) + this.timer = window.setInterval(() => { + setTimeout(() => { + this.getDatasetStatus(checkStatuDataset,repoLink) + },0) + },15000) + + }, + + getDatasetStatus(checkStatuDataset,repoLink){ + const getmap = checkStatuDataset.map((item)=>{ + let url = `${AppSubUrl}${repolink}/datasets/status/${item.UUID}` + console.log("map item",item,url) + return this.$axios.get(url) + }) + console.log(getmap) + this.$axios.all(getmap) + .then((res)=>{ + console.log(res,this.timer) + let flag = res.some((item)=>{ + console.log(item.data) + return item.data.AttachmentStatus == 1 + }) + console.log(flag) + flag && clearInterval(this.timer) + flag && this.refreshStatusDataset() + + } + ) + + }, + refreshStatusDataset(){ + console.log("refresh") + switch(this.activeName){ + case 'first': + this.getCurrentRepoDataset(this.repolink,this.cloudbrainType) + break + case 'second': + this.getMyDataset(this.repolink,this.cloudbrainType) + break + case 'third': + this.getPublicDataset(this.repolink,this.cloudbrainType) + break + case 'fourth': + this.getStarDataset(this.repolink,this.cloudbrainType) + break + } + }, getCurrentRepoDataset(repoLink,type){ + clearInterval(this.timer) this.loadingDataIndex = true let url = repoLink + '/datasets/current_repo' this.$axios.get(url,{ @@ -4124,11 +4182,17 @@ function initVueDataset() { console.log(JSON.parse(res.data.data)) console.log(res.data.count) this.currentRepoDataset = JSON.parse(res.data.data) + const checkStatuDataset = this.currentRepoDataset.filter(item=>item.DecompressState===2) + console.log("=========checkStatuDataset",checkStatuDataset,repoLink) + if(checkStatuDataset.length>0){ + this.polling(checkStatuDataset,repoLink) + } this.totalnums = parseInt(res.data.count) this.loadingDataIndex = false }) }, getMyDataset(repoLink,type){ + clearInterval(this.timer) this.loadingDataIndex = true let url = repoLink + '/datasets/my_datasets' this.$axios.get(url,{ @@ -4141,12 +4205,18 @@ function initVueDataset() { console.log(res) console.log(JSON.parse(res.data.data)) this.myDataset = JSON.parse(res.data.data) + const checkStatuDataset = this.myDataset.filter(item=>item.DecompressState===2) + console.log("=========checkStatuDataset",checkStatuDataset,repoLink) + if(checkStatuDataset.length>0){ + this.polling(checkStatuDataset,repoLink) + } this.totalnums = parseInt(res.data.count) this.loadingDataIndex = false }) }, getPublicDataset(repoLink,type){ + clearInterval(this.timer) this.loadingDataIndex = true let url = repoLink + '/datasets/public_datasets' this.$axios.get(url,{ @@ -4159,12 +4229,18 @@ function initVueDataset() { console.log(res) console.log(JSON.parse(res.data.data)) this.publicDataset = JSON.parse(res.data.data) + const checkStatuDataset = this.publicDataset.filter(item=>item.DecompressState===2) + console.log("=========checkStatuDataset",checkStatuDataset,repoLink) + if(checkStatuDataset.length>0){ + this.polling(checkStatuDataset,repoLink) + } this.totalnums = parseInt(res.data.count) this.loadingDataIndex = false }) }, getStarDataset(repoLink,type){ + clearInterval(this.timer) this.loadingDataIndex = true let url = repoLink + '/datasets/my_favorite' this.$axios.get(url,{ @@ -4177,6 +4253,11 @@ function initVueDataset() { console.log(res) console.log(JSON.parse(res.data.data)) this.myFavoriteDataset = JSON.parse(res.data.data) + const checkStatuDataset = this.myFavoriteDataset.filter(item=>item.DecompressState===2) + console.log("=========checkStatuDataset",checkStatuDataset,repoLink) + if(checkStatuDataset.length>0){ + this.polling(checkStatuDataset,repoLink) + } this.totalnums= parseInt(res.data.count) this.loadingDataIndex = false }) @@ -4209,13 +4290,7 @@ function initVueDataset() { break } } - - - - }, - - }); } diff --git a/web_src/less/_dataset.less b/web_src/less/_dataset.less index 3bc19ef63..35a87f89f 100644 --- a/web_src/less/_dataset.less +++ b/web_src/less/_dataset.less @@ -222,3 +222,38 @@ } } } +.panel_creator_reponam{ + display: inline-block; + border-radius: 4px; + padding: 4px; + font-size: 12px; + text-align: center; + background-color: rgba(161, 220, 255, 0.2); + color: #101010; +} +.panel_dataset_name{ + font-size: 15px; + color: #0366D6; + text-align: center; + margin-left: 1rem; +} +.panel_datset_desc{ + white-space: nowrap; + display: inline-block; + overflow: hidden; + width: 90%; + + text-overflow: ellipsis; +} +.el-dialog__body{ + padding-top:0 +} +#dataset-base{ + .active{ + color: #0087f5!important; + border: 1px solid #0087f5!important; + /* margin: -1px!important; */ + background: #fff!important; + + } +} \ No newline at end of file From e0b49c1a6319e92cf4fda635651b981259dee50b Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Wed, 23 Mar 2022 16:12:48 +0800 Subject: [PATCH 083/109] #1654 fix bug --- routers/api/v1/repo/cloudbrain.go | 2 +- routers/api/v1/repo/modelarts.go | 6 +++--- routers/repo/cloudbrain.go | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/routers/api/v1/repo/cloudbrain.go b/routers/api/v1/repo/cloudbrain.go index 53a3d9545..48013de84 100755 --- a/routers/api/v1/repo/cloudbrain.go +++ b/routers/api/v1/repo/cloudbrain.go @@ -79,7 +79,7 @@ func GetCloudbrainTask(ctx *context.APIContext) { job.ContainerID = taskRes.TaskStatuses[0].ContainerID job.Status = taskRes.TaskStatuses[0].State - if job.StartTime == 0 { + if job.StartTime == 0 && !taskRes.TaskStatuses[0].StartAt.IsZero() { job.StartTime = timeutil.TimeStamp(taskRes.TaskStatuses[0].StartAt.Unix()) } } diff --git a/routers/api/v1/repo/modelarts.go b/routers/api/v1/repo/modelarts.go index 5675ed20a..c6e2892ea 100755 --- a/routers/api/v1/repo/modelarts.go +++ b/routers/api/v1/repo/modelarts.go @@ -68,7 +68,7 @@ func GetModelArtsNotebook2(ctx *context.APIContext) { ctx.NotFound(err) return } - if job.StartTime == 0 { + if job.StartTime == 0 && result.Lease.CreateTime > 0 { job.StartTime = timeutil.TimeStamp(result.Lease.CreateTime / 1000) } job.Status = result.Status @@ -140,7 +140,7 @@ func GetModelArtsTrainJobVersion(ctx *context.APIContext) { ctx.NotFound(err) return } - if job.StartTime == 0 { + if job.StartTime == 0 && result.StartTime > 0 { job.StartTime = timeutil.TimeStamp(result.StartTime / 1000) } job.Status = modelarts.TransTrainJobStatus(result.IntStatus) @@ -379,7 +379,7 @@ func GetModelArtsInferenceJob(ctx *context.APIContext) { ctx.NotFound(err) return } - if job.StartTime == 0 { + if job.StartTime == 0 && result.StartTime > 0 { job.StartTime = timeutil.TimeStamp(result.StartTime / 1000) } job.Status = modelarts.TransTrainJobStatus(result.IntStatus) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index cdaa8b515..9ff299ba9 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -381,7 +381,7 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName) { task.Status = taskRes.TaskStatuses[0].State task.ContainerID = taskRes.TaskStatuses[0].ContainerID task.ContainerIp = taskRes.TaskStatuses[0].ContainerIP - if task.StartTime == 0 { + if task.StartTime == 0 && !taskRes.TaskStatuses[0].StartAt.IsZero() { task.StartTime = timeutil.TimeStamp(taskRes.TaskStatuses[0].StartAt.Unix()) } err = models.UpdateJob(task) @@ -961,7 +961,7 @@ func SyncCloudbrainStatus() { task.Status = taskRes.TaskStatuses[0].State if task.Status != string(models.JobWaiting) { task.Duration = time.Now().Unix() - taskRes.TaskStatuses[0].StartAt.Unix() - if task.StartTime == 0 { + if task.StartTime == 0 && !taskRes.TaskStatuses[0].StartAt.IsZero() { task.StartTime = timeutil.TimeStamp(taskRes.TaskStatuses[0].StartAt.Unix()) } //if task.Status == string(models.JobFailed) { @@ -1008,7 +1008,7 @@ func SyncCloudbrainStatus() { if result != nil { task.Status = result.Status - if task.StartTime == 0 { + if task.StartTime == 0 && result.Lease.CreateTime > 0 { task.StartTime = timeutil.TimeStamp(result.Lease.CreateTime / 1000) } if task.EndTime == 0 && task.Status == string(models.ModelArtsStopped) { @@ -1033,7 +1033,7 @@ func SyncCloudbrainStatus() { task.Duration = result.Duration / 1000 task.TrainJobDuration = result.TrainJobDuration - if task.StartTime == 0 { + if task.StartTime == 0 && result.StartTime > 0 { task.StartTime = timeutil.TimeStamp(result.StartTime / 1000) } if result.Duration != 0 { From ed979526e3cbfd53053d67ef2eeca26696abf67f Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Wed, 23 Mar 2022 16:35:26 +0800 Subject: [PATCH 084/109] fix 1650 --- routers/repo/attachment.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index 668169110..a60bed2a6 100755 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -241,14 +241,20 @@ func GetAttachment(ctx *context.Context) { } if dataSet != nil { - isPermit, err := models.GetUserDataSetPermission(dataSet, ctx.User) - if err != nil { - ctx.Error(http.StatusInternalServerError, "GetUserDataSetPermission", err.Error()) - return - } - if !isPermit { - ctx.Error(http.StatusNotFound) + if !ctx.IsSigned { + ctx.SetCookie("redirect_to", setting.AppSubURL+ctx.Req.URL.RequestURI(), 0, setting.AppSubURL) + ctx.Redirect(setting.AppSubURL + "/user/login") return + } else { + isPermit, err := models.GetUserDataSetPermission(dataSet, ctx.User) + if err != nil { + ctx.Error(http.StatusInternalServerError, "GetUserDataSetPermission", err.Error()) + return + } + if !isPermit { + ctx.Error(http.StatusNotFound) + return + } } } From 2d5f792c39527cd14697b08b313513db0642f095 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Wed, 23 Mar 2022 16:51:37 +0800 Subject: [PATCH 085/109] fix issue --- options/locale/locale_en-US.ini | 1 + options/locale/locale_zh-CN.ini | 1 + templates/explore/dataset_left.tmpl | 8 ++++---- templates/repo/attachment/edit.tmpl | 8 ++++---- templates/repo/datasets/index.tmpl | 4 ---- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index a52f02b79..2f5669b92 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -823,6 +823,7 @@ illustrate.only = Only Datasets In illustrate.zip = Zip Format illustrate.fisrt_end = Can Initiate Cloudbrain Tasks modify_dataset = Modify Dataset +modify_dataset_description = Modify Dataset Description [repo] owner = Owner repo_name = Repository Name diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index e1595e36d..07237fd3a 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -828,6 +828,7 @@ illustrate.only = 只有 illustrate.zip = zip格式 illustrate.fisrt_end = 的数据集才能发起云脑任务 modify_dataset = 修改数据集 +modify_dataset_description = 修改数据集文件描述 [repo] owner=拥有者 diff --git a/templates/explore/dataset_left.tmpl b/templates/explore/dataset_left.tmpl index 98cedc840..44d01cf3a 100644 --- a/templates/explore/dataset_left.tmpl +++ b/templates/explore/dataset_left.tmpl @@ -6,7 +6,7 @@ @@ -27,7 +27,7 @@
{{range $category := categories}} {{$Cate := $.i18n.Tr (printf "dataset.category.%s" $category)}} - {{$Cate}} + {{$Cate}} {{end}}
@@ -44,7 +44,7 @@
{{range $task := tasks}} {{$Task := $.i18n.Tr (printf "dataset.task.%s" $task)}} - {{$Task}} + {{$Task}} {{end}}
@@ -59,7 +59,7 @@
{{range $license := licenses}} - {{$license}} + {{$license}} {{end}}
diff --git a/templates/repo/attachment/edit.tmpl b/templates/repo/attachment/edit.tmpl index 611447548..b8734c86b 100644 --- a/templates/repo/attachment/edit.tmpl +++ b/templates/repo/attachment/edit.tmpl @@ -14,20 +14,20 @@

- 修改数据集文件描述 + {{$.i18n.Tr "dataset.modify_dataset_description"}}

{{.CsrfTokenHtml}} - + {{.Attachment.Type | AttachmentResourceType}} - + {{.Attachment.Name}} - + diff --git a/templates/repo/datasets/index.tmpl b/templates/repo/datasets/index.tmpl index 972b4c25c..fdbda8aa7 100755 --- a/templates/repo/datasets/index.tmpl +++ b/templates/repo/datasets/index.tmpl @@ -228,7 +228,6 @@
{{$x:=.IsPrivate | AttachmentStatus}} - {{$.i18n.Tr "home.show_private"}} {{$.i18n.Tr "org.settings.visibility.public"}}
@@ -265,9 +264,6 @@ {{if .CanDel}} {{$.i18n.Tr "dataset.set_public"}} {{$.i18n.Tr "dataset.set_private"}} - {{else}} - {{$.i18n.Tr "dataset.set_public"}} - {{$.i18n.Tr "dataset.set_private"}} {{end}}

{{$.i18n.Tr "dataset.illustrate"}}:

-

{{$.i18n.Tr "dataset.illustrate.only"}}{{$.i18n.Tr "dataset.illustrate.zip"}}{{$.i18n.Tr "dataset.illustrate.fisrt_end"}};
+

{{$.i18n.Tr "dataset.illustrate.only"}} {{$.i18n.Tr "dataset.illustrate.zip"}} {{$.i18n.Tr "dataset.illustrate.fisrt_end"}};
{{$.i18n.Tr "dataset.dataset_explain"}}

diff --git a/templates/repo/datasets/index.tmpl b/templates/repo/datasets/index.tmpl index fdbda8aa7..a6de99749 100755 --- a/templates/repo/datasets/index.tmpl +++ b/templates/repo/datasets/index.tmpl @@ -131,6 +131,7 @@ {{.i18n.Tr "repo.modelarts.modify"}}
+ {{if and (.dataset.Category) (.dataset.Task) (.dataset.License)}}
{{if .dataset.Category}} {{$category := .dataset.Category}} @@ -144,7 +145,9 @@ {{.dataset.License}} {{end}}
+ {{end}}
+ {{if .dataset.Description}}
@@ -154,6 +157,7 @@
+ {{end}}
@@ -171,10 +175,10 @@
-
+
{{$.i18n.Tr "dataset.dataset_file_name"}}
-
+
{{$.i18n.Tr "repo.model.manage.size"}}
@@ -199,7 +203,7 @@
-
+
{{if .Description}}
{{.Description}}
{{$.i18n.Tr "dataset.download"}}:{{.DownloadCount}}
@@ -220,7 +224,7 @@ -->
-
+
{{.Size | FileSize}}
@@ -241,7 +245,7 @@
{{.CreatedUnix | TimeSinceUnix1}}
-
+
- + diff --git a/templates/repo/datasets/create.tmpl b/templates/repo/datasets/create.tmpl index bd2a4136d..a65a5f351 100644 --- a/templates/repo/datasets/create.tmpl +++ b/templates/repo/datasets/create.tmpl @@ -32,7 +32,7 @@ - + diff --git a/templates/repo/datasets/edit.tmpl b/templates/repo/datasets/edit.tmpl index 6de84a4c9..2c0577eb6 100644 --- a/templates/repo/datasets/edit.tmpl +++ b/templates/repo/datasets/edit.tmpl @@ -36,7 +36,7 @@ - + diff --git a/templates/repo/modelarts/notebook/new.tmpl b/templates/repo/modelarts/notebook/new.tmpl index e8b02e8f7..3c78874eb 100755 --- a/templates/repo/modelarts/notebook/new.tmpl +++ b/templates/repo/modelarts/notebook/new.tmpl @@ -156,4 +156,5 @@ } }); }); + console.log({{.cloudbraintype}}) \ No newline at end of file From a765e65c4ba40c1363c9ca9b1d3b0c212cae2d20 Mon Sep 17 00:00:00 2001 From: wangjr Date: Fri, 25 Mar 2022 11:04:24 +0800 Subject: [PATCH 101/109] =?UTF-8?q?=E5=A4=9A=E5=85=AC=E5=91=8A=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=85=B3=E9=97=AD=E5=BC=B9=E7=AA=97=E5=90=8E=E6=96=B0?= =?UTF-8?q?=E5=85=AC=E5=91=8A=E5=BC=B9=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/base/head.tmpl | 6 +++--- templates/base/head_fluid.tmpl | 6 +++--- templates/base/head_home.tmpl | 6 +++--- templates/base/head_pro.tmpl | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index 2cecee52b..937abd588 100755 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -215,10 +215,10 @@ var _hmt = _hmt || []; localStorage.setItem("isCloseNotice",true) } function isShowNotice(){ - var current_notice = localStorage.getItem("notice") + var current_notice = localStorage.getItem("notices") - if (current_notice != "{{.notice.CommitId}}"){ - localStorage.setItem('notice',"{{.notice.CommitId}}"); + if (current_notice != "{{.notices.CommitId}}"){ + localStorage.setItem('notices',"{{.notices.CommitId}}"); isNewNotice=true; localStorage.setItem("isCloseNotice",false) }else{ diff --git a/templates/base/head_fluid.tmpl b/templates/base/head_fluid.tmpl index 59e542b0b..5340c7cb8 100644 --- a/templates/base/head_fluid.tmpl +++ b/templates/base/head_fluid.tmpl @@ -216,10 +216,10 @@ var _hmt = _hmt || []; localStorage.setItem("isCloseNotice",true) } function isShowNotice(){ - var current_notice = localStorage.getItem("notice") + var current_notice = localStorage.getItem("notices") - if (current_notice != "{{.notice.CommitId}}"){ - localStorage.setItem('notice',"{{.notice.CommitId}}"); + if (current_notice != "{{.notices.CommitId}}"){ + localStorage.setItem('notices',"{{.notices.CommitId}}"); isNewNotice=true; localStorage.setItem("isCloseNotice",false) }else{ diff --git a/templates/base/head_home.tmpl b/templates/base/head_home.tmpl index 561edd5ce..25d7a92ec 100644 --- a/templates/base/head_home.tmpl +++ b/templates/base/head_home.tmpl @@ -220,10 +220,10 @@ var _hmt = _hmt || []; localStorage.setItem("isCloseNotice",true) } function isShowNotice(){ - var current_notice = localStorage.getItem("notice") + var current_notice = localStorage.getItem("notices") - if (current_notice != "{{.notice.CommitId}}"){ - localStorage.setItem('notice',"{{.notice.CommitId}}"); + if (current_notice != "{{.notices.CommitId}}"){ + localStorage.setItem('notices',"{{.notices.CommitId}}"); isNewNotice=true; localStorage.setItem("isCloseNotice",false) }else{ diff --git a/templates/base/head_pro.tmpl b/templates/base/head_pro.tmpl index 82543ac61..75292b6fc 100644 --- a/templates/base/head_pro.tmpl +++ b/templates/base/head_pro.tmpl @@ -217,10 +217,10 @@ var _hmt = _hmt || []; localStorage.setItem("isCloseNotice",true) } function isShowNotice(){ - var current_notice = localStorage.getItem("notice") + var current_notice = localStorage.getItem("notices") - if (current_notice != "{{.notice.CommitId}}"){ - localStorage.setItem('notice',"{{.notice.CommitId}}"); + if (current_notice != "{{.notices.CommitId}}"){ + localStorage.setItem('notices',"{{.notices.CommitId}}"); isNewNotice=true; localStorage.setItem("isCloseNotice",false) }else{ From 624372f01b31a0758286a7e81668e2007a29c6a1 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Fri, 25 Mar 2022 11:46:57 +0800 Subject: [PATCH 102/109] fix bug --- models/repo.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/models/repo.go b/models/repo.go index 2d1fdacfb..5d662db45 100755 --- a/models/repo.go +++ b/models/repo.go @@ -2691,7 +2691,7 @@ func ReadLatestFileInRepo(userName, repoName, refName, treePath string) (*RepoFi log.Error("ReadLatestFileInRepo error when OpenRepository,error=%v", err) return nil, err } - commitID, err := gitRepo.GetBranchCommitID(refName) + _, err = gitRepo.GetBranchCommitID(refName) if err != nil { log.Error("ReadLatestFileInRepo error when GetBranchCommitID,error=%v", err) return nil, err @@ -2723,5 +2723,9 @@ func ReadLatestFileInRepo(userName, repoName, refName, treePath string) (*RepoFi if n >= 0 { buf = buf[:n] } - return &RepoFile{CommitId: commitID, Content: buf}, nil + commitId := "" + if blob != nil { + commitId = fmt.Sprint(blob.ID) + } + return &RepoFile{CommitId: commitId, Content: buf}, nil } From 56ebce77b2fc5d8b783d962ce76fbd33e3f53f19 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Fri, 25 Mar 2022 16:20:39 +0800 Subject: [PATCH 103/109] fix issue --- options/locale/locale_zh-CN.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index ce3ce847e..4cc95f6ba 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -812,7 +812,7 @@ dataset_explain = 数据集:云脑1提供 CPU / GPU 资源,云脑2提供 Asc dataset_instructions_for_use = 使用说明:可以参考启智AI协作平台 dataset_camp_course = 小白训练营课程 dataset_upload = 上传 -dataset_file_name = 文件名字 +dataset_file_name = 文件名称 dataset_available_clusters = 可用集群 dataset_upload_time = 上传时间 download = 下载 From 5d91151a9d5859accc73d6b0e24f1728794d6bb1 Mon Sep 17 00:00:00 2001 From: Gitea Date: Fri, 25 Mar 2022 16:27:40 +0800 Subject: [PATCH 104/109] fix issue --- templates/explore/datasets.tmpl | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/templates/explore/datasets.tmpl b/templates/explore/datasets.tmpl index 238131077..ff18a3da3 100644 --- a/templates/explore/datasets.tmpl +++ b/templates/explore/datasets.tmpl @@ -162,7 +162,7 @@ {{end}}
{{.Title}}
- {{if and (.Category) (.Task) (.License)}} + {{if or (.Category) (.Task) (.License)}}
{{if .Category}} {{$category := .Category}} @@ -216,6 +216,3 @@
{{template "base/footer" .}} - \ No newline at end of file From 927d8b84c716405eb8844897bc4b4b43aca700de Mon Sep 17 00:00:00 2001 From: Gitea Date: Fri, 25 Mar 2022 16:48:09 +0800 Subject: [PATCH 105/109] fix issue --- templates/custom/select_dataset.tmpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/custom/select_dataset.tmpl b/templates/custom/select_dataset.tmpl index e3f9277ba..17e4eee42 100644 --- a/templates/custom/select_dataset.tmpl +++ b/templates/custom/select_dataset.tmpl @@ -21,7 +21,7 @@
${dataset.Repo.OwnerName}/${dataset.Repo.Alias} ${dataset.Name}
- + ${dataset.Description} @@ -47,7 +47,7 @@
${dataset.Repo.OwnerName}/${dataset.Repo.Alias}${dataset.Name}
- + ${dataset.Description} @@ -97,7 +97,7 @@
${dataset.Repo.OwnerName}/${dataset.Repo.Alias}${dataset.Name}
- + ${dataset.Description} From fc335aa811e8d67b4d1389f04ce890760ecc5f2b Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Fri, 25 Mar 2022 17:01:44 +0800 Subject: [PATCH 106/109] fix issue --- templates/explore/dataset_left.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/explore/dataset_left.tmpl b/templates/explore/dataset_left.tmpl index 23c252557..2f9faf5df 100644 --- a/templates/explore/dataset_left.tmpl +++ b/templates/explore/dataset_left.tmpl @@ -51,7 +51,7 @@

- {{.i18n.Tr "dataset.license"}} + {{.i18n.Tr "repo.license"}} {{if $.License}} Clear {{end}} From 2c677c8de84b1c5d3c90dba75ccd99292882774e Mon Sep 17 00:00:00 2001 From: liuzx Date: Fri, 25 Mar 2022 17:58:50 +0800 Subject: [PATCH 107/109] fix-bug --- routers/repo/modelarts.go | 70 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index b37c7b3b6..73d3172a5 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -859,6 +859,7 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) flavorCode := form.Flavor params := form.Params poolID := form.PoolID + isSaveParam := form.IsSaveParam repo := ctx.Repo.Repository codeLocalPath := setting.JobPath + jobName + modelarts.CodePath codeObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.CodePath @@ -983,6 +984,40 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) }) } + //save param config + if isSaveParam == "on" { + if form.ParameterTemplateName == "" { + log.Error("ParameterTemplateName is empty") + trainJobNewDataPrepare(ctx) + ctx.RenderWithErr("保存作业参数时,作业参数名称不能为空", tplModelArtsTrainJobNew, &form) + return + } + + _, err := modelarts.CreateTrainJobConfig(models.CreateConfigParams{ + ConfigName: form.ParameterTemplateName, + Description: form.PrameterDescription, + DataUrl: dataPath, + AppUrl: codeObsPath, + BootFileUrl: codeObsPath + bootFile, + TrainUrl: outputObsPath, + Flavor: models.Flavor{ + Code: flavorCode, + }, + WorkServerNum: workServerNumber, + EngineID: int64(engineID), + LogUrl: logObsPath, + PoolID: poolID, + Parameter: param, + }) + + if err != nil { + log.Error("Failed to CreateTrainJobConfig: %v", err) + trainJobErrorNewDataPrepare(ctx, form) + ctx.RenderWithErr("保存作业参数失败:"+err.Error(), tplModelArtsTrainJobNew, &form) + return + } + } + req := &modelarts.GenerateTrainJobReq{ JobName: jobName, DisplayJobName: displayJobName, @@ -1062,6 +1097,7 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ flavorCode := form.Flavor params := form.Params poolID := form.PoolID + isSaveParam := form.IsSaveParam repo := ctx.Repo.Repository codeLocalPath := setting.JobPath + jobName + modelarts.CodePath codeObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.CodePath + VersionOutputPath + "/" @@ -1161,6 +1197,40 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ }) } + //save param config + if isSaveParam == "on" { + if form.ParameterTemplateName == "" { + log.Error("ParameterTemplateName is empty") + versionErrorDataPrepare(ctx, form) + ctx.RenderWithErr("保存作业参数时,作业参数名称不能为空", tplModelArtsTrainJobVersionNew, &form) + return + } + + _, err := modelarts.CreateTrainJobConfig(models.CreateConfigParams{ + ConfigName: form.ParameterTemplateName, + Description: form.PrameterDescription, + DataUrl: dataPath, + AppUrl: codeObsPath, + BootFileUrl: codeObsPath + bootFile, + TrainUrl: outputObsPath, + Flavor: models.Flavor{ + Code: flavorCode, + }, + WorkServerNum: workServerNumber, + EngineID: int64(engineID), + LogUrl: logObsPath, + PoolID: poolID, + Parameter: parameters.Parameter, + }) + + if err != nil { + log.Error("Failed to CreateTrainJobConfig: %v", err) + versionErrorDataPrepare(ctx, form) + ctx.RenderWithErr("保存作业参数失败:"+err.Error(), tplModelArtsTrainJobVersionNew, &form) + return + } + } + task, err := models.GetCloudbrainByJobIDAndVersionName(jobID, PreVersionName) if err != nil { log.Error("GetCloudbrainByJobIDAndVersionName(%s) failed:%v", jobID, err.Error()) From 1400ba501c380b722b4bcb946df6881a0f9a9a25 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Fri, 25 Mar 2022 18:09:42 +0800 Subject: [PATCH 108/109] #1627 fix bug --- options/locale/locale_en-US.ini | 2 +- templates/repo/cloudbrain/benchmark/index.tmpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 3ebe5a9b5..42ea439c9 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -870,7 +870,7 @@ gpu_type_all=All model_download=Model Download submit_image=Submit Image download=Download -score=score +score=Score cloudbrain=Cloudbrain cloudbrain.new=New cloudbrain diff --git a/templates/repo/cloudbrain/benchmark/index.tmpl b/templates/repo/cloudbrain/benchmark/index.tmpl index 989e3bfd2..4e7d5b4e5 100755 --- a/templates/repo/cloudbrain/benchmark/index.tmpl +++ b/templates/repo/cloudbrain/benchmark/index.tmpl @@ -155,7 +155,7 @@ {{end}} - {{$.i18n.Tr "repo.stop"}} + {{$.i18n.Tr "repo.score"}} From 2c51360819b24d2a4e472fc780b6a078ff7883b1 Mon Sep 17 00:00:00 2001 From: liuzx Date: Mon, 28 Mar 2022 09:50:37 +0800 Subject: [PATCH 109/109] update --- routers/repo/modelarts.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index 73d3172a5..5f9b6bc9c 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -986,6 +986,13 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) //save param config if isSaveParam == "on" { + saveparams := append(param, models.Parameter{ + Label: modelarts.TrainUrl, + Value: outputObsPath, + }, models.Parameter{ + Label: modelarts.DataUrl, + Value: dataPath, + }) if form.ParameterTemplateName == "" { log.Error("ParameterTemplateName is empty") trainJobNewDataPrepare(ctx) @@ -1007,7 +1014,7 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) EngineID: int64(engineID), LogUrl: logObsPath, PoolID: poolID, - Parameter: param, + Parameter: saveparams, }) if err != nil { @@ -1199,6 +1206,13 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ //save param config if isSaveParam == "on" { + saveparams := append(param, models.Parameter{ + Label: modelarts.TrainUrl, + Value: outputObsPath, + }, models.Parameter{ + Label: modelarts.DataUrl, + Value: dataPath, + }) if form.ParameterTemplateName == "" { log.Error("ParameterTemplateName is empty") versionErrorDataPrepare(ctx, form) @@ -1220,7 +1234,7 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ EngineID: int64(engineID), LogUrl: logObsPath, PoolID: poolID, - Parameter: parameters.Parameter, + Parameter: saveparams, }) if err != nil {