任务列表信息
Former-commit-id: 6800f9a6d57d810991aea43d102cace8a9768c82
This commit is contained in:
parent
4549ff388b
commit
b7eeb14f7a
|
@ -206,6 +206,14 @@ type (
|
|||
AllCardRunTime float64 `json:"allCardRunTime"`
|
||||
AllJobCount float64 `json:"allJobCount"`
|
||||
AllJobRunTime float64 `json:"allJobRunTime"`
|
||||
TrainJobs []TrainJob `json:"trainJobs"`
|
||||
}
|
||||
TrainJob {
|
||||
Name string `json:"name"`
|
||||
Status string `json:"status"`
|
||||
ServiceName string `json:"ServiceName"`
|
||||
SynergyStatus string `json:"synergyStatus"`
|
||||
Strategy int `json:"strategy"`
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"PCM/adaptor/PCM-CORE/model"
|
||||
"PCM/common/enum"
|
||||
"PCM/common/tool"
|
||||
"context"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"strings"
|
||||
|
||||
"PCM/adaptor/PCM-CORE/api/internal/svc"
|
||||
"PCM/adaptor/PCM-CORE/api/internal/types"
|
||||
|
@ -17,6 +20,21 @@ type JobTotalLogic struct {
|
|||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
type Job struct {
|
||||
TotalSize int `json:"totalSize"`
|
||||
OtJobs []OtJob `json:"otJobs"`
|
||||
}
|
||||
|
||||
type OtJob struct {
|
||||
Name string `json:"name"`
|
||||
Status string `json:"status"`
|
||||
Tasks []Task `json:"tasks"`
|
||||
}
|
||||
|
||||
type Task struct {
|
||||
CenterName []string `json:"centerName"`
|
||||
}
|
||||
|
||||
func NewJobTotalLogic(ctx context.Context, svcCtx *svc.ServiceContext) *JobTotalLogic {
|
||||
return &JobTotalLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
|
@ -26,12 +44,64 @@ func NewJobTotalLogic(ctx context.Context, svcCtx *svc.ServiceContext) *JobTotal
|
|||
}
|
||||
|
||||
func (l *JobTotalLogic) JobTotal() (resp *types.JobTotalResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
// 获取任务时间信息
|
||||
resp = &types.JobTotalResp{}
|
||||
bytes, err := tool.HttpGet("GET", "https://grampus.openi.org.cn/openapi/v1/sharescreen/computepower/alljobinfo")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
json.Unmarshal(bytes, resp)
|
||||
|
||||
// 获取其他任务信息
|
||||
jobs := &Job{}
|
||||
jobBytes, err := tool.HttpGet("GET", "https://grampus.openi.org.cn/openapi/v1/sharescreen/trainjob?pageIndex=1&pageSize=10")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
json.Unmarshal(jobBytes, jobs)
|
||||
|
||||
for _, job := range jobs.OtJobs {
|
||||
resp.TrainJobs = append(resp.TrainJobs, types.TrainJob{
|
||||
Name: job.Name,
|
||||
Status: job.Status,
|
||||
ServiceName: job.Tasks[0].CenterName[0],
|
||||
Strategy: 0,
|
||||
SynergyStatus: "未协同",
|
||||
})
|
||||
}
|
||||
|
||||
var tasks []model.Task
|
||||
tx := l.svcCtx.DbEngin.Find(&tasks)
|
||||
if tx.Error != nil {
|
||||
logx.Error(err)
|
||||
return nil, tx.Error
|
||||
}
|
||||
if len(tasks) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
for _, task := range tasks {
|
||||
tx := l.svcCtx.DbEngin.Raw("SELECT CONCAT_WS(',',GROUP_CONCAT(DISTINCT h.service_name) ,GROUP_CONCAT(DISTINCT a.service_name) ,GROUP_CONCAT(DISTINCT c.service_name))as service_name from task t left join hpc h on t.id = h.task_id left join cloud c on t.id = c.task_id left join ai a on t.id = a.task_id where t.id = ?", task.Id).Scan(&task.ServiceName)
|
||||
if tx.Error != nil {
|
||||
logx.Error(err)
|
||||
return nil, tx.Error
|
||||
}
|
||||
// 承接方转义
|
||||
if task.ServiceName != "" {
|
||||
var names []string
|
||||
servicesName := strings.Split(task.ServiceName, ",")
|
||||
for _, name := range servicesName {
|
||||
names = append(names, enum.Partner(name).String())
|
||||
}
|
||||
task.ServiceName = strings.Join(names, ",")
|
||||
}
|
||||
resp.TrainJobs = append(resp.TrainJobs, types.TrainJob{
|
||||
ServiceName: task.ServiceName,
|
||||
Name: task.Name,
|
||||
Strategy: int(task.Strategy),
|
||||
SynergyStatus: enum.SynergyStatus(task.SynergyStatus).String(),
|
||||
Status: task.Status,
|
||||
})
|
||||
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
|
|
@ -60,7 +60,6 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
|||
ModelArtsRpc: modelartsclient.NewModelArts(zrpc.MustNewClient(c.ModelArtsRpcConf)),
|
||||
CephRpc: cephclient.NewCeph(zrpc.MustNewClient(c.CephRpcConf)),
|
||||
ACRpc: hpcacclient.NewHpcAC(zrpc.MustNewClient(c.ACRpcConf)),
|
||||
//THRpc: hpcthclient.NewHpcTH(zrpc.MustNewClient(c.THRpcConf)),
|
||||
OctopusRpc: octopusclient.NewOctopus(zrpc.MustNewClient(c.OctopusRpcConf)),
|
||||
DockerClient: dockerClient,
|
||||
}
|
||||
|
|
|
@ -184,6 +184,15 @@ type JobTotalResp struct {
|
|||
AllCardRunTime float64 `json:"allCardRunTime"`
|
||||
AllJobCount float64 `json:"allJobCount"`
|
||||
AllJobRunTime float64 `json:"allJobRunTime"`
|
||||
TrainJobs []TrainJob `json:"trainJobs"`
|
||||
}
|
||||
|
||||
type TrainJob struct {
|
||||
Name string `json:"name"`
|
||||
Status string `json:"status"`
|
||||
ServiceName string `json:"ServiceName"`
|
||||
SynergyStatus string `json:"synergyStatus"`
|
||||
Strategy int `json:"strategy"`
|
||||
}
|
||||
|
||||
type TaskListResp struct {
|
||||
|
|
Loading…
Reference in New Issue