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/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/modelarts/modelarts.go b/modules/modelarts/modelarts.go index 301c4cb0e..5f8cac81c 100755 --- a/modules/modelarts/modelarts.go +++ b/modules/modelarts/modelarts.go @@ -9,6 +9,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" ) @@ -259,7 +260,7 @@ 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 } @@ -335,12 +336,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 +372,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 +556,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 +596,6 @@ 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 } 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/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index f277ff8fc..1c9471cf7 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -2683,6 +2683,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 diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 197481358..669c34cc1 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -2693,6 +2693,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前 diff --git a/public/home/home.js b/public/home/home.js index 7d5cbe4b1..8fb64b611 100644 --- a/public/home/home.js +++ b/public/home/home.js @@ -125,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; @@ -138,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 += "
"; @@ -276,7 +298,14 @@ var actionNameZH={ "15":"重新开启了合并请求", "17":"从 {repoName} 删除分支 {deleteBranchName}", "22":"建议变更", - "23":"评论了合并请求" + "23":"评论了合并请求", + "24":"上传了数据集文件", + "25":"创建了CPU/GPU类型调试任务", + "26":"创建了NPU类型调试任务", + "27":"创建了训练任务", + "28":"创建了推理任务", + "29":"创建了评测任务", + "30":"导入了新模型" }; var actionNameEN={ @@ -294,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={ 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 d26b8f08c..fdaa60517 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 jobName = ctx.Params(":jobname") task, err := models.GetCloudbrainByName(jobName) if err != nil { ctx.Data["error"] = err.Error() } - 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 @@ -1099,6 +1097,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) @@ -1201,6 +1202,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/routes/routes.go b/routers/routes/routes.go index 55b24e97a..8f678121a 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -996,7 +996,6 @@ func RegisterRoutes(m *macaron.Macaron) { m.Get("", reqRepoCloudBrainReader, repo.CloudBrainBenchMarkShow) }) m.Group("/:jobid", func() { - // m.Get("", reqRepoCloudBrainReader, repo.CloudBrainBenchMarkShow) m.Post("/stop", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.CloudBrainStop) m.Post("/del", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.BenchmarkDel) m.Get("/rate", reqRepoCloudBrainReader, repo.GetRate) 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/repo/cloudbrain/benchmark/index.tmpl b/templates/repo/cloudbrain/benchmark/index.tmpl index a08d688c6..6dcdb93bf 100644 --- a/templates/repo/cloudbrain/benchmark/index.tmpl +++ b/templates/repo/cloudbrain/benchmark/index.tmpl @@ -100,7 +100,6 @@
- {{.JobName}}
diff --git a/templates/repo/cloudbrain/benchmark/new.tmpl b/templates/repo/cloudbrain/benchmark/new.tmpl index 081e44e48..7811680d4 100755 --- a/templates/repo/cloudbrain/benchmark/new.tmpl +++ b/templates/repo/cloudbrain/benchmark/new.tmpl @@ -83,7 +83,7 @@
- +
@@ -102,11 +102,16 @@  
+ @@ -182,12 +187,17 @@ function setChildType(){ let type_id = $('#benchmark_types_id').val(); + let child_selected_id = $('#benchmark_child_types_id_hidden').val(); $.get(`${repolink}/cloudbrain/benchmark/get_child_types?benchmark_type_id=${type_id}`, (data) => { console.log(JSON.stringify(data)) const n_length = data['child_types'].length let html='' for (let i=0;i${data['child_types'][i].value}`; + if(child_selected_id == data['child_types'][i].id){ + html += ``; + }else{ + html += ``; + } } document.getElementById("benchmark_child_types_id").innerHTML=html; }) diff --git a/templates/repo/cloudbrain/benchmark/show.tmpl b/templates/repo/cloudbrain/benchmark/show.tmpl index 10453b446..cf18c4b8c 100755 --- a/templates/repo/cloudbrain/benchmark/show.tmpl +++ b/templates/repo/cloudbrain/benchmark/show.tmpl @@ -188,6 +188,7 @@ td, th { {{range $k ,$v := .version_list_task}}
+
@@ -441,7 +442,6 @@ td, th { jobName = urlArr.slice(-1)[0] }) - function loadLog(version_name){ document.getElementById("mask").style.display = "block" $.get(`/api/v1/repos/${userName}/${repoPath}/cloudbrain/${jobName}/log?version_name=${version_name}&lines=50&order=asc`, (data) => { diff --git a/templates/user/dashboard/feeds.tmpl b/templates/user/dashboard/feeds.tmpl index f3794989c..519dcda8f 100644 --- a/templates/user/dashboard/feeds.tmpl +++ b/templates/user/dashboard/feeds.tmpl @@ -69,7 +69,21 @@ {{$.i18n.Tr "action.reject_pull_request" .GetRepoLink $index .ShortRepoFullDisplayName | Str2html}} {{else if eq .GetOpType 23}} {{ $index := index .GetIssueInfos 0}} - {{$.i18n.Tr "action.comment_pull" .GetRepoLink $index .ShortRepoFullDisplayName | Str2html}} + {{$.i18n.Tr "action.comment_pull" .GetRepoLink $index .ShortRepoPath | Str2html}} + {{else if eq .GetOpType 24}} + {{$.i18n.Tr "action.upload_dataset" .GetRepoLink .Content .RefName | Str2html}} + {{else if eq .GetOpType 25}} + {{$.i18n.Tr "action.task_gpudebugjob" .GetRepoLink .RefName .RefName | Str2html}} + {{else if eq .GetOpType 26}} + {{$.i18n.Tr "action.task_npudebugjob" .GetRepoLink .Content .RefName | Str2html}} + {{else if eq .GetOpType 27}} + {{$.i18n.Tr "action.task_trainjob" .GetRepoLink .Content .RefName | Str2html}} + {{else if eq .GetOpType 28}} + {{$.i18n.Tr "action.task_inferencejob" .GetRepoLink .Content .RefName | Str2html}} + {{else if eq .GetOpType 29}} + {{$.i18n.Tr "action.task_benchmark" .GetRepoLink .RefName .RefName | Str2html}} + {{else if eq .GetOpType 30}} + {{$.i18n.Tr "action.task_createmodel" .GetRepoLink .RefName .RefName | Str2html}} {{end}}

{{if or (eq .GetOpType 5) (eq .GetOpType 18)}} @@ -101,7 +115,23 @@
- {{svg (printf "octicon-%s" (ActionIcon .GetOpType)) 32}} + {{if eq .GetOpType 24}} + + {{else if eq .GetOpType 25}} + + {{else if eq .GetOpType 26}} + + {{else if eq .GetOpType 27}} + + {{else if eq .GetOpType 28}} + + {{else if eq .GetOpType 29}} + + {{else if eq .GetOpType 30}} + + {{else}} + {{svg (printf "octicon-%s" (ActionIcon .GetOpType)) 32}} + {{end}}