forked from JointCloud/pcm-coordinator
存算联动调整3
This commit is contained in:
parent
c4945eaa44
commit
5fb7b0313b
|
@ -5,8 +5,10 @@ import (
|
|||
"errors"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-ac/hpcAC"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/models"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -100,6 +102,17 @@ var RESOURCESPECS = map[string]string{
|
|||
"79xSdy48yLbVLl9DqEV6tQ2J6jaHe5KO": "2*NODE, CPU:32, 8*DCU",
|
||||
}
|
||||
|
||||
var AcStatus = map[string]string{
|
||||
"statQ": "Pending",
|
||||
"statR": "Running",
|
||||
"statE": "Pending",
|
||||
"statC": "Completed",
|
||||
"statH": "Pending",
|
||||
"statS": "Pending",
|
||||
"statW": "Pending",
|
||||
"statX": "Other",
|
||||
}
|
||||
|
||||
type ResourceSpec struct {
|
||||
GAP_NNODE string
|
||||
GAP_NPROC string
|
||||
|
@ -188,16 +201,63 @@ func (s ShuguangHpc) SubmitTask(imageId string, cmd string, envs []string, param
|
|||
}
|
||||
|
||||
func (s ShuguangHpc) QueryTask(taskId string) (interface{}, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
//实时作业
|
||||
reqC := &hpcAC.JobDetailReq{
|
||||
JobId: taskId,
|
||||
}
|
||||
respC, err := s.svcCtx.ACRpc.GetJobDetail(s.ctx, reqC)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
taskRespC, err := ConvertType[hpcAC.GetJobDetailResp](respC, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
//实时作业检查是否成功
|
||||
taskResp := taskRespC.(types.GetLinkTaskResp)
|
||||
if taskResp.Task != nil {
|
||||
return taskRespC, nil
|
||||
}
|
||||
|
||||
//历史作业
|
||||
reqH := &hpcAC.HistoryJobDetailReq{
|
||||
JobId: taskId,
|
||||
JobmanagerId: strconv.Itoa(StrJobManagerID),
|
||||
}
|
||||
|
||||
respH, err := s.svcCtx.ACRpc.HistoryJobDetail(s.ctx, reqH)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
taskRespH, err := ConvertType[hpcAC.HistoryJobDetailResp](respH, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return taskRespH, nil
|
||||
}
|
||||
|
||||
func (s ShuguangHpc) QuerySpecs() (interface{}, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
var resp types.GetResourceSpecsResp
|
||||
|
||||
for k, v := range RESOURCESPECS {
|
||||
var respec types.ResourceSpecSl
|
||||
respec.SpecId = k
|
||||
respec.SpecName = v
|
||||
respec.ParticipantId = s.participant.Id
|
||||
respec.ParticipantName = s.participant.Name
|
||||
resp.ResourceSpecs = append(resp.ResourceSpecs, &respec)
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s ShuguangHpc) DeleteTask(taskId string) (interface{}, error) {
|
||||
//req := hpcAC.DeleteJobReq{}
|
||||
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
|
|
@ -209,6 +209,17 @@ func ConvertType[T any](in *T, participant *models.StorelinkCenter) (interface{}
|
|||
var resp types.SubmitLinkTaskResp
|
||||
inresp := (interface{})(in).(*hpcAC.SubmitTaskAiResp)
|
||||
|
||||
if inresp.Code == "0" {
|
||||
resp.Success = true
|
||||
resp.TaskId = inresp.Data
|
||||
} else {
|
||||
resp.Success = false
|
||||
resp.ErrorMsg = inresp.Msg
|
||||
}
|
||||
return resp, nil
|
||||
case *hpcAC.SubmitJobResp:
|
||||
var resp types.SubmitLinkTaskResp
|
||||
inresp := (interface{})(in).(*hpcAC.SubmitJobResp)
|
||||
if inresp.Code == "0" {
|
||||
resp.Success = true
|
||||
resp.TaskId = inresp.Data
|
||||
|
@ -270,6 +281,44 @@ func ConvertType[T any](in *T, participant *models.StorelinkCenter) (interface{}
|
|||
resp.Task = nil
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
case *hpcAC.GetJobDetailResp:
|
||||
var resp types.GetLinkTaskResp
|
||||
inresp := (interface{})(in).(*hpcAC.GetJobDetailResp)
|
||||
if inresp.Code == "0" {
|
||||
resp.Success = true
|
||||
var task types.TaskSl
|
||||
task.TaskId = inresp.Data.JobId
|
||||
task.TaskName = inresp.Data.JobName
|
||||
task.TaskStatus = AcStatus[inresp.Data.JobStatus]
|
||||
task.StartedAt = timeutils.StringToUnixTime(inresp.Data.JobStartTime)
|
||||
task.CompletedAt = timeutils.StringToUnixTime(inresp.Data.JobEndTime)
|
||||
resp.Task = &task
|
||||
} else {
|
||||
resp.Success = false
|
||||
resp.ErrorMsg = inresp.Msg
|
||||
resp.Task = nil
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
case *hpcAC.HistoryJobDetailResp:
|
||||
var resp types.GetLinkTaskResp
|
||||
inresp := (interface{})(in).(*hpcAC.HistoryJobDetailResp)
|
||||
if inresp.Code == "0" {
|
||||
resp.Success = true
|
||||
var task types.TaskSl
|
||||
task.TaskId = inresp.Data.JobId
|
||||
task.TaskName = inresp.Data.JobName
|
||||
task.TaskStatus = AcStatus[inresp.Data.JobState]
|
||||
task.StartedAt = timeutils.StringToUnixTime(inresp.Data.JobStartTime)
|
||||
task.CompletedAt = timeutils.StringToUnixTime(inresp.Data.JobEndTime)
|
||||
resp.Task = &task
|
||||
} else {
|
||||
resp.Success = false
|
||||
resp.ErrorMsg = inresp.Msg
|
||||
resp.Task = nil
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
case *octopus.DeleteTrainJobResp:
|
||||
var resp types.DeleteLinkTaskResp
|
||||
|
|
2
go.mod
2
go.mod
|
@ -24,7 +24,7 @@ require (
|
|||
github.com/rs/zerolog v1.28.0
|
||||
github.com/shopspring/decimal v1.3.1
|
||||
github.com/zeromicro/go-zero v1.6.0
|
||||
gitlink.org.cn/jcce-pcm/pcm-ac v0.0.0-20231207021053-376383ea3c38
|
||||
gitlink.org.cn/jcce-pcm/pcm-ac v0.0.0-20231207111119-cdecc6b118c8
|
||||
gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230904090036-24fc730ec87d
|
||||
gitlink.org.cn/jcce-pcm/pcm-participant-kubernetes v0.0.0-20231128034759-01d57082e120
|
||||
gitlink.org.cn/jcce-pcm/pcm-participant-modelarts v0.0.0-20231101085149-724c7c4cc090
|
||||
|
|
4
go.sum
4
go.sum
|
@ -997,8 +997,8 @@ github.com/yuin/gopher-lua v1.1.0/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7
|
|||
github.com/zeromicro/go-zero v1.5.1/go.mod h1:bGYm4XWsGN9GhDsO2O2BngpVoWjf3Eog2a5hUOMhlXs=
|
||||
github.com/zeromicro/go-zero v1.6.0 h1:UwSOR1lGZ2g7L0S07PM8RoneAcubtd5x//EfbuNucQ0=
|
||||
github.com/zeromicro/go-zero v1.6.0/go.mod h1:E9GCFPb0SwsTKFBcFr9UynGvXiDMmfc6fI5F15vqvAQ=
|
||||
gitlink.org.cn/jcce-pcm/pcm-ac v0.0.0-20231207021053-376383ea3c38 h1:tKVL4JcF1P+rntJd4hFg+MtVgsGmyhnisEaME8tF7J0=
|
||||
gitlink.org.cn/jcce-pcm/pcm-ac v0.0.0-20231207021053-376383ea3c38/go.mod h1:ySZHK8NpHn4gjbLoOtJbSEUDiYZVwjbnFAcG71gXPgg=
|
||||
gitlink.org.cn/jcce-pcm/pcm-ac v0.0.0-20231207111119-cdecc6b118c8 h1:J2vJNi4xlWApxpQXizyNvAbvj3qjXep18J3XJrGBGwc=
|
||||
gitlink.org.cn/jcce-pcm/pcm-ac v0.0.0-20231207111119-cdecc6b118c8/go.mod h1:ySZHK8NpHn4gjbLoOtJbSEUDiYZVwjbnFAcG71gXPgg=
|
||||
gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230904090036-24fc730ec87d h1:DHjl/rLuH2gKYtY0MKMGNQDHFT12APg25RlMUQo+tHk=
|
||||
gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230904090036-24fc730ec87d/go.mod h1:r/KLzUpupCV5jdxSfgDhc2pVjP0fBi3VhAWRttsBn30=
|
||||
gitlink.org.cn/jcce-pcm/pcm-participant-kubernetes v0.0.0-20231128034759-01d57082e120 h1:4mUD/FW+i948cpTI9faCgnIUItZW3eoA1UdPsDnzK1M=
|
||||
|
|
Loading…
Reference in New Issue