Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/1530 Reviewed-by: lewis <747342561@qq.com>pull/1533/head
@@ -49,6 +49,14 @@ const ( | |||||
ActionApprovePullRequest // 21 | ActionApprovePullRequest // 21 | ||||
ActionRejectPullRequest // 22 | ActionRejectPullRequest // 22 | ||||
ActionCommentPull // 23 | 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 | // Action represents user operation type and other information to | ||||
@@ -1,16 +1,17 @@ | |||||
package cloudbrain | package cloudbrain | ||||
import ( | import ( | ||||
"code.gitea.io/gitea/modules/storage" | |||||
"encoding/json" | "encoding/json" | ||||
"errors" | "errors" | ||||
"strconv" | "strconv" | ||||
"code.gitea.io/gitea/modules/setting" | |||||
"code.gitea.io/gitea/modules/storage" | |||||
"code.gitea.io/gitea/models" | "code.gitea.io/gitea/models" | ||||
"code.gitea.io/gitea/modules/context" | "code.gitea.io/gitea/modules/context" | ||||
"code.gitea.io/gitea/modules/log" | "code.gitea.io/gitea/modules/log" | ||||
"code.gitea.io/gitea/modules/notification" | |||||
"code.gitea.io/gitea/modules/setting" | |||||
) | ) | ||||
const ( | const ( | ||||
@@ -221,13 +222,19 @@ func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, | |||||
ComputeResource: models.GPUResource, | ComputeResource: models.GPUResource, | ||||
BenchmarkTypeID: benchmarkTypeID, | BenchmarkTypeID: benchmarkTypeID, | ||||
BenchmarkChildTypeID: benchmarkChildTypeID, | BenchmarkChildTypeID: benchmarkChildTypeID, | ||||
Description: description, | |||||
Description: description, | |||||
}) | }) | ||||
if err != nil { | if err != nil { | ||||
return err | 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 | return nil | ||||
} | } | ||||
@@ -9,6 +9,7 @@ import ( | |||||
"code.gitea.io/gitea/models" | "code.gitea.io/gitea/models" | ||||
"code.gitea.io/gitea/modules/context" | "code.gitea.io/gitea/modules/context" | ||||
"code.gitea.io/gitea/modules/log" | "code.gitea.io/gitea/modules/log" | ||||
"code.gitea.io/gitea/modules/notification" | |||||
"code.gitea.io/gitea/modules/setting" | "code.gitea.io/gitea/modules/setting" | ||||
"code.gitea.io/gitea/modules/storage" | "code.gitea.io/gitea/modules/storage" | ||||
) | ) | ||||
@@ -259,7 +260,7 @@ func GenerateTask(ctx *context.Context, jobName, uuid, description, flavor strin | |||||
if err != nil { | if err != nil { | ||||
return err | return err | ||||
} | } | ||||
notification.NotifyOtherTask(ctx.User, ctx.Repo.Repository, jobResult.ID, jobName, models.ActionCreateDebugNPUTask) | |||||
return nil | 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()) | log.Error("GetAttachmentByUUID(%s) failed:%v", strconv.FormatInt(jobResult.JobID, 10), err.Error()) | ||||
return err | return err | ||||
} | } | ||||
jobId := strconv.FormatInt(jobResult.JobID, 10) | |||||
err = models.CreateCloudbrain(&models.Cloudbrain{ | err = models.CreateCloudbrain(&models.Cloudbrain{ | ||||
Status: TransTrainJobStatus(jobResult.Status), | Status: TransTrainJobStatus(jobResult.Status), | ||||
UserID: ctx.User.ID, | UserID: ctx.User.ID, | ||||
RepoID: ctx.Repo.Repository.ID, | RepoID: ctx.Repo.Repository.ID, | ||||
JobID: strconv.FormatInt(jobResult.JobID, 10), | |||||
JobID: jobId, | |||||
JobName: req.JobName, | JobName: req.JobName, | ||||
JobType: string(models.JobTypeTrain), | JobType: string(models.JobTypeTrain), | ||||
Type: models.TypeCloudBrainTwo, | 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()) | log.Error("CreateCloudbrain(%s) failed:%v", req.JobName, err.Error()) | ||||
return err | return err | ||||
} | } | ||||
notification.NotifyOtherTask(ctx.User, ctx.Repo.Repository, jobId, req.JobName, models.ActionCreateTrainTask) | |||||
return nil | 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()) | log.Error("GetAttachmentByUUID(%s) failed:%v", strconv.FormatInt(jobResult.JobID, 10), err.Error()) | ||||
return err | return err | ||||
} | } | ||||
jobID := strconv.FormatInt(jobResult.JobID, 10) | |||||
err = models.CreateCloudbrain(&models.Cloudbrain{ | err = models.CreateCloudbrain(&models.Cloudbrain{ | ||||
Status: TransTrainJobStatus(jobResult.Status), | Status: TransTrainJobStatus(jobResult.Status), | ||||
UserID: ctx.User.ID, | UserID: ctx.User.ID, | ||||
RepoID: ctx.Repo.Repository.ID, | RepoID: ctx.Repo.Repository.ID, | ||||
JobID: strconv.FormatInt(jobResult.JobID, 10), | |||||
JobID: jobID, | |||||
JobName: req.JobName, | JobName: req.JobName, | ||||
JobType: string(models.JobTypeInference), | JobType: string(models.JobTypeInference), | ||||
Type: models.TypeCloudBrainTwo, | 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()) | log.Error("CreateCloudbrain(%s) failed:%v", req.JobName, err.Error()) | ||||
return err | return err | ||||
} | } | ||||
notification.NotifyOtherTask(ctx.User, ctx.Repo.Repository, jobID, req.JobName, models.ActionCreateInferenceTask) | |||||
return nil | return nil | ||||
} | } |
@@ -330,3 +330,18 @@ func (a *actionNotifier) NotifySyncDeleteRef(doer *models.User, repo *models.Rep | |||||
log.Error("notifyWatchers: %v", err) | 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) | |||||
} | |||||
} |
@@ -54,4 +54,6 @@ type Notifier interface { | |||||
NotifySyncPushCommits(pusher *models.User, repo *models.Repository, refName, oldCommitID, newCommitID string, commits *repository.PushCommits) | NotifySyncPushCommits(pusher *models.User, repo *models.Repository, refName, oldCommitID, newCommitID string, commits *repository.PushCommits) | ||||
NotifySyncCreateRef(doer *models.User, repo *models.Repository, refType, refFullName string) | NotifySyncCreateRef(doer *models.User, repo *models.Repository, refType, refFullName string) | ||||
NotifySyncDeleteRef(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) | |||||
} | } |
@@ -154,3 +154,7 @@ func (*NullNotifier) NotifySyncCreateRef(doer *models.User, repo *models.Reposit | |||||
// NotifySyncDeleteRef places a place holder function | // NotifySyncDeleteRef places a place holder function | ||||
func (*NullNotifier) NotifySyncDeleteRef(doer *models.User, repo *models.Repository, refType, refFullName string) { | 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) { | |||||
} |
@@ -37,6 +37,13 @@ func NewContext() { | |||||
RegisterNotifier(action.NewNotifier()) | 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 | // NotifyCreateIssueComment notifies issue comment related message to notifiers | ||||
func NotifyCreateIssueComment(doer *models.User, repo *models.Repository, | func NotifyCreateIssueComment(doer *models.User, repo *models.Repository, | ||||
issue *models.Issue, comment *models.Comment) { | issue *models.Issue, comment *models.Comment) { | ||||
@@ -2683,6 +2683,13 @@ 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 | 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>` | 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>` | 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</a>` | |||||
task_gpudebugjob=`created CPU/GPU type debugging task<a href="%s/cloudbrain/%s">%s</a>` | |||||
task_npudebugjob=`created NPU type debugging task <a href="%s/modelarts/notebook/%s">%s</a>` | |||||
task_trainjob=`created training task<a href="%s/modelarts/train-job/%s">%s</a>` | |||||
task_inferencejob=`created reasoning task <a href="%s/modelarts/inference-job/%s">%s</a>` | |||||
task_benchmark=`created profiling task <a href="%s/cloudbrain/benchmark/%s">%s</a>` | |||||
task_createmodel=`created new model <a href="%s/modelmanage/show_model_info?name=%s">%s</a>` | |||||
[tool] | [tool] | ||||
ago = %s ago | ago = %s ago | ||||
@@ -2693,6 +2693,13 @@ 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> | 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>` | approve_pull_request=`同意了 <a href="%s/pulls/%s">%s#%[2]s</a>` | ||||
reject_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</a>` | |||||
task_gpudebugjob=`创建了CPU/GPU类型调试任务 <a href="%s/cloudbrain/%s">%s</a>` | |||||
task_npudebugjob=`创建了NPU类型调试任务 <a href="%s/modelarts/notebook/%s">%s</a>` | |||||
task_trainjob=`创建了训练任务 <a href="%s/modelarts/train-job/%s">%s</a>` | |||||
task_inferencejob=`创建了推理任务 <a href="%s/modelarts/inference-job/%s">%s</a>` | |||||
task_benchmark=`创建了评测任务 <a href="%s/cloudbrain/benchmark/%s">%s</a>` | |||||
task_createmodel=`导入了新模型 <a href="%s/modelmanage/show_model_info?name=%s">%s</a>` | |||||
[tool] | [tool] | ||||
ago=%s前 | ago=%s前 | ||||
@@ -125,12 +125,15 @@ socket.onmessage = function (e) { | |||||
else if(record.OpType == "2"){ | else if(record.OpType == "2"){ | ||||
actionName = actionName.replace("{oldRepoName}",record.Content); | actionName = actionName.replace("{oldRepoName}",record.Content); | ||||
html += recordPrefix + actionName; | html += recordPrefix + actionName; | ||||
html += " <a href=\"" + getRepoLink(record) + "\" rel=\"nofollow\">" + getRepotext(record) + "</a>" | |||||
html += " <a href=\"" + getRepoLink(record) + "\" rel=\"nofollow\">" + getRepoLink(record) + "</a>" | |||||
} | |||||
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 += " <a href=\"" + getTaskLink(record) + "\" rel=\"nofollow\">" + record.RefName + "</a>" | |||||
} | } | ||||
else{ | else{ | ||||
continue; | continue; | ||||
} | } | ||||
if(record.Repo != null){ | if(record.Repo != null){ | ||||
var time = getTime(record.CreatedUnix,currentTime); | var time = getTime(record.CreatedUnix,currentTime); | ||||
html += " " + time; | html += " " + time; | ||||
@@ -138,13 +141,32 @@ socket.onmessage = function (e) { | |||||
html += "</div>"; | html += "</div>"; | ||||
html += "</div>"; | html += "</div>"; | ||||
} | } | ||||
} | } | ||||
output.innerHTML = html; | output.innerHTML = html; | ||||
swiperNewMessage.updateSlides(); | swiperNewMessage.updateSlides(); | ||||
swiperNewMessage.updateProgress(); | 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){ | function getMsg(record){ | ||||
var html =""; | var html =""; | ||||
html += "<div class=\"swiper-slide item\">"; | html += "<div class=\"swiper-slide item\">"; | ||||
@@ -276,7 +298,14 @@ var actionNameZH={ | |||||
"15":"重新开启了合并请求", | "15":"重新开启了合并请求", | ||||
"17":"从 {repoName} 删除分支 {deleteBranchName}", | "17":"从 {repoName} 删除分支 {deleteBranchName}", | ||||
"22":"建议变更", | "22":"建议变更", | ||||
"23":"评论了合并请求" | |||||
"23":"评论了合并请求", | |||||
"24":"上传了数据集文件", | |||||
"25":"创建了CPU/GPU类型调试任务", | |||||
"26":"创建了NPU类型调试任务", | |||||
"27":"创建了训练任务", | |||||
"28":"创建了推理任务", | |||||
"29":"创建了评测任务", | |||||
"30":"导入了新模型" | |||||
}; | }; | ||||
var actionNameEN={ | var actionNameEN={ | ||||
@@ -294,7 +323,14 @@ var actionNameEN={ | |||||
"15":" reopened pull request", | "15":" reopened pull request", | ||||
"17":" deleted branch {deleteBranchName} from {repoName}", | "17":" deleted branch {deleteBranchName} from {repoName}", | ||||
"22":" proposed changes", | "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={ | var repoAndOrgZH={ | ||||
@@ -12,6 +12,7 @@ import ( | |||||
"code.gitea.io/gitea/models" | "code.gitea.io/gitea/models" | ||||
"code.gitea.io/gitea/modules/context" | "code.gitea.io/gitea/modules/context" | ||||
"code.gitea.io/gitea/modules/log" | "code.gitea.io/gitea/modules/log" | ||||
"code.gitea.io/gitea/modules/notification" | |||||
"code.gitea.io/gitea/modules/setting" | "code.gitea.io/gitea/modules/setting" | ||||
"code.gitea.io/gitea/modules/storage" | "code.gitea.io/gitea/modules/storage" | ||||
uuid "github.com/satori/go.uuid" | 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) | models.UpdateRepositoryUnits(ctx.Repo.Repository, units, deleteUnitTypes) | ||||
log.Info("save model end.") | log.Info("save model end.") | ||||
notification.NotifyOtherTask(ctx.User, ctx.Repo.Repository, id, name, models.ActionCreateNewModelTask) | |||||
return nil | return nil | ||||
} | } | ||||
@@ -20,11 +20,11 @@ import ( | |||||
"code.gitea.io/gitea/modules/labelmsg" | "code.gitea.io/gitea/modules/labelmsg" | ||||
"code.gitea.io/gitea/modules/log" | "code.gitea.io/gitea/modules/log" | ||||
"code.gitea.io/gitea/modules/minio_ext" | "code.gitea.io/gitea/modules/minio_ext" | ||||
"code.gitea.io/gitea/modules/notification" | |||||
"code.gitea.io/gitea/modules/setting" | "code.gitea.io/gitea/modules/setting" | ||||
"code.gitea.io/gitea/modules/storage" | "code.gitea.io/gitea/modules/storage" | ||||
"code.gitea.io/gitea/modules/upload" | "code.gitea.io/gitea/modules/upload" | ||||
"code.gitea.io/gitea/modules/worker" | "code.gitea.io/gitea/modules/worker" | ||||
gouuid "github.com/satori/go.uuid" | gouuid "github.com/satori/go.uuid" | ||||
) | ) | ||||
@@ -845,6 +845,9 @@ func CompleteMultipart(ctx *context.Context) { | |||||
ctx.Error(500, fmt.Sprintf("InsertAttachment: %v", err)) | ctx.Error(500, fmt.Sprintf("InsertAttachment: %v", err)) | ||||
return | 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 attachment.DatasetID != 0 { | ||||
if isCanDecompress(attachment.Name) { | if isCanDecompress(attachment.Name) { | ||||
@@ -865,7 +868,6 @@ func CompleteMultipart(ctx *context.Context) { | |||||
labelmsg.SendDecompressAttachToLabelOBS(string(attachjson)) | labelmsg.SendDecompressAttachToLabelOBS(string(attachjson)) | ||||
} | } | ||||
} else { | } else { | ||||
dataset, _ := models.GetDatasetByID(attachment.DatasetID) | |||||
var labelMap map[string]string | var labelMap map[string]string | ||||
labelMap = make(map[string]string) | labelMap = make(map[string]string) | ||||
labelMap["UUID"] = uuid | labelMap["UUID"] = uuid | ||||
@@ -350,18 +350,15 @@ func CloudBrainShow(ctx *context.Context) { | |||||
func cloudBrainShow(ctx *context.Context, tpName base.TplName) { | func cloudBrainShow(ctx *context.Context, tpName base.TplName) { | ||||
ctx.Data["PageIsCloudBrain"] = true | ctx.Data["PageIsCloudBrain"] = true | ||||
var jobName = ctx.Params(":jobname") | var jobName = ctx.Params(":jobname") | ||||
task, err := models.GetCloudbrainByName(jobName) | task, err := models.GetCloudbrainByName(jobName) | ||||
if err != nil { | if err != nil { | ||||
ctx.Data["error"] = err.Error() | ctx.Data["error"] = err.Error() | ||||
} | } | ||||
result, err := cloudbrain.GetJob(task.JobID) | result, err := cloudbrain.GetJob(task.JobID) | ||||
if err != nil { | if err != nil { | ||||
ctx.Data["error"] = err.Error() | ctx.Data["error"] = err.Error() | ||||
} | } | ||||
if result != nil { | if result != nil { | ||||
jobRes, _ := models.ConvertToJobResultPayload(result.Payload) | jobRes, _ := models.ConvertToJobResultPayload(result.Payload) | ||||
jobRes.Resource.Memory = strings.ReplaceAll(jobRes.Resource.Memory, "Mi", "MB") | 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 | ctx.Data["resource_spec"] = spec | ||||
taskRoles := jobRes.TaskRoles | taskRoles := jobRes.TaskRoles | ||||
if jobRes.JobStatus.State != string(models.JobFailed) { | if jobRes.JobStatus.State != string(models.JobFailed) { | ||||
taskRes, _ := models.ConvertToTaskPod(taskRoles[cloudbrain.SubTaskName].(map[string]interface{})) | taskRes, _ := models.ConvertToTaskPod(taskRoles[cloudbrain.SubTaskName].(map[string]interface{})) | ||||
ctx.Data["taskRes"] = taskRes | ctx.Data["taskRes"] = taskRes | ||||
task.Status = taskRes.TaskStatuses[0].State | task.Status = taskRes.TaskStatuses[0].State | ||||
@@ -1099,6 +1097,9 @@ func GetChildTypes(ctx *context.Context) { | |||||
} | } | ||||
func CloudBrainBenchmarkNew(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) | err := cloudBrainNewDataPrepare(ctx) | ||||
if err != nil { | if err != nil { | ||||
ctx.ServerError("get new cloudbrain info failed", err) | ctx.ServerError("get new cloudbrain info failed", err) | ||||
@@ -1201,6 +1202,9 @@ func CloudBrainBenchmarkCreate(ctx *context.Context, form auth.CreateCloudBrainF | |||||
benchmarkTypeID := form.BenchmarkTypeID | benchmarkTypeID := form.BenchmarkTypeID | ||||
benchmarkChildTypeID := form.BenchmarkChildTypeID | benchmarkChildTypeID := form.BenchmarkChildTypeID | ||||
ctx.Data["description"] = form.Description | |||||
ctx.Data["benchmarkTypeID"] = benchmarkTypeID | |||||
ctx.Data["benchmark_child_types_id_hidden"] = benchmarkChildTypeID | |||||
if !jobNamePattern.MatchString(jobName) { | if !jobNamePattern.MatchString(jobName) { | ||||
cloudBrainNewDataPrepare(ctx) | cloudBrainNewDataPrepare(ctx) | ||||
ctx.RenderWithErr(ctx.Tr("repo.cloudbrain_jobname_err"), tplCloudBrainBenchmarkNew, &form) | ctx.RenderWithErr(ctx.Tr("repo.cloudbrain_jobname_err"), tplCloudBrainBenchmarkNew, &form) | ||||
@@ -996,7 +996,6 @@ func RegisterRoutes(m *macaron.Macaron) { | |||||
m.Get("", reqRepoCloudBrainReader, repo.CloudBrainBenchMarkShow) | m.Get("", reqRepoCloudBrainReader, repo.CloudBrainBenchMarkShow) | ||||
}) | }) | ||||
m.Group("/:jobid", func() { | m.Group("/:jobid", func() { | ||||
// m.Get("", reqRepoCloudBrainReader, repo.CloudBrainBenchMarkShow) | |||||
m.Post("/stop", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.CloudBrainStop) | m.Post("/stop", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.CloudBrainStop) | ||||
m.Post("/del", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.BenchmarkDel) | m.Post("/del", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.BenchmarkDel) | ||||
m.Get("/rate", reqRepoCloudBrainReader, repo.GetRate) | m.Get("/rate", reqRepoCloudBrainReader, repo.GetRate) | ||||
@@ -10,7 +10,7 @@ import ( | |||||
"github.com/elliotchance/orderedmap" | "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 { | type ClientsManager struct { | ||||
Clients *orderedmap.OrderedMap | Clients *orderedmap.OrderedMap | ||||
@@ -100,7 +100,6 @@ | |||||
<!-- 任务名 --> | <!-- 任务名 --> | ||||
<div class="three wide column padding0"> | <div class="three wide column padding0"> | ||||
<a class="title" href="{{$.Link}}/{{.JobName}}" title="{{.JobName}}" style="font-size: 14px;"> | <a class="title" href="{{$.Link}}/{{.JobName}}" title="{{.JobName}}" style="font-size: 14px;"> | ||||
<span class="fitted" style="width: 90%;vertical-align: middle;">{{.JobName}}</span> | <span class="fitted" style="width: 90%;vertical-align: middle;">{{.JobName}}</span> | ||||
</a> | </a> | ||||
</div> | </div> | ||||
@@ -83,7 +83,7 @@ | |||||
</div> | </div> | ||||
<div class="unite min_title inline field"> | <div class="unite min_title inline field"> | ||||
<label style="font-weight: normal;" for="description">{{.i18n.Tr "repo.modelarts.train_job.description"}} </label> | <label style="font-weight: normal;" for="description">{{.i18n.Tr "repo.modelarts.train_job.description"}} </label> | ||||
<textarea style="width: 80%;" id="description" name="description" rows="3" maxlength="254" placeholder={{.i18n.Tr "repo.modelarts.train_job.new_place"}} onchange="this.value=this.value.substring(0, 255)" onkeydown="this.value=this.value.substring(0, 255)" onkeyup="this.value=this.value.substring(0, 255)"></textarea> | |||||
<textarea style="width: 80%;" id="description" name="description" rows="3" maxlength="254" placeholder={{.i18n.Tr "repo.modelarts.train_job.new_place"}} onchange="this.value=this.value.substring(0, 255)" onkeydown="this.value=this.value.substring(0, 255)" onkeyup="this.value=this.value.substring(0, 255)">{{.description}}</textarea> | |||||
</div> | </div> | ||||
<div class="required unite min_title inline field"> | <div class="required unite min_title inline field"> | ||||
@@ -102,11 +102,16 @@ | |||||
<span> </span> | <span> </span> | ||||
<select class="ui fluid selection search dropdown" id="benchmark_types_id" name="benchmark_types_id" > | <select class="ui fluid selection search dropdown" id="benchmark_types_id" name="benchmark_types_id" > | ||||
{{range .benchmark_types}} | {{range .benchmark_types}} | ||||
<option value="{{.Id}}">{{.First}}</option> | |||||
{{if eq .Id $.benchmarkTypeID}} | |||||
<option value="{{.Id}}" selected="true">{{.First}}</option> | |||||
{{else}} | |||||
<option value="{{.Id}}">{{.First}}</option> | |||||
{{end}} | |||||
{{end}} | {{end}} | ||||
</select> | </select> | ||||
</div> | </div> | ||||
<div class="eight wide field" id="engine_name"> | <div class="eight wide field" id="engine_name"> | ||||
<input type="hidden" id="benchmark_child_types_id_hidden" name="benchmark_child_types_id_hidden" value="{{.benchmark_child_types_id_hidden}}"> | |||||
<label style="font-weight: normal;white-space: nowrap;">{{.i18n.Tr "repo.cloudbrain.benchmark.evaluate_child_type"}}</label> | <label style="font-weight: normal;white-space: nowrap;">{{.i18n.Tr "repo.cloudbrain.benchmark.evaluate_child_type"}}</label> | ||||
<select class="ui fluid selection dropdown nowrap" id="benchmark_child_types_id" style='width: 100%;' name="benchmark_child_types_id"> | <select class="ui fluid selection dropdown nowrap" id="benchmark_child_types_id" style='width: 100%;' name="benchmark_child_types_id"> | ||||
</select> | </select> | ||||
@@ -182,12 +187,17 @@ | |||||
function setChildType(){ | function setChildType(){ | ||||
let type_id = $('#benchmark_types_id').val(); | 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) => { | $.get(`${repolink}/cloudbrain/benchmark/get_child_types?benchmark_type_id=${type_id}`, (data) => { | ||||
console.log(JSON.stringify(data)) | console.log(JSON.stringify(data)) | ||||
const n_length = data['child_types'].length | const n_length = data['child_types'].length | ||||
let html='' | let html='' | ||||
for (let i=0;i<n_length;i++){ | for (let i=0;i<n_length;i++){ | ||||
html += `<option value="${data['child_types'][i].id}">${data['child_types'][i].value}</option>`; | |||||
if(child_selected_id == data['child_types'][i].id){ | |||||
html += `<option value="${data['child_types'][i].id}" selected="true">${data['child_types'][i].value}</option>`; | |||||
}else{ | |||||
html += `<option value="${data['child_types'][i].id}">${data['child_types'][i].value}</option>`; | |||||
} | |||||
} | } | ||||
document.getElementById("benchmark_child_types_id").innerHTML=html; | document.getElementById("benchmark_child_types_id").innerHTML=html; | ||||
}) | }) | ||||
@@ -188,6 +188,7 @@ td, th { | |||||
</h4> | </h4> | ||||
{{range $k ,$v := .version_list_task}} | {{range $k ,$v := .version_list_task}} | ||||
<div class="ui accordion border-according" id="accordion{{.VersionName}}" data-repopath="{{$.RepoRelPath}}" data-jobid="{{.JobID}}" data-version="{{.VersionName}}"> | <div class="ui accordion border-according" id="accordion{{.VersionName}}" data-repopath="{{$.RepoRelPath}}" data-jobid="{{.JobID}}" data-version="{{.VersionName}}"> | ||||
<input type="hidden" id="jobId_input" name="jobId_input" value="{{.JobID}}"> | |||||
<div class="{{if eq $k 0}}active{{end}} title padding0"> | <div class="{{if eq $k 0}}active{{end}} title padding0"> | ||||
<div class="according-panel-heading"> | <div class="according-panel-heading"> | ||||
<div class="accordion-panel-title"> | <div class="accordion-panel-title"> | ||||
@@ -441,7 +442,6 @@ td, th { | |||||
jobName = urlArr.slice(-1)[0] | jobName = urlArr.slice(-1)[0] | ||||
}) | }) | ||||
function loadLog(version_name){ | function loadLog(version_name){ | ||||
document.getElementById("mask").style.display = "block" | document.getElementById("mask").style.display = "block" | ||||
$.get(`/api/v1/repos/${userName}/${repoPath}/cloudbrain/${jobName}/log?version_name=${version_name}&lines=50&order=asc`, (data) => { | $.get(`/api/v1/repos/${userName}/${repoPath}/cloudbrain/${jobName}/log?version_name=${version_name}&lines=50&order=asc`, (data) => { | ||||
@@ -69,7 +69,21 @@ | |||||
{{$.i18n.Tr "action.reject_pull_request" .GetRepoLink $index .ShortRepoFullDisplayName | Str2html}} | {{$.i18n.Tr "action.reject_pull_request" .GetRepoLink $index .ShortRepoFullDisplayName | Str2html}} | ||||
{{else if eq .GetOpType 23}} | {{else if eq .GetOpType 23}} | ||||
{{ $index := index .GetIssueInfos 0}} | {{ $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}} | {{end}} | ||||
</p> | </p> | ||||
{{if or (eq .GetOpType 5) (eq .GetOpType 18)}} | {{if or (eq .GetOpType 5) (eq .GetOpType 18)}} | ||||
@@ -101,7 +115,23 @@ | |||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="ui two wide right aligned column"> | <div class="ui two wide right aligned column"> | ||||
<span class="text grey">{{svg (printf "octicon-%s" (ActionIcon .GetOpType)) 32}}</span> | |||||
{{if eq .GetOpType 24}} | |||||
<span class="text grey"><i class="ri-uninstall-line icon big"></i></span> | |||||
{{else if eq .GetOpType 25}} | |||||
<span class="text grey"><i class="ri-voice-recognition-line icon big"></i></span> | |||||
{{else if eq .GetOpType 26}} | |||||
<span class="text grey"><i class="ri-voice-recognition-line icon big"></i></span> | |||||
{{else if eq .GetOpType 27}} | |||||
<span class="text grey"><i class="ri-character-recognition-line icon big"></i></span> | |||||
{{else if eq .GetOpType 28}} | |||||
<span class="text grey"><i class="ri-haze-2-line icon big"></i></span> | |||||
{{else if eq .GetOpType 29}} | |||||
<span class="text grey"><i class="ri-vip-crown-line icon big"></i></span> | |||||
{{else if eq .GetOpType 30}} | |||||
<span class="text grey"><i class="ri-picture-in-picture-exit-line icon big"></i></span> | |||||
{{else}} | |||||
<span class="text grey">{{svg (printf "octicon-%s" (ActionIcon .GetOpType)) 32}}</span> | |||||
{{end}} | |||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="ui divider"></div> | <div class="ui divider"></div> | ||||