Browse Source

动态信息增加

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.22.2.2^2
zouap 4 years ago
parent
commit
ce27bf3d25
14 changed files with 60 additions and 24 deletions
  1. +7
    -1
      models/action.go
  2. +10
    -3
      modules/cloudbrain/cloudbrain.go
  3. +8
    -7
      modules/modelarts/modelarts.go
  4. +4
    -4
      modules/notification/action/action.go
  5. +1
    -1
      modules/notification/base/notifier.go
  6. +1
    -1
      modules/notification/base/null.go
  7. +2
    -2
      modules/notification/notification.go
  8. +1
    -0
      options/locale/locale_en-US.ini
  9. +1
    -1
      options/locale/locale_zh-CN.ini
  10. +2
    -1
      routers/repo/ai_model_manage.go
  11. +1
    -1
      routers/repo/attachment.go
  12. +1
    -1
      routers/repo/cloudbrain.go
  13. +1
    -1
      services/socketwrap/clientManager.go
  14. +20
    -0
      templates/user/dashboard/feeds.tmpl

+ 7
- 1
models/action.go View File

@@ -50,7 +50,13 @@ const (
ActionRejectPullRequest // 22
ActionCommentPull // 23

ActionUploadAttachment //24
ActionUploadAttachment //24
ActionCreateDebugGPUTask //25
ActionCreateDebugNPUTask //26
ActionCreateTrainTask //27
ActionCreateInferenceTask // 28
ActionCreateBenchMarkTask //29
ActionCreateNewModelTask //30
)

// Action represents user operation type and other information to


+ 10
- 3
modules/cloudbrain/cloudbrain.go View File

@@ -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
}



+ 8
- 7
modules/modelarts/modelarts.go View File

@@ -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"
)
@@ -258,7 +259,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
}

@@ -292,12 +293,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,
@@ -328,7 +329,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
}

@@ -512,12 +513,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,
@@ -552,6 +553,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
}

+ 4
- 4
modules/notification/action/action.go View File

@@ -315,16 +315,16 @@ func (a *actionNotifier) NotifySyncDeleteRef(doer *models.User, repo *models.Rep
}
}

func (a *actionNotifier) NotifyUploadAttachment(doer *models.User, repo *models.Repository, attachment *models.Attachment) {
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: models.ActionUploadAttachment,
OpType: optype,
RepoID: repo.ID,
Repo: repo,
IsPrivate: repo.IsPrivate,
RefName: attachment.Name,
Content: attachment.UUID,
RefName: name,
Content: id,
}); err != nil {
log.Error("notifyWatchers: %v", err)
}


+ 1
- 1
modules/notification/base/notifier.go View File

@@ -54,5 +54,5 @@ type Notifier interface {
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)
NotifyOtherTask(doer *models.User, repo *models.Repository, id string, name string)
}

+ 1
- 1
modules/notification/base/null.go View File

