From ec29cafc619635721de4d6a3e03c892bca850c15 Mon Sep 17 00:00:00 2001 From: wangjr Date: Fri, 7 Jan 2022 16:48:45 +0800 Subject: [PATCH 001/188] #1179 --- web_src/js/components/MinioUploader.vue | 2 +- web_src/js/components/ObsUploader.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web_src/js/components/MinioUploader.vue b/web_src/js/components/MinioUploader.vue index 0699f957e..85f1c084a 100755 --- a/web_src/js/components/MinioUploader.vue +++ b/web_src/js/components/MinioUploader.vue @@ -81,7 +81,7 @@ export default { dictInvalidFileType: this.dropzoneParams.data('invalid-input-type'), dictFileTooBig: this.dropzoneParams.data('file-too-big'), dictRemoveFile: this.dropzoneParams.data('remove-file'), - previewTemplate + // previewTemplate }); dropzoneUploader.on('addedfile', (file) => { setTimeout(() => { diff --git a/web_src/js/components/ObsUploader.vue b/web_src/js/components/ObsUploader.vue index 3b5bd3162..c5f34ce2f 100755 --- a/web_src/js/components/ObsUploader.vue +++ b/web_src/js/components/ObsUploader.vue @@ -82,7 +82,7 @@ export default { dictInvalidFileType: this.dropzoneParams.data('invalid-input-type'), dictFileTooBig: this.dropzoneParams.data('file-too-big'), dictRemoveFile: this.dropzoneParams.data('remove-file'), - previewTemplate + // previewTemplate }); dropzoneUploader.on('addedfile', (file) => { setTimeout(() => { From 9e5bc3c86a68807cc869a4f54073adc684cbd042 Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Tue, 15 Feb 2022 10:16:48 +0800 Subject: [PATCH 002/188] s3 download link --- models/attachment.go | 13 +++++++++++++ modules/structs/attachment.go | 7 ++++--- templates/repo/datasets/dataset_list.tmpl | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) mode change 100644 => 100755 modules/structs/attachment.go diff --git a/models/attachment.go b/models/attachment.go index fd1df9e43..715cd0a90 100755 --- a/models/attachment.go +++ b/models/attachment.go @@ -88,6 +88,7 @@ func (a *Attachment) APIFormat() *api.Attachment { Size: a.Size, UUID: a.UUID, DownloadURL: a.DownloadURL(), + S3DownloadURL: a.S3DownloadURL(), } } @@ -96,6 +97,18 @@ func (a *Attachment) DownloadURL() string { return fmt.Sprintf("%sattachments/%s", setting.AppURL, a.UUID) } +// DownloadURL returns the download url of the attached file +func (a *Attachment) S3DownloadURL() string { + url := "" + if a.Type == TypeCloudBrainOne { + url, _ = storage.Attachments.PresignedGetURL(setting.Attachment.Minio.BasePath+AttachmentRelativePath(a.UUID), a.Name) + } else if a.Type == TypeCloudBrainTwo { + + } + + return url +} + // AttachmentRelativePath returns the relative path func AttachmentRelativePath(uuid string) string { return path.Join(uuid[0:1], uuid[1:2], uuid) diff --git a/modules/structs/attachment.go b/modules/structs/attachment.go old mode 100644 new mode 100755 index 7becd9433..0f3c2ed6a --- a/modules/structs/attachment.go +++ b/modules/structs/attachment.go @@ -16,9 +16,10 @@ type Attachment struct { Size int64 `json:"size"` DownloadCount int64 `json:"download_count"` // swagger:strfmt date-time - Created time.Time `json:"created_at"` - UUID string `json:"uuid"` - DownloadURL string `json:"browser_download_url"` + Created time.Time `json:"created_at"` + UUID string `json:"uuid"` + DownloadURL string `json:"browser_download_url"` + S3DownloadURL string } // EditAttachmentOptions options for editing attachments diff --git a/templates/repo/datasets/dataset_list.tmpl b/templates/repo/datasets/dataset_list.tmpl index e0c69c745..765adf391 100755 --- a/templates/repo/datasets/dataset_list.tmpl +++ b/templates/repo/datasets/dataset_list.tmpl @@ -14,7 +14,7 @@
{{svg "octicon-flame" 16}} {{(.DownloadCount | PrettyNumber)}} - + {{svg "octicon-file-binary" 16}}
{{if eq .DecompressState 1}} From 1acb67d85c2f82f1df26647c88cf8bf7847b62a6 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 15 Feb 2022 10:33:48 +0800 Subject: [PATCH 003/188] =?UTF-8?q?=E8=A7=A3=E5=86=B3#1461?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/user/notification.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/user/notification.go b/routers/user/notification.go index 9724c8108..0fd6df007 100644 --- a/routers/user/notification.go +++ b/routers/user/notification.go @@ -132,7 +132,7 @@ func getNotifications(c *context.Context) { } c.Data["Title"] = c.Tr("notifications") - c.Data["Keyword"] = keyword + //c.Data["Keyword"] = keyword c.Data["Status"] = status c.Data["Notifications"] = notifications From 6b0a34ca6e261a06cf2681bae5460c331366a446 Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Tue, 15 Feb 2022 11:08:01 +0800 Subject: [PATCH 004/188] obs download link --- models/attachment.go | 2 +- templates/repo/datasets/dataset_list.tmpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/models/attachment.go b/models/attachment.go index 715cd0a90..a6d4b3715 100755 --- a/models/attachment.go +++ b/models/attachment.go @@ -103,7 +103,7 @@ func (a *Attachment) S3DownloadURL() string { if a.Type == TypeCloudBrainOne { url, _ = storage.Attachments.PresignedGetURL(setting.Attachment.Minio.BasePath+AttachmentRelativePath(a.UUID), a.Name) } else if a.Type == TypeCloudBrainTwo { - + url, _ = storage.ObsGetPreSignedUrl(a.UUID, a.Name) } return url diff --git a/templates/repo/datasets/dataset_list.tmpl b/templates/repo/datasets/dataset_list.tmpl index 765adf391..eed89b709 100755 --- a/templates/repo/datasets/dataset_list.tmpl +++ b/templates/repo/datasets/dataset_list.tmpl @@ -14,7 +14,7 @@
{{svg "octicon-flame" 16}} {{(.DownloadCount | PrettyNumber)}} - + {{svg "octicon-file" 16}} {{svg "octicon-file-binary" 16}}
{{if eq .DecompressState 1}} From 6d2b3062481412a06b7eb0755f1ce99ae223c8d0 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 15 Feb 2022 11:47:36 +0800 Subject: [PATCH 005/188] =?UTF-8?q?#1410=E9=A6=96=E9=A1=B5=E9=80=82?= =?UTF-8?q?=E9=85=8D=E7=A7=BB=E5=8A=A8=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- custom/public/css/git.openi.css | 143 +++++++++++++++++++++++++++++--- public/home/home.js | 10 ++- templates/home.tmpl | 8 +- 3 files changed, 144 insertions(+), 17 deletions(-) diff --git a/custom/public/css/git.openi.css b/custom/public/css/git.openi.css index 502ba8d88..c97b48056 100644 --- a/custom/public/css/git.openi.css +++ b/custom/public/css/git.openi.css @@ -44,6 +44,12 @@ -webkit-line-clamp: 2; -webkit-box-orient: vertical; } +.ui.label{ + font-weight: normal; +} +.active { + color: #0366D6 !important; +} .opacity5{ opacity:0.5;} .radius15{ border-radius:1.5rem !important; } @@ -252,6 +258,11 @@ .homeorg-list .card .ui.small.header .content{ width: calc(100% - 3.25em); } +.homepro-tit{ + background: #FFF; + z-index: 9; + position: relative; +} .homepro-list{ position: relative; z-index: 9; @@ -261,8 +272,8 @@ .homepro-list .ui.card{ border-radius: 15px; background-color: #FFF; - box-shadow: 0px 5px 10px 0px rgba(105, 192, 255, 30); - border: 1px solid rgba(105, 192, 255, 40); + box-shadow: 0px 5px 10px 0px rgba(105, 192, 255, .3); + border: 1px solid rgba(105, 192, 255, .4); min-height: 10.8em; } .homepro-list .ui.card>.content>.header{ @@ -277,26 +288,134 @@ position: relative; } +/**seach**/ +/**搜索导航条适配窄屏**/ +.seachnav{ + overflow-x: auto; + overflow-y: hidden; + scrollbar-width: none; /* firefox */ + -ms-overflow-style: none; /* IE 10+ */ +} +.seachnav::-webkit-scrollbar { + display: none; /* Chrome Safari */ +} +.ui.green.button, .ui.green.buttons .button{ + background-color: #5BB973; +} +.seach .repos--seach{ + padding-bottom: 0; + border-bottom: none; +} +.seach .ui.secondary.pointing.menu{ + border-bottom: none; +} +.seach .ui.secondary.pointing.menu .item > i{ + margin-right: 5px; +} +.seach .ui.secondary.pointing.menu .active.item{ + border-bottom-width: 2px; + margin: 0 0 -1px; +} +.seach .ui.menu .active.item>.label { + background: #1684FC; + color: #FFF; +} +.seach .ui.menu .item>.label:not(.active.item>.label) { + background: #e8e8e8; + color: rgba(0,0,0,.6); +} + +.highlight{ + color: red; +} +.ui.list .list>.item>img.image+.content, .ui.list>.item>img.image+.content { + width: calc(100% - 3.0em); + margin-left: 0; +} + +.seach .ui.list .list>.item .header, .seach .ui.list>.item .header{ + margin-bottom: 0.5em; + font-size: 1.4rem !important; + font-weight: normal; +} +.seach .time, .seach .time a{ + font-size: 12px; + color: grey; +} + +.seach .list .item.members .ui.avatar.image { + width: 3.2em; + height: 3.2em; +} +.ui.list .list>.item.members>img.image+.content, .ui.list>.item.members>img.image+.content { + width: calc(100% - 4.0em); + margin-left: 0; +} + @media only screen and (max-width: 767px) { .am-mt-30{ margin-top: 1.5rem !important;} .ui.secondary.hometop.segment{ - margin-bottom: 2.0rem; + margin-bottom: 5.0rem; } - .bannerpic, .i-code-pic{ + .bannerpic{ display: none; } - .i-code h2::before { - left: calc(-5.0rem + 6px); + #homenews{ + bottom: -3em; } - .i-code h2.am-bw::before{ - left: calc(-4.0rem + 6px); + #homenews > p { + margin-left: 1.0em; + } + .homenews{ + padding-left: 1.3em !important; + border-radius: 1.5em; + } + .homenews::before{ + left: 2em; + } + .homeorg{ + padding-left: 3.5em; + } + .homeorg-tit::after { + left: -2.3em; + } + .homeorg-list{ + margin: 0 0 2.0em !important; + } + .homeorg-list > .column{ + width: 3em !important; + margin-left: -0.5em; + padding: 0.5rem 0 0 !important; + } + .homeorg-list .card{ + background: none !important; + } + .homeorg-list .card > .content{ + padding: 0 !important; + } + + .homeorg-list > .column .card .ui.header>img{ + width: 3.0em; + height: 3.0em; + border-radius: 2.0em; + border: 2px solid #FFF; + } + .homeorg-list > .column .card .ui.header > .content{ + display: none; } .leftline01{ - width: calc(50% - 4.0rem); + width: 4.0em; + bottom: 4em; + border-radius: 0 0 0 3.0em; + } + .leftline02, .leftline02-2{ + left: 6.0em; + top: calc(-4.0em - 2px); + border-radius: 0 3.0em 3.0em 0; + width: calc(50% - 6.0em); } - .leftline02{ - left: calc(50% - 1.0rem); - top: calc(-3.5rem - 2px); + .leftline02-2 { + width: calc(50% - 8.0em); } } diff --git a/public/home/home.js b/public/home/home.js index f49c8248b..bc8932642 100644 --- a/public/home/home.js +++ b/public/home/home.js @@ -17,7 +17,7 @@ var swiperNewMessage = new Swiper(".newslist", { }, }); var swiperRepo = new Swiper(".homepro-list", { - slidesPerView: 3, + slidesPerView: 1, slidesPerColumn: 2, slidesPerColumnFill:'row', spaceBetween: 30, @@ -29,6 +29,14 @@ var swiperRepo = new Swiper(".homepro-list", { delay: 2500, disableOnInteraction: false, }, + breakpoints: { + 768: { + slidesPerView: 2, + }, + 1024: { + slidesPerView: 3, + }, + }, }); var output = document.getElementById("newmessage"); diff --git a/templates/home.tmpl b/templates/home.tmpl index f43639a14..08893d71e 100755 --- a/templates/home.tmpl +++ b/templates/home.tmpl @@ -20,7 +20,7 @@

