diff --git a/custom/public/css/git.openi.css b/custom/public/css/git.openi.css index 502ba8d88..8e2c25b2d 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; } @@ -250,9 +256,13 @@ box-shadow: none !important; } .homeorg-list .card .ui.small.header .content{ - width: calc(100% - 3.25em); + width: calc(100% - 3.75em); } -.homepro-list{ +.homepro-tit{ + z-index: 9; + position: relative; +} +.homepro-list, .homeorg-list{ position: relative; z-index: 9; padding: 1.0em 1.0em 3.0em; @@ -261,42 +271,156 @@ .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{ line-height: 40px !important; } -.homepro-list .swiper-pagination-bullet-active{ +.homepro-list .swiper-pagination-bullet-active, .homeorg-list .swiper-pagination-bullet-active{ width: 40px; - border-radius: 4px; + border-radius: 4px; } .i-env > div{ 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; + } + .homepro-tit > p{ + background: #FFF; + } + .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{ - left: calc(50% - 1.0rem); - top: calc(-3.5rem - 2px); + .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-2 { + width: calc(50% - 8.0em); + } + .i-env .ui.cards>.card>.content .description{ + display: none; } } diff --git a/models/action.go b/models/action.go index 4821910db..2a9d88399 100755 --- a/models/action.go +++ b/models/action.go @@ -49,6 +49,14 @@ const ( ActionApprovePullRequest // 21 ActionRejectPullRequest // 22 ActionCommentPull // 23 + + ActionUploadAttachment //24 + ActionCreateDebugGPUTask //25 + ActionCreateDebugNPUTask //26 + ActionCreateTrainTask //27 + ActionCreateInferenceTask // 28 + ActionCreateBenchMarkTask //29 + ActionCreateNewModelTask //30 ) // Action represents user operation type and other information to diff --git a/models/attachment.go b/models/attachment.go index fd1df9e43..c322d391b 100755 --- a/models/attachment.go +++ b/models/attachment.go @@ -88,12 +88,25 @@ func (a *Attachment) APIFormat() *api.Attachment { Size: a.Size, UUID: a.UUID, DownloadURL: a.DownloadURL(), + S3DownloadURL: a.S3DownloadURL(), } } // DownloadURL returns the download url of the attached file func (a *Attachment) DownloadURL() string { - return fmt.Sprintf("%sattachments/%s", setting.AppURL, a.UUID) + return fmt.Sprintf("%sattachments/%s?type=%d", setting.AppURL, a.UUID, a.Type) +} + +// S3DownloadURL returns the s3 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 { + url, _ = storage.ObsGetPreSignedUrl(a.UUID, a.Name) + } + + return url } // AttachmentRelativePath returns the relative path diff --git a/models/cloudbrain.go b/models/cloudbrain.go index a51b2c091..8bb3357ae 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -102,7 +102,7 @@ type Cloudbrain struct { UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` Duration int64 TrainJobDuration string - Image string //GPU镜像名称 + Image string //镜像名称 GpuQueue string //GPU类型即GPU队列 ResourceSpecId int //GPU规格id DeletedAt time.Time `xorm:"deleted"` @@ -452,6 +452,16 @@ type FlavorInfo struct { Desc string `json:"desc"` } +type ImageInfosModelArts struct { + ImageInfo []*ImageInfoModelArts `json:"image_info"` +} + +type ImageInfoModelArts struct { + Id string `json:"id"` + Value string `json:"value"` + Desc string `json:"desc"` +} + type PoolInfos struct { PoolInfo []*PoolInfo `json:"pool_info"` } diff --git a/models/repo_statistic.go b/models/repo_statistic.go index d3eb65c30..809cb26c4 100755 --- a/models/repo_statistic.go +++ b/models/repo_statistic.go @@ -12,6 +12,7 @@ type RepoStatistic struct { ID int64 `xorm:"pk autoincr" json:"-"` RepoID int64 `xorm:"unique(s) NOT NULL" json:"repo_id"` Name string `xorm:"INDEX" json:"name"` + Alias string `xorm:"INDEX" json:"alias"` OwnerName string `json:"ownerName"` IsPrivate bool `json:"isPrivate"` IsMirror bool `json:"isMirror"` @@ -63,6 +64,13 @@ type RepoStatistic struct { UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated" json:"-"` } +func (repo *RepoStatistic) DisplayName() string { + if repo.Alias == "" { + return repo.Name + } + return repo.Alias +} + func DeleteRepoStatDaily(date string) error { sess := xStatistic.NewSession() defer sess.Close() diff --git a/modules/auth/modelarts.go b/modules/auth/modelarts.go index 821cd72f8..2d30de6ed 100755 --- a/modules/auth/modelarts.go +++ b/modules/auth/modelarts.go @@ -19,7 +19,8 @@ type CreateModelArtsNotebookForm struct { JobName string `form:"job_name" binding:"Required"` Attachment string `form:"attachment"` Description string `form:"description"` - Flavor string `form:"flavor"` + Flavor string `form:"flavor" binding:"Required"` + ImageId string `form:"image_id" binding:"Required"` } func (f *CreateModelArtsNotebookForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors { diff --git a/modules/cloudbrain/cloudbrain.go b/modules/cloudbrain/cloudbrain.go index f15443b30..b86a2d3f4 100755 --- a/modules/cloudbrain/cloudbrain.go +++ b/modules/cloudbrain/cloudbrain.go @@ -1,16 +1,17 @@ package cloudbrain import ( - "code.gitea.io/gitea/modules/storage" "encoding/json" "errors" "strconv" - "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/storage" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/notification" + "code.gitea.io/gitea/modules/setting" ) const ( @@ -221,13 +222,19 @@ func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, ComputeResource: models.GPUResource, BenchmarkTypeID: benchmarkTypeID, BenchmarkChildTypeID: benchmarkChildTypeID, - Description: description, + Description: description, }) if err != nil { return err } + if string(models.JobTypeBenchmark) == jobType { + notification.NotifyOtherTask(ctx.User, ctx.Repo.Repository, jobID, jobName, models.ActionCreateBenchMarkTask) + } else { + notification.NotifyOtherTask(ctx.User, ctx.Repo.Repository, jobID, jobName, models.ActionCreateDebugGPUTask) + } + return nil } diff --git a/modules/context/auth.go b/modules/context/auth.go index 61a7b029b..dba2c3269 100755 --- a/modules/context/auth.go +++ b/modules/context/auth.go @@ -6,12 +6,14 @@ package context import ( + "encoding/base64" + "net/http" + "strings" + "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/auth" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" - "encoding/base64" - "net/http" "gitea.com/macaron/csrf" "gitea.com/macaron/macaron" @@ -94,7 +96,14 @@ func Toggle(options *ToggleOptions) macaron.Handler { return } - ctx.SetCookie("redirect_to", setting.AppSubURL+ctx.Req.URL.RequestURI(), 0, setting.AppSubURL) + tempUrl := ctx.Req.URL.RequestURI() + + if strings.Contains(tempUrl, "action/star?") || strings.Contains(tempUrl, "action/watch?") { + redirectForStarAndWatch(ctx, tempUrl) + + } else { + ctx.SetCookie("redirect_to", setting.AppSubURL+ctx.Req.URL.RequestURI(), 0, setting.AppSubURL) + } ctx.Redirect(setting.AppSubURL + "/user/login") return } else if !ctx.User.IsActive && setting.Service.RegisterEmailConfirm { @@ -159,6 +168,17 @@ func Toggle(options *ToggleOptions) macaron.Handler { } } +func redirectForStarAndWatch(ctx *Context, tempUrl string) { + splits := strings.Split(tempUrl, "?") + if len(splits) > 1 { + redirectArguments := strings.Split(splits[1], "=") + + if len(redirectArguments) > 0 && redirectArguments[0] == "redirect_to" { + ctx.SetCookie("redirect_to", setting.AppSubURL+strings.Replace(redirectArguments[1], "%2f", "/", -1), 0, setting.AppSubURL) + } + } +} + func basicAuth(ctx *Context) bool { var siteAuth = base64.StdEncoding.EncodeToString([]byte(setting.CBAuthUser + ":" + setting.CBAuthPassword)) auth := ctx.Req.Header.Get("Authorization") diff --git a/modules/modelarts/modelarts.go b/modules/modelarts/modelarts.go index 301c4cb0e..1b7341a56 100755 --- a/modules/modelarts/modelarts.go +++ b/modules/modelarts/modelarts.go @@ -2,6 +2,7 @@ package modelarts import ( "encoding/json" + "errors" "fmt" "path" "strconv" @@ -9,14 +10,15 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/notification" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/storage" ) const ( //notebook - storageTypeOBS = "obs" - autoStopDuration = 4 * 60 * 60 + storageTypeOBS = "obs" + autoStopDuration = 4 * 60 * 60 autoStopDurationMs = 4 * 60 * 60 * 1000 DataSetMountPath = "/home/ma-user/work" @@ -63,6 +65,7 @@ const ( var ( poolInfos *models.PoolInfos FlavorInfos *models.FlavorInfos + ImageInfos *models.ImageInfosModelArts ) type GenerateTrainJobReq struct { @@ -259,35 +262,42 @@ func GenerateTask(ctx *context.Context, jobName, uuid, description, flavor strin if err != nil { return err } - + notification.NotifyOtherTask(ctx.User, ctx.Repo.Repository, jobResult.ID, jobName, models.ActionCreateDebugNPUTask) return nil } -func GenerateNotebook2(ctx *context.Context, jobName, uuid, description, flavor string) error { +func GenerateNotebook2(ctx *context.Context, jobName, uuid, description, flavor, imageId string) error { if poolInfos == nil { json.Unmarshal([]byte(setting.PoolInfos), &poolInfos) } + + imageName, err := GetNotebookImageName(imageId) + if err != nil { + log.Error("GetNotebookImageName failed: %v", err.Error()) + return err + } + jobResult, err := createNotebook2(models.CreateNotebook2Params{ JobName: jobName, Description: description, Flavor: flavor, Duration: autoStopDurationMs, - ImageID: "59a6e9f5-93c0-44dd-85b0-82f390c5d53a", + ImageID: imageId, PoolID: poolInfos.PoolInfo[0].PoolId, Feature: models.NotebookFeature, - Volume: models.VolumeReq{ - Capacity: 100, - Category: models.EVSCategory, - Ownership: models.ManagedOwnership, + Volume: models.VolumeReq{ + Capacity: setting.Capacity, + Category: models.EVSCategory, + Ownership: models.ManagedOwnership, }, - WorkspaceID: "0", + WorkspaceID: "0", }) if err != nil { log.Error("createNotebook2 failed: %v", err.Error()) return err } err = models.CreateCloudbrain(&models.Cloudbrain{ - Status: string(models.JobWaiting), + Status: jobResult.Status, UserID: ctx.User.ID, RepoID: ctx.Repo.Repository.ID, JobID: jobResult.ID, @@ -296,6 +306,7 @@ func GenerateNotebook2(ctx *context.Context, jobName, uuid, description, flavor Type: models.TypeCloudBrainTwo, Uuid: uuid, ComputeResource: models.NPUResource, + Image: imageName, }) if err != nil { @@ -335,12 +346,12 @@ func GenerateTrainJob(ctx *context.Context, req *GenerateTrainJobReq) (err error log.Error("GetAttachmentByUUID(%s) failed:%v", strconv.FormatInt(jobResult.JobID, 10), err.Error()) return err } - + jobId := strconv.FormatInt(jobResult.JobID, 10) err = models.CreateCloudbrain(&models.Cloudbrain{ Status: TransTrainJobStatus(jobResult.Status), UserID: ctx.User.ID, RepoID: ctx.Repo.Repository.ID, - JobID: strconv.FormatInt(jobResult.JobID, 10), + JobID: jobId, JobName: req.JobName, JobType: string(models.JobTypeTrain), Type: models.TypeCloudBrainTwo, @@ -371,7 +382,7 @@ func GenerateTrainJob(ctx *context.Context, req *GenerateTrainJobReq) (err error log.Error("CreateCloudbrain(%s) failed:%v", req.JobName, err.Error()) return err } - + notification.NotifyOtherTask(ctx.User, ctx.Repo.Repository, jobId, req.JobName, models.ActionCreateTrainTask) return nil } @@ -555,12 +566,12 @@ func GenerateInferenceJob(ctx *context.Context, req *GenerateInferenceJobReq) (e log.Error("GetAttachmentByUUID(%s) failed:%v", strconv.FormatInt(jobResult.JobID, 10), err.Error()) return err } - + jobID := strconv.FormatInt(jobResult.JobID, 10) err = models.CreateCloudbrain(&models.Cloudbrain{ Status: TransTrainJobStatus(jobResult.Status), UserID: ctx.User.ID, RepoID: ctx.Repo.Repository.ID, - JobID: strconv.FormatInt(jobResult.JobID, 10), + JobID: jobID, JobName: req.JobName, JobType: string(models.JobTypeInference), Type: models.TypeCloudBrainTwo, @@ -595,6 +606,29 @@ func GenerateInferenceJob(ctx *context.Context, req *GenerateInferenceJobReq) (e log.Error("CreateCloudbrain(%s) failed:%v", req.JobName, err.Error()) return err } - + notification.NotifyOtherTask(ctx.User, ctx.Repo.Repository, jobID, req.JobName, models.ActionCreateInferenceTask) return nil } + +func GetNotebookImageName(imageId string) (string, error) { + var validImage = false + var imageName = "" + + if ImageInfos == nil { + json.Unmarshal([]byte(setting.ImageInfos), &ImageInfos) + } + + for _, imageInfo := range ImageInfos.ImageInfo { + if imageInfo.Id == imageId { + validImage = true + imageName = imageInfo.Value + } + } + + if !validImage { + log.Error("the image id(%s) is invalid", imageId) + return imageName, errors.New("the image id is invalid") + } + + return imageName, nil +} 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/modules/notification/action/action.go b/modules/notification/action/action.go index 4bc296657..babf4acf6 100644 --- a/modules/notification/action/action.go +++ b/modules/notification/action/action.go @@ -330,3 +330,18 @@ func (a *actionNotifier) NotifySyncDeleteRef(doer *models.User, repo *models.Rep log.Error("notifyWatchers: %v", err) } } + +func (a *actionNotifier) NotifyOtherTask(doer *models.User, repo *models.Repository, id string, name string, optype models.ActionType) { + if err := models.NotifyWatchers(&models.Action{ + ActUserID: repo.OwnerID, + ActUser: doer, + OpType: optype, + RepoID: repo.ID, + Repo: repo, + IsPrivate: repo.IsPrivate, + RefName: name, + Content: id, + }); err != nil { + log.Error("notifyWatchers: %v", err) + } +} diff --git a/modules/notification/base/notifier.go b/modules/notification/base/notifier.go index 8325f710c..8d6fdeb52 100644 --- a/modules/notification/base/notifier.go +++ b/modules/notification/base/notifier.go @@ -54,4 +54,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) + + NotifyOtherTask(doer *models.User, repo *models.Repository, id string, name string, optype models.ActionType) } diff --git a/modules/notification/base/null.go b/modules/notification/base/null.go index a74c47980..0d3489882 100644 --- a/modules/notification/base/null.go +++ b/modules/notification/base/null.go @@ -154,3 +154,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) NotifyOtherTask(doer *models.User, repo *models.Repository, id string, name string, optype models.ActionType) { + +} diff --git a/modules/notification/notification.go b/modules/notification/notification.go index d12024663..0fd6fa471 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 NotifyOtherTask(doer *models.User, repo *models.Repository, id string, name string, optype models.ActionType) { + for _, notifier := range notifiers { + notifier.NotifyOtherTask(doer, repo, id, name, optype) + } +} + // 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/modules/setting/setting.go b/modules/setting/setting.go index c6828f9f7..4e063fe05 100755 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -513,6 +513,8 @@ var ( PoolInfos string Flavor string DebugHost string + ImageInfos string + Capacity int //train-job ResourcePools string Engines string @@ -1326,7 +1328,8 @@ func NewContext() { ProfileID = sec.Key("PROFILE_ID").MustString("") PoolInfos = sec.Key("POOL_INFOS").MustString("") Flavor = sec.Key("FLAVOR").MustString("") - DebugHost = sec.Key("DEBUG_SERVER_HOST").MustString("http://192.168.202.73") + ImageInfos = sec.Key("IMAGE_INFOS").MustString("") + Capacity = sec.Key("IMAGE_INFOS").MustInt(100) ResourcePools = sec.Key("Resource_Pools").MustString("") Engines = sec.Key("Engines").MustString("") EngineVersions = sec.Key("Engine_Versions").MustString("") 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/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index fb2b2cd2d..5c0c600be 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -2063,6 +2063,9 @@ people = People teams = Teams lower_members = members lower_repositories = repositories +lower_member=member +lower_repository = repository + create_new_team = New Team create_team = Create Team org_desc = Description @@ -2082,6 +2085,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. @@ -2687,6 +2693,13 @@ mirror_sync_create = synced new reference %[2]s to %[2]s at %[3]s from mirror approve_pull_request = `approved %s#%[2]s` reject_pull_request = `suggested changes for %s#%[2]s` +upload_dataset=`upload dataset %s` +task_gpudebugjob=`created CPU/GPU type debugging task%s` +task_npudebugjob=`created NPU type debugging task %s` +task_trainjob=`created training task%s` +task_inferencejob=`created reasoning task %s` +task_benchmark=`created profiling task %s` +task_createmodel=`created new model %s` [tool] ago = %s ago @@ -2761,6 +2774,7 @@ head.dataset = Datasets foot.council = Council foot.technical_committee = Technical Committee foot.join = Join OpenI +foot.agreement=Use agreement foot.news = News foot.community_news = Community News foot.member_news = Member news diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 782335033..42deebcb7 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -2072,6 +2072,8 @@ people=组织成员 teams=组织团队 lower_members=名成员 lower_repositories=个项目 +lower_member=名成员 +lower_repository=个项目 create_new_team=新建团队 create_team=创建团队 org_desc=组织描述 @@ -2091,6 +2093,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"。 @@ -2697,6 +2702,13 @@ mirror_sync_create=从镜像同步了新的引用 %[2]s mirror_sync_delete=从镜像同步并从 %[3]s 删除了引用 %[2]s approve_pull_request=`同意了 %s#%[2]s` reject_pull_request=`建议变更 %s#%[2]s` +upload_dataset=`上传了数据集文件 %s` +task_gpudebugjob=`创建了CPU/GPU类型调试任务 %s` +task_npudebugjob=`创建了NPU类型调试任务 %s` +task_trainjob=`创建了训练任务 %s` +task_inferencejob=`创建了推理任务 %s` +task_benchmark=`创建了评测任务 %s` +task_createmodel=`导入了新模型 %s` [tool] ago=%s前 @@ -2771,6 +2783,7 @@ head.dataset=数据集 foot.council=理事会 foot.technical_committee=技术委员会 foot.join=加入启智 +foot.agreement=使用协议 foot.news=动态 foot.community_news=社区动态 foot.member_news=成员动态 diff --git a/public/home/home.js b/public/home/home.js index f49c8248b..8fb64b611 100644 --- a/public/home/home.js +++ b/public/home/home.js @@ -6,7 +6,6 @@ if(isEmpty(token)){ token = meta.attr("content"); } } - var swiperNewMessage = new Swiper(".newslist", { direction: "vertical", slidesPerView: 10, @@ -17,7 +16,7 @@ var swiperNewMessage = new Swiper(".newslist", { }, }); var swiperRepo = new Swiper(".homepro-list", { - slidesPerView: 3, + slidesPerView: 1, slidesPerColumn: 2, slidesPerColumnFill:'row', spaceBetween: 30, @@ -29,6 +28,37 @@ var swiperRepo = new Swiper(".homepro-list", { delay: 2500, disableOnInteraction: false, }, + breakpoints: { + 768: { + slidesPerView: 2, + }, + 1024: { + slidesPerView: 3, + }, + }, +}); + +var swiperOrg = new Swiper(".homeorg-list", { + slidesPerView: 1, + slidesPerColumn: 4, + slidesPerColumnFill:'row', + spaceBetween: 15, + pagination: { + el: ".swiper-pagination", + clickable: true, + }, + autoplay: { + delay: 4500, + disableOnInteraction: false, + }, + breakpoints: { + 768: { + slidesPerView: 2, + }, + 1024: { + slidesPerView: 3, + }, + }, }); var output = document.getElementById("newmessage"); @@ -95,12 +125,15 @@ socket.onmessage = function (e) { else if(record.OpType == "2"){ actionName = actionName.replace("{oldRepoName}",record.Content); html += recordPrefix + actionName; - html += " " + getRepotext(record) + "" + html += " " + getRepoLink(record) + "" + } + else if(record.OpType == "24" || record.OpType == "25" || record.OpType == "26" || record.OpType == "27" || record.OpType == "28" || record.OpType == "29" || record.OpType == "30"){ + html += recordPrefix + actionName; + html += " " + record.RefName + "" } else{ continue; } - if(record.Repo != null){ var time = getTime(record.CreatedUnix,currentTime); html += " " + time; @@ -108,13 +141,32 @@ socket.onmessage = function (e) { html += ""; html += ""; } - } output.innerHTML = html; swiperNewMessage.updateSlides(); swiperNewMessage.updateProgress(); }; +function getTaskLink(record){ + var re = getRepoLink(record); + if(record.OpType == 24){ + return re + "/datasets?type=" + record.Content; + }else if(record.OpType == 25){ + return re + "/cloudbrain/" + record.RefName; + }else if(record.OpType == 26){ + return re + "/modelarts/notebook/" + record.Content; + }else if(record.OpType == 27){ + return re + "/modelarts/train-job/" + record.Content; + }else if(record.OpType == 28){ + return re + "/modelarts/inference-job/" + record.Content; + }else if(record.OpType == 29){ + return re + "/cloudbrain/benchmark/" + record.RefName; + }else if(record.OpType == 30){ + return re + "/modelmanage/show_model_info?name=" + record.RefName; + } + return re; +} + function getMsg(record){ var html =""; html += "
"; @@ -246,7 +298,14 @@ var actionNameZH={ "15":"重新开启了合并请求", "17":"从 {repoName} 删除分支 {deleteBranchName}", "22":"建议变更", - "23":"评论了合并请求" + "23":"评论了合并请求", + "24":"上传了数据集文件", + "25":"创建了CPU/GPU类型调试任务", + "26":"创建了NPU类型调试任务", + "27":"创建了训练任务", + "28":"创建了推理任务", + "29":"创建了评测任务", + "30":"导入了新模型" }; var actionNameEN={ @@ -264,7 +323,14 @@ var actionNameEN={ "15":" reopened pull request", "17":" deleted branch {deleteBranchName} from {repoName}", "22":" proposed changes", - "23":" commented on pull request" + "23":" commented on pull request", + "24":" upload dataset ", + "25":" created CPU/GPU type debugging task ", + "26":" created NPU type debugging task ", + "27":" created training task", + "28":" created reasoning task", + "29":" created profiling task", + "30":" created new model" }; var repoAndOrgZH={ @@ -392,7 +458,7 @@ function displayOrg(json){ if (json != null && json.length > 0){ for(var i = 0; i < json.length;i++){ var record = json[i] - html += "
"; + html += "
"; html += " "; html += "
"; html += "
"; @@ -408,4 +474,5 @@ function displayOrg(json){ } } orgDiv.innerHTML = html; + swiperOrg.updateSlides(); } diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 72a68a6d3..36f220cef 100755 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -878,8 +878,9 @@ func RegisterRoutes(m *macaron.Macaron) { }, reqAdmin()) }, reqAnyRepoReader()) m.Group("/cloudbrain", func() { - m.Get("/:jobid", repo.GetCloudbrainTask) - m.Get("/:jobid/log", repo.CloudbrainGetLog) + // m.Get("/:jobid", repo.GetCloudbrainTask) + m.Get("/:jobname", repo.GetCloudbrainTask) + m.Get("/:jobname/log", repo.CloudbrainGetLog) }, reqRepoReader(models.UnitTypeCloudBrain)) m.Group("/modelarts", func() { m.Group("/notebook", func() { diff --git a/routers/api/v1/repo/cloudbrain.go b/routers/api/v1/repo/cloudbrain.go index dd468783d..6a2538048 100755 --- a/routers/api/v1/repo/cloudbrain.go +++ b/routers/api/v1/repo/cloudbrain.go @@ -6,11 +6,12 @@ package repo import ( - "code.gitea.io/gitea/modules/log" "net/http" "sort" "time" + "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/cloudbrain" "code.gitea.io/gitea/modules/context" @@ -48,14 +49,12 @@ func GetCloudbrainTask(ctx *context.APIContext) { err error ) - jobID := ctx.Params(":jobid") - repoID := ctx.Repo.Repository.ID - job, err := models.GetRepoCloudBrainByJobID(repoID, jobID) + jobName := ctx.Params(":jobname") + job, err := models.GetCloudbrainByName(jobName) if err != nil { - ctx.NotFound(err) - return + ctx.Data["error"] = err.Error() } - jobResult, err := cloudbrain.GetJob(jobID) + jobResult, err := cloudbrain.GetJob(job.JobID) if err != nil { ctx.NotFound(err) return @@ -84,7 +83,7 @@ func GetCloudbrainTask(ctx *context.APIContext) { } ctx.JSON(http.StatusOK, map[string]interface{}{ - "JobID": result.Config.JobID, + "JobName": result.Config.JobName, "JobStatus": result.JobStatus.State, "SubState": result.JobStatus.SubState, "CreatedTime": time.Unix(result.JobStatus.CreatedTime/1000, 0).Format("2006-01-02 15:04:05"), @@ -94,8 +93,8 @@ func GetCloudbrainTask(ctx *context.APIContext) { } func CloudbrainGetLog(ctx *context.Context) { - jobID := ctx.Params(":jobid") - _, err := models.GetCloudbrainByJobID(jobID) + jobName := ctx.Params(":jobname") + job, err := models.GetCloudbrainByName(jobName) if err != nil { log.Error("GetCloudbrainByJobID failed: %v", err, ctx.Data["MsgID"]) ctx.ServerError(err.Error(), err) @@ -103,8 +102,8 @@ func CloudbrainGetLog(ctx *context.Context) { } var hits []models.Hits - result, err := cloudbrain.GetJobLog(jobID) - if err != nil{ + result, err := cloudbrain.GetJobLog(job.JobID) + if err != nil { log.Error("GetJobLog failed: %v", err, ctx.Data["MsgID"]) ctx.ServerError(err.Error(), err) return @@ -115,7 +114,7 @@ func CloudbrainGetLog(ctx *context.Context) { if len(result.Hits.Hits) >= cloudbrain.LogPageSize { for { resultNext, err := cloudbrain.GetJobAllLog(result.ScrollID) - if err != nil{ + if err != nil { log.Error("GetJobAllLog failed: %v", err, ctx.Data["MsgID"]) } else { for _, hit := range resultNext.Hits.Hits { @@ -142,8 +141,8 @@ func CloudbrainGetLog(ctx *context.Context) { } ctx.JSON(http.StatusOK, map[string]interface{}{ - "JobID": jobID, - "Content": content, + "JobName": jobName, + "Content": content, }) return diff --git a/routers/api/v1/repo/modelarts.go b/routers/api/v1/repo/modelarts.go index c9f8761c9..27df10e16 100755 --- a/routers/api/v1/repo/modelarts.go +++ b/routers/api/v1/repo/modelarts.go @@ -77,6 +77,7 @@ func GetModelArtsNotebook2(ctx *context.APIContext) { ctx.JSON(http.StatusOK, map[string]interface{}{ "JobID": jobID, + "JobName": job.JobName, "JobStatus": result.Status, }) diff --git a/routers/api/v1/repo/repo_dashbord.go b/routers/api/v1/repo/repo_dashbord.go index 46596330f..959fb4c9f 100644 --- a/routers/api/v1/repo/repo_dashbord.go +++ b/routers/api/v1/repo/repo_dashbord.go @@ -297,7 +297,7 @@ func allProjectsPeroidHeader(ctx *context.Context) map[string]string { } 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.Name, getCellName("C", row): rs.OwnerName, getCellName("D", row): getIsPrivateDisplay(rs.IsPrivate, ctx), getCellName("E", row): strconv.FormatFloat(rs.RadarTotal, 'f', 2, 64), + 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): getIsPrivateDisplay(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), @@ -317,7 +317,7 @@ func allProjectsOpenIHeader() map[string]string { 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.Name, getCellName("C", row): rs.OwnerName, getCellName("D", row): getIsPrivateDisplay(rs.IsPrivate, ctx), getCellName("E", row): strconv.FormatFloat(rs.RadarTotal, 'f', 2, 64), + 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): getIsPrivateDisplay(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), @@ -466,10 +466,10 @@ func generateCountSql(beginTime time.Time, endTime time.Time, latestDate string, countSql := "SELECT count(*) FROM " + "(SELECT repo_id FROM repo_statistic where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) + " and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) + " group by repo_id) A," + - "(SELECT repo_id,name,is_private,radar_total from public.repo_statistic where date='" + latestDate + "') B" + + "(SELECT repo_id,name,alias,is_private,radar_total from public.repo_statistic where date='" + latestDate + "') B" + " where A.repo_id=B.repo_id" if q != "" { - countSql = countSql + " and LOWER(B.name) like '%" + strings.ToLower(q) + "%'" + countSql = countSql + " and LOWER(B.alias) like '%" + strings.ToLower(q) + "%'" } return countSql } @@ -482,22 +482,22 @@ func generateOpenICountSql(latestDate string) string { } func generateTypeAllSql(beginTime time.Time, endTime time.Time, latestDate string, q string, orderBy string, page int, pageSize int) string { - sql := "SELECT A.repo_id,name,owner_name,is_private,radar_total,num_watches,num_visits,num_downloads,num_pulls,num_commits,num_stars,num_forks,num_issues,num_closed_issues,num_contributor FROM " + + sql := "SELECT A.repo_id,name,alias,owner_name,is_private,radar_total,num_watches,num_visits,num_downloads,num_pulls,num_commits,num_stars,num_forks,num_issues,num_closed_issues,num_contributor FROM " + "(SELECT repo_id,sum(num_visits) as num_visits " + " FROM repo_statistic where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) + " and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) + " group by repo_id) A," + - "(SELECT repo_id,name,owner_name,is_private,radar_total,num_watches,num_downloads,num_pulls,num_commits,num_stars,num_forks,num_issues,num_closed_issues,num_contributor from public.repo_statistic where date='" + latestDate + "') B" + + "(SELECT repo_id,name,alias,owner_name,is_private,radar_total,num_watches,num_downloads,num_pulls,num_commits,num_stars,num_forks,num_issues,num_closed_issues,num_contributor from public.repo_statistic where date='" + latestDate + "') B" + " where A.repo_id=B.repo_id" if q != "" { - sql = sql + " and LOWER(name) like '%" + strings.ToLower(q) + "%'" + sql = sql + " and LOWER(alias) like '%" + strings.ToLower(q) + "%'" } sql = sql + " order by " + orderBy + " desc,repo_id" + " limit " + strconv.Itoa(pageSize) + " offset " + strconv.Itoa((page-1)*pageSize) return sql } func generateTypeAllOpenISql(latestDate string, page int, pageSize int) string { - sql := "SELECT id, repo_id, date, num_watches, num_stars, num_forks, num_downloads, num_comments, num_visits, num_closed_issues, num_versions, num_dev_months, repo_size, dataset_size, num_models, num_wiki_views, num_commits, num_issues, num_pulls, issue_fixed_rate, num_contributor, num_key_contributor, num_contributors_growth, num_commits_growth, num_commit_lines_growth, num_issues_growth, num_comments_growth, impact, completeness, liveness, project_health, team_health, growth, radar_total, name, is_private, owner_name FROM " + + sql := "SELECT id, repo_id, date, num_watches, num_stars, num_forks, num_downloads, num_comments, num_visits, num_closed_issues, num_versions, num_dev_months, repo_size, dataset_size, num_models, num_wiki_views, num_commits, num_issues, num_pulls, issue_fixed_rate, num_contributor, num_key_contributor, num_contributors_growth, num_commits_growth, num_commit_lines_growth, num_issues_growth, num_comments_growth, impact, completeness, liveness, project_health, team_health, growth, radar_total, name,alias, is_private, owner_name FROM " + " public.repo_statistic where date='" + latestDate + "'" sql = sql + " order by radar_total desc,repo_id" + " limit " + strconv.Itoa(pageSize) + " offset " + strconv.Itoa((page-1)*pageSize) @@ -506,14 +506,14 @@ func generateTypeAllOpenISql(latestDate string, page int, pageSize int) string { func generatePageSql(beginTime time.Time, endTime time.Time, latestDate string, q string, orderBy string, page int, pageSize int) string { - sql := "SELECT A.repo_id,name,owner_name,is_private,radar_total,num_watches,num_visits,num_downloads,num_pulls,num_commits,num_stars,num_forks,num_issues,num_closed_issues,num_contributor FROM " + + sql := "SELECT A.repo_id,name,alias,owner_name,is_private,radar_total,num_watches,num_visits,num_downloads,num_pulls,num_commits,num_stars,num_forks,num_issues,num_closed_issues,num_contributor FROM " + "(SELECT repo_id,sum(num_watches_added) as num_watches,sum(num_visits) as num_visits, sum(num_downloads_added) as num_downloads,sum(num_pulls_added) as num_pulls,sum(num_commits_added) as num_commits,sum(num_stars_added) as num_stars,sum(num_forks_added) num_forks,sum(num_issues_added) as num_issues,sum(num_closed_issues_added) as num_closed_issues,sum(num_contributor_added) as num_contributor " + " FROM repo_statistic where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) + " and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) + " group by repo_id) A," + - "(SELECT repo_id,name,owner_name,is_private,radar_total from public.repo_statistic where date='" + latestDate + "') B" + + "(SELECT repo_id,name,alias,owner_name,is_private,radar_total from public.repo_statistic where date='" + latestDate + "') B" + " where A.repo_id=B.repo_id" if q != "" { - sql = sql + " and LOWER(B.name) like '%" + strings.ToLower(q) + "%'" + sql = sql + " and LOWER(B.alias) like '%" + strings.ToLower(q) + "%'" } sql = sql + " order by " + orderBy + " desc,A.repo_id" + " limit " + strconv.Itoa(pageSize) + " offset " + strconv.Itoa((page-1)*pageSize) return sql diff --git a/routers/home.go b/routers/home.go index 397e1990d..2db8d2112 100755 --- a/routers/home.go +++ b/routers/home.go @@ -38,6 +38,7 @@ const ( tplExploreCode base.TplName = "explore/code" tplExploreImages base.TplName = "explore/images" tplExploreExploreDataAnalysis base.TplName = "explore/data_analysis" + tplHomeTerm base.TplName = "terms" ) // Home render home page @@ -596,3 +597,7 @@ func RecommendRepoFromPromote(ctx *context.Context) { ctx.JSON(200, result) } } + +func HomeTerm(ctx *context.Context) { + ctx.HTML(200, tplHomeTerm) +} diff --git a/routers/repo/ai_model_manage.go b/routers/repo/ai_model_manage.go index fe4d9794c..e2040e0d2 100644 --- a/routers/repo/ai_model_manage.go +++ b/routers/repo/ai_model_manage.go @@ -12,6 +12,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/notification" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/storage" uuid "github.com/satori/go.uuid" @@ -113,7 +114,7 @@ func saveModelByParameters(jobId string, versionName string, name string, versio models.UpdateRepositoryUnits(ctx.Repo.Repository, units, deleteUnitTypes) log.Info("save model end.") - + notification.NotifyOtherTask(ctx.User, ctx.Repo.Repository, id, name, models.ActionCreateNewModelTask) return nil } diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index c2d096416..bc843c555 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" ) @@ -845,6 +845,9 @@ func CompleteMultipart(ctx *context.Context) { 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) if attachment.DatasetID != 0 { if isCanDecompress(attachment.Name) { @@ -865,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 diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index ba5fc8a05..344115977 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -350,18 +350,15 @@ func CloudBrainShow(ctx *context.Context) { func cloudBrainShow(ctx *context.Context, tpName base.TplName) { ctx.Data["PageIsCloudBrain"] = true - - var jobID = ctx.Params(":jobid") - task, err := models.GetCloudbrainByJobID(jobID) + var jobName = ctx.Params(":jobname") + task, err := models.GetCloudbrainByName(jobName) if err != nil { ctx.Data["error"] = err.Error() } - - result, err := cloudbrain.GetJob(jobID) + result, err := cloudbrain.GetJob(task.JobID) if err != nil { ctx.Data["error"] = err.Error() } - if result != nil { jobRes, _ := models.ConvertToJobResultPayload(result.Payload) jobRes.Resource.Memory = strings.ReplaceAll(jobRes.Resource.Memory, "Mi", "MB") @@ -369,6 +366,7 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName) { ctx.Data["resource_spec"] = spec taskRoles := jobRes.TaskRoles if jobRes.JobStatus.State != string(models.JobFailed) { + taskRes, _ := models.ConvertToTaskPod(taskRoles[cloudbrain.SubTaskName].(map[string]interface{})) ctx.Data["taskRes"] = taskRes task.Status = taskRes.TaskStatuses[0].State @@ -422,7 +420,7 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName) { ctx.Data["duration"] = util.AddZero(duration/3600000) + ":" + util.AddZero(duration%3600000/60000) + ":" + util.AddZero(duration%60000/1000) ctx.Data["task"] = task - ctx.Data["jobID"] = jobID + // ctx.Data["jobID"] = task.JobID ctx.Data["jobName"] = task.JobName version_list_task := make([]*models.Cloudbrain, 0) version_list_task = append(version_list_task, task) @@ -582,6 +580,7 @@ func logErrorAndUpdateJobStatus(err error, taskInfo *models.Cloudbrain) { } func CloudBrainDel(ctx *context.Context) { + var listType = ctx.Query("debugListType") if err := deleteCloudbrainJob(ctx); err != nil { log.Error("deleteCloudbrainJob failed: %v", err, ctx.Data["msgID"]) ctx.ServerError(err.Error(), err) @@ -1104,6 +1103,9 @@ func GetChildTypes(ctx *context.Context) { } func CloudBrainBenchmarkNew(ctx *context.Context) { + ctx.Data["description"] = "" + ctx.Data["benchmarkTypeID"] = -1 + ctx.Data["benchmark_child_types_id_hidden"] = -1 err := cloudBrainNewDataPrepare(ctx) if err != nil { ctx.ServerError("get new cloudbrain info failed", err) @@ -1206,6 +1208,9 @@ func CloudBrainBenchmarkCreate(ctx *context.Context, form auth.CreateCloudBrainF benchmarkTypeID := form.BenchmarkTypeID benchmarkChildTypeID := form.BenchmarkChildTypeID + ctx.Data["description"] = form.Description + ctx.Data["benchmarkTypeID"] = benchmarkTypeID + ctx.Data["benchmark_child_types_id_hidden"] = benchmarkChildTypeID if !jobNamePattern.MatchString(jobName) { cloudBrainNewDataPrepare(ctx) ctx.RenderWithErr(ctx.Tr("repo.cloudbrain_jobname_err"), tplCloudBrainBenchmarkNew, &form) 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 diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index 7fb8a3c35..b4c17bb3a 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -103,8 +103,13 @@ func MustEnableModelArts(ctx *context.Context) { } func NotebookNew(ctx *context.Context) { - ctx.Data["PageIsCloudBrain"] = true + notebookNewDataPrepare(ctx) + + ctx.HTML(200, tplModelArtsNotebookNew) +} +func notebookNewDataPrepare(ctx *context.Context) error { + ctx.Data["PageIsCloudBrain"] = true t := time.Now() var jobName = jobNamePrefixValid(cutString(ctx.User.Name, 5)) + t.Format("2006010215") + strconv.Itoa(int(t.Unix()))[5:] ctx.Data["job_name"] = jobName @@ -112,26 +117,14 @@ func NotebookNew(ctx *context.Context) { attachs, err := models.GetModelArtsUserAttachments(ctx.User.ID) if err != nil { ctx.ServerError("GetAllUserAttachments failed:", err) - return + return err } - ctx.Data["attachments"] = attachs - ctx.Data["dataset_path"] = modelarts.DataSetMountPath - ctx.Data["env"] = modelarts.NotebookEnv - ctx.Data["notebook_type"] = modelarts.NotebookType - if modelarts.FlavorInfos == nil { - json.Unmarshal([]byte(setting.FlavorInfos), &modelarts.FlavorInfos) - } - ctx.Data["flavors"] = modelarts.FlavorInfos.FlavorInfo - - ctx.HTML(200, tplModelArtsNotebookNew) -} -func notebookNewDataPrepare(ctx *context.Context) error { - ctx.Data["PageIsCloudBrain"] = true - t := time.Now() - var jobName = jobNamePrefixValid(cutString(ctx.User.Name, 5)) + t.Format("2006010215") + strconv.Itoa(int(t.Unix()))[5:] - ctx.Data["job_name"] = jobName + if modelarts.ImageInfos == nil { + json.Unmarshal([]byte(setting.ImageInfos), &modelarts.ImageInfos) + } + ctx.Data["images"] = modelarts.ImageInfos.ImageInfo if modelarts.FlavorInfos == nil { json.Unmarshal([]byte(setting.FlavorInfos), &modelarts.FlavorInfos) @@ -191,8 +184,7 @@ func Notebook2Create(ctx *context.Context, form auth.CreateModelArtsNotebookForm uuid := form.Attachment description := form.Description flavor := form.Flavor - - flavor = "modelarts.bm.910.arm.public.1" + imageId := form.ImageId count, err := models.GetCloudbrainNotebookCountByUserID(ctx.User.ID) if err != nil { @@ -223,7 +215,7 @@ func Notebook2Create(ctx *context.Context, form auth.CreateModelArtsNotebookForm } } - err = modelarts.GenerateNotebook2(ctx, jobName, uuid, description, flavor) + err = modelarts.GenerateNotebook2(ctx, jobName, uuid, description, flavor, imageId) if err != nil { log.Error("GenerateNotebook2 failed, %v", err, ctx.Data["MsgID"]) notebookNewDataPrepare(ctx) @@ -262,12 +254,20 @@ func NotebookShow(ctx *context.Context) { result.CreateTime = time.Unix(int64(result.CreateAt/1000), 0).Format("2006-01-02 15:04:05") result.LatestUpdateTime = time.Unix(int64(result.UpdateAt/1000), 0).Format("2006-01-02 15:04:05") - //result.QueuingInfo.BeginTime = time.Unix(int64(result.QueuingInfo.BeginTimestamp/1000), 0).Format("2006-01-02 15:04:05") - //result.QueuingInfo.EndTime = time.Unix(int64(result.QueuingInfo.EndTimestamp/1000), 0).Format("2006-01-02 15:04:05") } + var datasetDownloadLink string + if task.Uuid != "" && task.UserID == ctx.User.ID { + attachment, err := models.GetAttachmentByUUID(task.Uuid) + if err == nil { + datasetDownloadLink = attachment.S3DownloadURL() + } + } + + ctx.Data["datasetDownloadLink"] = datasetDownloadLink ctx.Data["task"] = task ctx.Data["jobID"] = jobID + ctx.Data["jobName"] = task.JobName ctx.Data["result"] = result ctx.HTML(200, tplModelArtsNotebookShow) } @@ -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 @@ -417,6 +417,7 @@ func NotebookManage(ctx *context.Context) { func NotebookDel(ctx *context.Context) { var jobID = ctx.Params(":jobid") + var listType = ctx.Query("debugListType") task := ctx.Cloudbrain if task.Status != string(models.ModelArtsCreateFailed) && task.Status != string(models.ModelArtsStartFailed) && task.Status != string(models.ModelArtsStopped) { @@ -428,8 +429,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) @@ -1452,6 +1457,7 @@ func TrainJobShow(ctx *context.Context) { ctx.Data["jobName"] = VersionListTasks[0].JobName ctx.Data["version_list_task"] = VersionListTasks ctx.Data["version_list_count"] = VersionListCount + ctx.Data["canDownload"] = cloudbrain.CanDeleteJob(ctx, &VersionListTasks[0].Cloudbrain) ctx.HTML(http.StatusOK, tplModelArtsTrainJobShow) } @@ -2056,6 +2062,7 @@ func InferenceJobShow(ctx *context.Context) { ctx.Data["jobID"] = jobID ctx.Data["jobName"] = task.JobName ctx.Data["task"] = task + ctx.Data["canDownload"] = cloudbrain.CanDeleteJob(ctx, task) tempUids := []int64{} tempUids = append(tempUids, task.UserID) diff --git a/routers/repo/repo_statistic.go b/routers/repo/repo_statistic.go index dce183f49..06f45e608 100755 --- a/routers/repo/repo_statistic.go +++ b/routers/repo/repo_statistic.go @@ -107,6 +107,7 @@ func RepoStatisticDaily(date string) { RepoID: repo.ID, Date: date, Name: repo.Name, + Alias: repo.Alias, IsPrivate: repo.IsPrivate, IsMirror: repo.IsMirror, OwnerName: repo.OwnerName, @@ -282,7 +283,7 @@ func RepoStatisticDaily(date string) { } func getDistinctProjectName(repo *models.Repository) string { - return repo.OwnerName + "/" + repo.Name + return repo.OwnerName + "/" + repo.Alias } func getDatasetSize(repo *models.Repository) (int64, error) { diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index e71e8cb3a..b4adfc347 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -63,11 +63,13 @@ func queryUserDataPage(ctx *context.Context, tableName string, queryObj interfac _, count := models.QueryUserStaticDataByTableName(1, 1, tableName, queryObj, userName) var indexTotal int64 indexTotal = 0 + row := 1 for { re, _ := models.QueryUserStaticDataByTableName(int(indexTotal), PAGE_SIZE, tableName, queryObj, "") log.Info("return count=" + fmt.Sprint(count)) - for i, userRecord := range re { - rows := fmt.Sprint(i + 2) + for _, userRecord := range re { + row++ + rows := fmt.Sprint(row) xlsx.SetCellValue(sheetName, "A"+rows, userRecord.ID) xlsx.SetCellValue(sheetName, "B"+rows, userRecord.Name) xlsx.SetCellValue(sheetName, "C"+rows, userRecord.CodeMergeCount) diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 31ab2a50d..e9c7d3fd1 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -319,6 +319,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Get("/action/notification", routers.ActionNotification) m.Get("/recommend/org", routers.RecommendOrgFromPromote) m.Get("/recommend/repo", routers.RecommendRepoFromPromote) + m.Get("/home/term", routers.HomeTerm) m.Group("/explore", func() { m.Get("", func(ctx *context.Context) { ctx.Redirect(setting.AppSubURL + "/explore/repos") @@ -978,8 +979,10 @@ func RegisterRoutes(m *macaron.Macaron) { }, context.RepoRef()) m.Group("/cloudbrain", func() { - m.Group("/:jobid", func() { + m.Group("/:jobname", func() { m.Get("", reqRepoCloudBrainReader, repo.CloudBrainShow) + }) + m.Group("/:jobid", func() { m.Get("/debug", cloudbrain.AdminOrJobCreaterRight, repo.CloudBrainDebug) m.Post("/commit_image", cloudbrain.AdminOrJobCreaterRight, bindIgnErr(auth.CommitImageCloudBrainForm{}), repo.CloudBrainCommitImage) m.Post("/stop", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.CloudBrainStop) @@ -994,8 +997,10 @@ func RegisterRoutes(m *macaron.Macaron) { m.Group("/benchmark", func() { m.Get("", reqRepoCloudBrainReader, repo.CloudBrainBenchmarkIndex) - m.Group("/:jobid", func() { + m.Group("/:jobname", func() { m.Get("", reqRepoCloudBrainReader, repo.CloudBrainBenchMarkShow) + }) + m.Group("/:jobid", func() { m.Post("/stop", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.CloudBrainStop) m.Post("/del", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.BenchmarkDel) m.Get("/rate", reqRepoCloudBrainReader, repo.GetRate) 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 diff --git a/services/socketwrap/clientManager.go b/services/socketwrap/clientManager.go index 53de73673..3ba35f8ff 100644 --- a/services/socketwrap/clientManager.go +++ b/services/socketwrap/clientManager.go @@ -10,7 +10,7 @@ import ( "github.com/elliotchance/orderedmap" ) -var opTypes = []int{1, 2, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 22, 23} +var opTypes = []int{1, 2, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 22, 23, 24, 25, 26, 27, 28, 29, 30} type ClientsManager struct { Clients *orderedmap.OrderedMap diff --git a/templates/base/footer_content.tmpl b/templates/base/footer_content.tmpl index 42084b871..bcf46f9f0 100755 --- a/templates/base/footer_content.tmpl +++ b/templates/base/footer_content.tmpl @@ -8,6 +8,8 @@ {{.i18n.Tr "custom.foot.council"}} {{.i18n.Tr "custom.foot.technical_committee"}} {{.i18n.Tr "custom.foot.join"}} + {{.i18n.Tr "custom.foot.agreement"}} +