@@ -151,6 +151,6 @@ func (*NullNotifier) NotifySyncCreateRef(doer *models.User, repo *models.Reposit
func (*NullNotifier) NotifySyncDeleteRef(doer *models.User, repo *models.Repository, refType, refFullName string) {
}

func (*NullNotifier) NotifyUploadAttachment(doer *models.User, repo *models.Repository, attachment *models.Attachment) {
func (*NullNotifier) NotifyOtherTask(doer *models.User, repo *models.Repository, id string, name string, optype models.ActionType) {

}

+ 2
- 2
modules/notification/notification.go View File

@@ -39,11 +39,11 @@ func NewContext() {
}

// NotifyUploadAttachment notifies attachment upload message to notifiers
func NotifyUploadAttachment(doer *models.User, repo *models.Repository, attachment *models.Attachment) {
func NotifyOtherTask(doer *models.User, repo *models.Repository, id string, name string, optype models.ActionType) {
log.Info("send attachment to db.")
for _, notifier := range notifiers {
log.Info("send attachment to notifiers.")
notifier.NotifyUploadAttachment(doer, repo, attachment)
notifier.NotifyOtherTask(doer, repo, id, name, optype)
}
}



+ 1
- 0
options/locale/locale_en-US.ini View File

@@ -2638,6 +2638,7 @@ mirror_sync_create = synced new reference <a href="%s/src/%s">%[2]s</a> to <a hr
mirror_sync_delete = synced and deleted reference <code>%[2]s</code> at <a href="%[1]s">%[3]s</a> from mirror
approve_pull_request = `approved <a href="%s/pulls/%s">%s#%[2]s</a>`
reject_pull_request = `suggested changes for <a href="%s/pulls/%s">%s#%[2]s</a>`
upload_dataset=`upload dataset <a href="%s/datasets?type=%s">%s#%[2]s</a>`

[tool]
ago = %s ago


+ 1
- 1
options/locale/locale_zh-CN.ini View File

@@ -2646,7 +2646,7 @@ mirror_sync_create=从镜像同步了新的引用 <a href="%s/src/%s">%[2]s</a>
mirror_sync_delete=从镜像同步并从 <a href="%[1]s">%[3]s</a> 删除了引用 <code>%[2]s</code>
approve_pull_request=`同意了 <a href="%s/pulls/%s">%s#%[2]s</a>`
reject_pull_request=`建议变更 <a href="%s/pulls/%s">%s#%[2]s</a>`
upload_dataset=`上传了数据集 <a href="%s/datasets?type=%s">%s#%[2]s</a>`
[tool]
ago=%s前
from_now=%s 之后


+ 2
- 1
routers/repo/ai_model_manage.go View File

@@ -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
}



+ 1
- 1
routers/repo/attachment.go View File

@@ -847,7 +847,7 @@ func CompleteMultipart(ctx *context.Context) {
}
dataset, _ := models.GetDatasetByID(attachment.DatasetID)
repository, _ := models.GetRepositoryByID(dataset.RepoID)
notification.NotifyUploadAttachment(ctx.User, repository, attachment)
notification.NotifyOtherTask(ctx.User, repository, fmt.Sprint(attachment.Type), attachment.Name, models.ActionUploadAttachment)

if attachment.DatasetID != 0 {
if isCanDecompress(attachment.Name) {


+ 1
- 1
routers/repo/cloudbrain.go View File

@@ -445,7 +445,7 @@ func CloudBrainStop(ctx *context.Context) {

task := ctx.Cloudbrain
for {
if task.Status == string(models.JobStopped) || task.Status == string(models.JobFailed) || task.Status == string(models.JobSucceeded){
if task.Status == string(models.JobStopped) || task.Status == string(models.JobFailed) || task.Status == string(models.JobSucceeded) {
log.Error("the job(%s) has been stopped", task.JobName, ctx.Data["msgID"])
resultCode = "-1"
errorMsg = "system error"


+ 1
- 1
services/socketwrap/clientManager.go View File

@@ -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


+ 20
- 0
templates/user/dashboard/feeds.tmpl View File

@@ -69,6 +69,26 @@
{{$.i18n.Tr "action.reject_pull_request" .GetRepoLink $index .ShortRepoPath | Str2html}}
{{else if eq .GetOpType 23}}
{{ $index := index .GetIssueInfos 0}}
{{$.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.comment_pull" .GetRepoLink $index .ShortRepoPath | Str2html}}
{{else if eq .GetOpType 26}}
{{$.i18n.Tr "action.comment_pull" .GetRepoLink $index .ShortRepoPath | Str2html}}
{{else if eq .GetOpType 27}}
{{$.i18n.Tr "action.comment_pull" .GetRepoLink $index .ShortRepoPath | Str2html}}
{{else if eq .GetOpType 28}}
{{$.i18n.Tr "action.comment_pull" .GetRepoLink $index .ShortRepoPath | Str2html}}
{{else if eq .GetOpType 29}}
{{$.i18n.Tr "action.comment_pull" .GetRepoLink $index .ShortRepoPath | Str2html}}
{{else if eq .GetOpType 30}}
{{$.i18n.Tr "action.comment_pull" .GetRepoLink $index .ShortRepoPath | Str2html}}
{{end}}
</p>


Loading…
Cancel
Save