* {{.page_only_dynamic}}

-
+
-
+
@@ -78,7 +78,7 @@

{{.page_dev_env}}

{{.page_dev_env_desc}}

-
+
@@ -158,4 +158,4 @@ -{{template "base/footer" .}} \ No newline at end of file +{{template "base/footer" .}} From 755688bb6f857f3a7830c3110b91e47ae20db264 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 15 Feb 2022 17:04:06 +0800 Subject: [PATCH 006/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E7=9A=84=E9=80=9A=E7=9F=A5=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/action.go | 2 ++ modules/notification/action/action.go | 15 +++++++++++++++ modules/notification/base/notifier.go | 2 ++ modules/notification/base/null.go | 4 ++++ modules/notification/notification.go | 7 +++++++ routers/repo/attachment.go | 4 +++- 6 files changed, 33 insertions(+), 1 deletion(-) diff --git a/models/action.go b/models/action.go index 003dc1b20..deb16f6c3 100755 --- a/models/action.go +++ b/models/action.go @@ -49,6 +49,8 @@ const ( ActionApprovePullRequest // 21 ActionRejectPullRequest // 22 ActionCommentPull // 23 + + ActionUploadAttachment //24 ) // Action represents user operation type and other information to diff --git a/modules/notification/action/action.go b/modules/notification/action/action.go index 9956940f3..ba279a3c7 100644 --- a/modules/notification/action/action.go +++ b/modules/notification/action/action.go @@ -314,3 +314,18 @@ func (a *actionNotifier) NotifySyncDeleteRef(doer *models.User, repo *models.Rep log.Error("notifyWatchers: %v", err) } } + +func NotifyUploadAttachment(doer *models.User, repo *models.Repository, attachment *models.Attachment) { + if err := models.NotifyWatchers(&models.Action{ + ActUserID: repo.OwnerID, + ActUser: repo.MustOwner(), + OpType: models.ActionUploadAttachment, + RepoID: repo.ID, + Repo: repo, + IsPrivate: repo.IsPrivate, + RefName: attachment.Name, + Content: attachment.UUID, + }); err != nil { + log.Error("notifyWatchers: %v", err) + } +} diff --git a/modules/notification/base/notifier.go b/modules/notification/base/notifier.go index 0b3e1173b..95331131f 100644 --- a/modules/notification/base/notifier.go +++ b/modules/notification/base/notifier.go @@ -53,4 +53,6 @@ type Notifier interface { NotifySyncPushCommits(pusher *models.User, repo *models.Repository, refName, oldCommitID, newCommitID string, commits *repository.PushCommits) NotifySyncCreateRef(doer *models.User, repo *models.Repository, refType, refFullName string) NotifySyncDeleteRef(doer *models.User, repo *models.Repository, refType, refFullName string) + + NotifyUploadAttachment(doer *models.User, repo *models.Repository, attachment *models.Attachment) } diff --git a/modules/notification/base/null.go b/modules/notification/base/null.go index d2fd51d71..6450c1f0f 100644 --- a/modules/notification/base/null.go +++ b/modules/notification/base/null.go @@ -150,3 +150,7 @@ func (*NullNotifier) NotifySyncCreateRef(doer *models.User, repo *models.Reposit // NotifySyncDeleteRef places a place holder function func (*NullNotifier) NotifySyncDeleteRef(doer *models.User, repo *models.Repository, refType, refFullName string) { } + +func (*NullNotifier) NotifyUploadAttachment(doer *models.User, repo *models.Repository, attachment *models.Attachment) { + +} diff --git a/modules/notification/notification.go b/modules/notification/notification.go index d12024663..7b0203a5c 100644 --- a/modules/notification/notification.go +++ b/modules/notification/notification.go @@ -37,6 +37,13 @@ func NewContext() { RegisterNotifier(action.NewNotifier()) } +// NotifyUploadAttachment notifies attachment upload message to notifiers +func NotifyUploadAttachment(doer *models.User, repo *models.Repository, attachment *models.Attachment) { + for _, notifier := range notifiers { + notifier.NotifyUploadAttachment(doer, repo, attachment) + } +} + // NotifyCreateIssueComment notifies issue comment related message to notifiers func NotifyCreateIssueComment(doer *models.User, repo *models.Repository, issue *models.Issue, comment *models.Comment) { diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index 8443d6488..dc15be9f1 100755 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -20,11 +20,11 @@ import ( "code.gitea.io/gitea/modules/labelmsg" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/minio_ext" + "code.gitea.io/gitea/modules/notification" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/storage" "code.gitea.io/gitea/modules/upload" "code.gitea.io/gitea/modules/worker" - gouuid "github.com/satori/go.uuid" ) @@ -846,6 +846,8 @@ func CompleteMultipart(ctx *context.Context) { return } + notification.NotifyUploadAttachment(ctx.User, ctx.Repo.Repository, attachment) + if attachment.DatasetID != 0 { if isCanDecompress(attachment.Name) { if typeCloudBrain == models.TypeCloudBrainOne { From 80ec65ea46c6450143ed3a96a404423eb567646b Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Tue, 15 Feb 2022 17:11:05 +0800 Subject: [PATCH 007/188] =?UTF-8?q?=E4=BA=91=E8=84=91=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E8=BF=90=E7=BB=B4=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/cloudbrain.go | 58 ++++++++++++++++++--- routers/admin/cloudbrains.go | 98 ++++++++++++++++++++++++++++++++++++ routers/routes/routes.go | 3 ++ 3 files changed, 151 insertions(+), 8 deletions(-) create mode 100644 routers/admin/cloudbrains.go diff --git a/models/cloudbrain.go b/models/cloudbrain.go index 82c4c6b83..1a8496355 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -209,17 +209,20 @@ type GetImagesPayload struct { type CloudbrainsOptions struct { ListOptions - RepoID int64 // include all repos if empty - UserID int64 - JobID string - SortType string - CloudbrainIDs []int64 - // JobStatus CloudbrainStatus + RepoID int64 // include all repos if empty + UserID int64 + JobID string + SortType string + CloudbrainIDs []int64 + JobStatus []string + JobStatusNot bool + Keyword string Type int JobTypes []string VersionName string IsLatestVersion string JobTypeNot bool + NeedRepoInfo bool } type TaskPod struct { @@ -1015,7 +1018,32 @@ func Cloudbrains(opts *CloudbrainsOptions) ([]*CloudbrainInfo, int64, error) { cond = cond.And(builder.In("cloudbrain.id", opts.CloudbrainIDs)) } - count, err := sess.Where(cond).Count(new(Cloudbrain)) + if len(opts.JobStatus) > 0 { + if opts.JobStatusNot { + cond = cond.And( + builder.NotIn("cloudbrain.status", opts.JobStatus), + ) + } else { + cond = cond.And( + builder.In("cloudbrain.status", opts.JobStatus), + ) + } + } + + var count int64 + var err error + condition := "cloudbrain.user_id = `user`.id" + if len(opts.Keyword) == 0 { + count, err = sess.Where(cond).Count(new(Cloudbrain)) + } else { + lowerKeyWord := strings.ToLower(opts.Keyword) + + cond = cond.And(builder.Or(builder.Like{"LOWER(cloudbrain.job_name)", lowerKeyWord}), builder.Like{"`user`.lower_name", lowerKeyWord}) + count, err = sess.Table(&Cloudbrain{}).Where(cond). + Join("left", "`user`", condition).Count(new(CloudbrainInfo)) + + } + if err != nil { return nil, 0, fmt.Errorf("Count: %v", err) } @@ -1033,11 +1061,25 @@ func Cloudbrains(opts *CloudbrainsOptions) ([]*CloudbrainInfo, int64, error) { sess.OrderBy("cloudbrain.created_unix DESC") cloudbrains := make([]*CloudbrainInfo, 0, setting.UI.IssuePagingNum) if err := sess.Table(&Cloudbrain{}).Where(cond). - Join("left", "`user`", "cloudbrain.user_id = `user`.id"). + Join("left", "`user`", condition). Find(&cloudbrains); err != nil { return nil, 0, fmt.Errorf("Find: %v", err) } + if opts.NeedRepoInfo { + var ids []int64 + for _, task := range cloudbrains { + ids = append(ids, task.RepoID) + } + repositoryMap, err := GetRepositoriesMapByIDs(ids) + if err == nil { + for _, task := range cloudbrains { + task.Repo = repositoryMap[task.RepoID] + } + } + + } + return cloudbrains, count, nil } diff --git a/routers/admin/cloudbrains.go b/routers/admin/cloudbrains.go new file mode 100644 index 000000000..8bc4bb03d --- /dev/null +++ b/routers/admin/cloudbrains.go @@ -0,0 +1,98 @@ +package admin + +import ( + "strings" + + "code.gitea.io/gitea/modules/modelarts" + + "code.gitea.io/gitea/models" + "code.gitea.io/gitea/modules/base" + "code.gitea.io/gitea/modules/context" + "code.gitea.io/gitea/modules/setting" +) + +const ( + tplCloudBrains base.TplName = "admin/cloudbrain/list" +) + +func CloudBrains(ctx *context.Context) { + ctx.Data["Title"] = ctx.Tr("admin.cloudBrains") + ctx.Data["PageIsAdmin"] = true + ctx.Data["PageIsAdminCloudBrains"] = true + + listType := ctx.Query("listType") + jobType := ctx.Query("jobType") + jobStatus := ctx.Query("jobStatus") + + ctx.Data["ListType"] = listType + ctx.Data["JobType"] = jobType + ctx.Data["JobStatus"] = jobStatus + + page := ctx.QueryInt("page") + if page <= 0 { + page = 1 + } + debugType := modelarts.DebugType + if listType == models.GPUResource { + debugType = models.TypeCloudBrainOne + } else if listType == models.NPUResource { + debugType = models.TypeCloudBrainTwo + } + + var jobTypes []string + jobTypeNot := false + if jobType == string(models.JobTypeDebug) { + jobTypes = append(jobTypes, string(models.JobTypeSnn4imagenet), string(models.JobTypeBrainScore), string(models.JobTypeDebug)) + } else if jobType != "all" && jobType != "" { + jobTypes = append(jobTypes, jobType) + } + + var jobStatuses []string + jobStatusNot := false + if jobStatus == "other" { + jobStatusNot = true + jobStatuses = append(jobStatuses, string(models.ModelArtsTrainJobWaiting), string(models.ModelArtsTrainJobFailed), string(models.ModelArtsRunning), string(models.ModelArtsTrainJobCompleted), + string(models.ModelArtsStarting), string(models.ModelArtsRestarting), string(models.ModelArtsStartFailed), + string(models.ModelArtsStopping), string(models.ModelArtsStopped)) + } else if jobStatus != "all" && jobStatus != "" { + jobStatuses = append(jobStatuses, jobStatus) + } + + keyword := strings.Trim(ctx.Query("q"), " ") + + ciTasks, count, err := models.Cloudbrains(&models.CloudbrainsOptions{ + ListOptions: models.ListOptions{ + Page: page, + PageSize: setting.UI.IssuePagingNum, + }, + Keyword: keyword, + Type: debugType, + JobTypeNot: jobTypeNot, + JobStatusNot: jobStatusNot, + JobStatus: jobStatuses, + JobTypes: jobTypes, + NeedRepoInfo: true, + }) + if err != nil { + ctx.ServerError("Get job failed:", err) + return + } + + for i, task := range ciTasks { + ciTasks[i].CanDebug = true + ciTasks[i].CanDel = true + ciTasks[i].Cloudbrain.ComputeResource = task.ComputeResource + } + + pager := context.NewPagination(int(count), setting.UI.IssuePagingNum, page, 5) + pager.SetDefaultParams(ctx) + pager.AddParam(ctx, "listType", "ListType") + ctx.Data["Page"] = pager + ctx.Data["PageIsCloudBrain"] = true + ctx.Data["Tasks"] = ciTasks + ctx.Data["CanCreate"] = true + ctx.Data["Keyword"] = keyword + + ctx.HTML(200, tplCloudBrains) + +} diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 9690c115d..a915daf64 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -507,6 +507,9 @@ func RegisterRoutes(m *macaron.Macaron) { m.Get("", admin.Datasets) // m.Post("/delete", admin.DeleteDataset) }) + m.Group("/cloudbrains", func() { + m.Get("", admin.CloudBrains) + }) m.Group("/^:configType(hooks|system-hooks)$", func() { m.Get("", admin.DefaultOrSystemWebhooks) From d1f43bf7f51766eff183161908e85703c620cfc3 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 15 Feb 2022 17:14:41 +0800 Subject: [PATCH 008/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E7=9A=84=E9=80=9A=E7=9F=A5=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- modules/notification/action/action.go | 2 +- modules/notification/notification.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/notification/action/action.go b/modules/notification/action/action.go index ba279a3c7..4c40df114 100644 --- a/modules/notification/action/action.go +++ b/modules/notification/action/action.go @@ -315,7 +315,7 @@ func (a *actionNotifier) NotifySyncDeleteRef(doer *models.User, repo *models.Rep } } -func NotifyUploadAttachment(doer *models.User, repo *models.Repository, attachment *models.Attachment) { +func (a *actionNotifier) NotifyUploadAttachment(doer *models.User, repo *models.Repository, attachment *models.Attachment) { if err := models.NotifyWatchers(&models.Action{ ActUserID: repo.OwnerID, ActUser: repo.MustOwner(), diff --git a/modules/notification/notification.go b/modules/notification/notification.go index 7b0203a5c..3179dd5f9 100644 --- a/modules/notification/notification.go +++ b/modules/notification/notification.go @@ -6,6 +6,7 @@ package notification import ( "code.gitea.io/gitea/models" + "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/notification/action" "code.gitea.io/gitea/modules/notification/base" "code.gitea.io/gitea/modules/notification/indexer" @@ -39,7 +40,9 @@ func NewContext() { // NotifyUploadAttachment notifies attachment upload message to notifiers func NotifyUploadAttachment(doer *models.User, repo *models.Repository, attachment *models.Attachment) { + log.Info("send attachment to db.") for _, notifier := range notifiers { + log.Info("send attachment to notifiers.") notifier.NotifyUploadAttachment(doer, repo, attachment) } } From 075516d5ab43f296ca2991112a02c07ba9f5bbde Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 15 Feb 2022 17:21:57 +0800 Subject: [PATCH 009/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E7=9A=84=E9=80=9A=E7=9F=A5=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- modules/notification/action/action.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/notification/action/action.go b/modules/notification/action/action.go index 4c40df114..cc86d927a 100644 --- a/modules/notification/action/action.go +++ b/modules/notification/action/action.go @@ -318,7 +318,7 @@ func (a *actionNotifier) NotifySyncDeleteRef(doer *models.User, repo *models.Rep func (a *actionNotifier) NotifyUploadAttachment(doer *models.User, repo *models.Repository, attachment *models.Attachment) { if err := models.NotifyWatchers(&models.Action{ ActUserID: repo.OwnerID, - ActUser: repo.MustOwner(), + ActUser: doer, OpType: models.ActionUploadAttachment, RepoID: repo.ID, Repo: repo, From 9c460221646f6d7aefc469341c76118144d9abb5 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 15 Feb 2022 17:54:03 +0800 Subject: [PATCH 010/188] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E7=9A=84=E9=80=9A=E7=9F=A5=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/attachment.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index dc15be9f1..91c0e7d28 100755 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -845,8 +845,9 @@ func CompleteMultipart(ctx *context.Context) { ctx.Error(500, fmt.Sprintf("InsertAttachment: %v", err)) return } - - notification.NotifyUploadAttachment(ctx.User, ctx.Repo.Repository, attachment) + dataset, _ := models.GetDatasetByID(attachment.DatasetID) + repository, _ := models.GetRepositoryByID(dataset.RepoID) + notification.NotifyUploadAttachment(ctx.User, repository, attachment) if attachment.DatasetID != 0 { if isCanDecompress(attachment.Name) { @@ -867,7 +868,6 @@ func CompleteMultipart(ctx *context.Context) { labelmsg.SendDecompressAttachToLabelOBS(string(attachjson)) } } else { - dataset, _ := models.GetDatasetByID(attachment.DatasetID) var labelMap map[string]string labelMap = make(map[string]string) labelMap["UUID"] = uuid From 43cb44f26b28aaaad851a5e74e58e4e765a0d824 Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Wed, 16 Feb 2022 09:09:25 +0800 Subject: [PATCH 011/188] no cache when download --- routers/repo/download.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/routers/repo/download.go b/routers/repo/download.go index 5b8982102..f1b6e09b7 100755 --- a/routers/repo/download.go +++ b/routers/repo/download.go @@ -28,7 +28,8 @@ func ServeData(ctx *context.Context, name string, reader io.Reader) error { buf = buf[:n] } - ctx.Resp.Header().Set("Cache-Control", "public,max-age=86400") + //ctx.Resp.Header().Set("Cache-Control", "public,max-age=86400") + ctx.Resp.Header().Set("Cache-Control", "max-age=0") name = path.Base(name) // Google Chrome dislike commas in filenames, so let's change it to a space From b5caaea9859012e224a99753acd24d8e1cc48e67 Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Wed, 16 Feb 2022 10:31:43 +0800 Subject: [PATCH 012/188] fix 1503 --- modules/modelarts/resty.go | 4 +++- routers/repo/modelarts.go | 12 ++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/modelarts/resty.go b/modules/modelarts/resty.go index afc5a14c0..28fcdd49a 100755 --- a/modules/modelarts/resty.go +++ b/modules/modelarts/resty.go @@ -30,9 +30,11 @@ const ( errorCodeExceedLimit = "ModelArts.0118" //notebook 2.0 - urlNotebook2 = "/notebooks" + urlNotebook2 = "/notebooks" + //error code modelartsIllegalToken = "ModelArts.6401" + NotebookNotFound = "ModelArts.6404" ) func getRestyClient() *resty.Client { diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index 7e9ae3c09..9dea34c82 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -307,7 +307,7 @@ func NotebookDebug2(ctx *context.Context) { ctx.RenderWithErr(err.Error(), tplModelArtsNotebookIndex, nil) return } - + ctx.Redirect(result.Url) } @@ -387,7 +387,7 @@ func NotebookManage(ctx *context.Context) { log.Error("ManageNotebook2(%s) failed:%v", task.JobName, err.Error(), ctx.Data["MsgID"]) resultCode = "-1" errorMsg = err.Error() - if strings.Contains(err.Error(), "ModelArts.6404") { + if strings.Contains(err.Error(), modelarts.NotebookNotFound) { errorMsg = "the job's version is too old and can not be restarted" } break @@ -428,8 +428,12 @@ func NotebookDel(ctx *context.Context) { _, err := modelarts.DelNotebook2(jobID) if err != nil { log.Error("DelNotebook2(%s) failed:%v", task.JobName, err.Error()) - ctx.ServerError("DelNotebook2 failed", err) - return + if strings.Contains(err.Error(), modelarts.NotebookNotFound) { + log.Info("old notebook version") + } else { + ctx.ServerError("DelNotebook2 failed", err) + return + } } err = models.DeleteJob(task) From e5ca2fcd0d200a89a4a8c1ec6fef5ff1c4e60f1f Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Wed, 16 Feb 2022 11:29:30 +0800 Subject: [PATCH 013/188] =?UTF-8?q?=E4=BA=91=E8=84=91=E8=BF=90=E7=BB=B4?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=AF=BC=E5=87=BA=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- options/locale/locale_en-US.ini | 4 ++ options/locale/locale_zh-CN.ini | 3 + routers/admin/cloudbrains.go | 119 +++++++++++++++++++++++++++++++- routers/routes/routes.go | 1 + 4 files changed, 126 insertions(+), 1 deletion(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index b3ede3b06..318348d56 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -864,9 +864,13 @@ confirm_choice = confirm cloudbran1_tips = Only data in zip format can create cloudbrain tasks cloudbrain_creator=Creator cloudbrain_task = Task Name +cloudbrain_task_type = Task Type +cloudbrain_task_name=Cloud Brain Task Name cloudbrain_operate = Operate cloudbrain_status_createtime = Status/Createtime cloudbrain_status_runtime = Running Time +cloudbrain_jobname_err=Name must start with a lowercase letter or number,can include lowercase letter,number,_ and -,can not end with _, and can be up to 36 characters long. +cloudbrain_query_fail=Failed to query cloudbrain information. record_begintime_get_err=Can not get the record begin time. parameter_is_wrong=The input parameter is wrong. diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 86e88184c..58b0b79b3 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -868,10 +868,13 @@ confirm_choice=确定 cloudbran1_tips=只有zip格式的数据集才能发起云脑任务 cloudbrain_creator=创建者 cloudbrain_task=任务名称 +cloudbrain_task_type=任务类型 +cloudbrain_task_name=云脑侧任务名称 cloudbrain_operate=操作 cloudbrain_status_createtime=状态/创建时间 cloudbrain_status_runtime = 运行时长 cloudbrain_jobname_err=只能以小写字母或数字开头且只包含小写字母、数字、_和-,不能以_结尾,最长36个字符。 +cloudbrain_query_fail=查询云脑任务失败。 record_begintime_get_err=无法获取统计开始时间。 parameter_is_wrong=输入参数错误,请检查输入参数。 diff --git a/routers/admin/cloudbrains.go b/routers/admin/cloudbrains.go index 8bc4bb03d..2058925e5 100644 --- a/routers/admin/cloudbrains.go +++ b/routers/admin/cloudbrains.go @@ -1,18 +1,27 @@ package admin import ( + "net/http" + "net/url" + "strconv" "strings" + "time" + + "github.com/360EntSecGroup-Skylar/excelize/v2" "code.gitea.io/gitea/modules/modelarts" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" + "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" ) const ( - tplCloudBrains base.TplName = "admin/cloudbrain/list" + tplCloudBrains base.TplName = "admin/cloudbrain/list" + EXCEL_DATE_FORMAT = "20060102150405" + CREATE_TIME_FORMAT = "2006/01/02 15:04:05.00" ) func CloudBrains(ctx *context.Context) { @@ -96,3 +105,111 @@ func CloudBrains(ctx *context.Context) { ctx.HTML(200, tplCloudBrains) } + +func DownloadCloudBrains(ctx *context.Context) { + + page := 1 + + pageSize := 300 + + var cloudBrain = ctx.Tr("repo.cloudbrain") + fileName := getFileName(cloudBrain) + + _, total, err := models.Cloudbrains(&models.CloudbrainsOptions{ + ListOptions: models.ListOptions{ + Page: page, + PageSize: 1, + }, + Type: modelarts.DebugType, + NeedRepoInfo: false, + }) + + if err != nil { + log.Warn("Can not get cloud brain info", err) + ctx.Error(http.StatusBadRequest, ctx.Tr("repo.cloudbrain_query_fail")) + return + } + + totalPage := getTotalPage(total, pageSize) + + f := excelize.NewFile() + + index := f.NewSheet(cloudBrain) + f.DeleteSheet("Sheet1") + + for k, v := range allHeader(ctx) { + f.SetCellValue(cloudBrain, k, v) + } + + var row = 2 + for i := 0; i < totalPage; i++ { + + pageRecords, _, err := models.Cloudbrains(&models.CloudbrainsOptions{ + ListOptions: models.ListOptions{ + Page: page, + PageSize: pageSize, + }, + Type: modelarts.DebugType, + NeedRepoInfo: true, + }) + if err != nil { + log.Warn("Can not get cloud brain info", err) + continue + } + for _, record := range pageRecords { + + for k, v := range allValues(row, record, ctx) { + f.SetCellValue(cloudBrain, k, v) + } + row++ + + } + + page++ + } + f.SetActiveSheet(index) + + ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+url.QueryEscape(fileName)) + ctx.Resp.Header().Set("Content-Type", "application/octet-stream") + + f.WriteTo(ctx.Resp) +} + +func allValues(row int, rs *models.CloudbrainInfo, ctx *context.Context) map[string]string { + return map[string]string{getCellName("A", row): rs.JobName, getCellName("B", row): rs.Status, getCellName("C", row): rs.JobType, getCellName("D", row): time.Unix(int64(rs.Cloudbrain.CreatedUnix), 0).Format(CREATE_TIME_FORMAT), getCellName("E", row): getDurationTime(rs), + getCellName("F", row): rs.ComputeResource, getCellName("G", row): rs.Name, getCellName("H", row): rs.Repo.OwnerName + "/" + rs.Repo.Alias, getCellName("I", row): rs.JobName, + } +} + +func getDurationTime(rs *models.CloudbrainInfo) string { + if rs.JobType == "TRAIN" || rs.JobType == "INFERENCE" { + return rs.TrainJobDuration + } else { + return "-" + } +} + +func getFileName(baseName string) string { + return baseName + "_" + time.Now().Format(EXCEL_DATE_FORMAT) + ".xlsx" + +} + +func getTotalPage(total int64, pageSize int) int { + + another := 0 + if int(total)%pageSize != 0 { + another = 1 + } + return int(total)/pageSize + another + +} + +func allHeader(ctx *context.Context) map[string]string { + + return map[string]string{"A1": ctx.Tr("repo.cloudbrain_task"), "B1": ctx.Tr("repo.modelarts.status"), "C1": ctx.Tr("repo.cloudbrain_task_type"), "D1": ctx.Tr("repo.modelarts.createtime"), "E1": ctx.Tr("repo.modelarts.train_job.dura_time"), "F1": ctx.Tr("repo.modelarts.computing_resources"), "G1": ctx.Tr("repo.cloudbrain_creator"), "H1": ctx.Tr("repo.repo_name"), "I1": ctx.Tr("repo.cloudbrain_task_name")} + +} + +func getCellName(col string, row int) string { + return col + strconv.Itoa(row) +} diff --git a/routers/routes/routes.go b/routers/routes/routes.go index a915daf64..9e0dcf930 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -509,6 +509,7 @@ func RegisterRoutes(m *macaron.Macaron) { }) m.Group("/cloudbrains", func() { m.Get("", admin.CloudBrains) + m.Get("/download", admin.DownloadCloudBrains) }) m.Group("/^:configType(hooks|system-hooks)$", func() { From f7ada1132460da5ecabaf6c65e1947ed76e088e6 Mon Sep 17 00:00:00 2001 From: wangjr Date: Wed, 16 Feb 2022 15:19:14 +0800 Subject: [PATCH 014/188] =?UTF-8?q?fix-1456=20=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- options/locale/locale_en-US.ini | 3 +++ options/locale/locale_zh-CN.ini | 3 +++ templates/org/select_pro.tmpl | 25 +++++++++++++------------ 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index b3ede3b06..148f07dee 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -2078,6 +2078,9 @@ custom_select_courses = Customize selected courses recommend_remain_pro = Remain save_fail_tips = The upper limit is exceeded select_again = Select more than 9, please select again! +custom_select_projects = Customize selected projects +customize = Customize +selected_project=Selected Projects form.name_reserved = The organization name '%s' is reserved. form.name_pattern_not_allowed = The pattern '%s' is not allowed in an organization name. diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 86e88184c..b527ef005 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -2088,6 +2088,9 @@ custom_select_courses = 自定义精选课程 recommend_remain_pro = 还能推荐 save_fail_tips = 最多可选9个,保存失败 select_again = 选择超过9个,请重新选择! +custom_select_projects = 自定义精选项目 +customize = 自定义 +selected_project=精选项目 form.name_reserved=组织名称 '%s' 是被保留的。 form.name_pattern_not_allowed=组织名称中不允许使用 "%s"。 diff --git a/templates/org/select_pro.tmpl b/templates/org/select_pro.tmpl index 70b2a9bb3..5105fa40e 100755 --- a/templates/org/select_pro.tmpl +++ b/templates/org/select_pro.tmpl @@ -70,11 +70,11 @@
{{if .tags}} - 精选项目 + {{.i18n.Tr "org.selected_project"}} {{if .IsOrganizationOwner}} - {{svg "octicon-gear" 16}}自定义 + {{svg "octicon-gear" 16}}{{.i18n.Tr "org.customize"}} {{end}} {{end}} @@ -137,10 +137,10 @@