Merge remote-tracking branch 'origin/2.0' into 2.0
This commit is contained in:
commit
ce44f191c5
|
@ -65,8 +65,9 @@ func submitJob(infoList *pcmcoreclient.InfoListResp, submitJobLogic *CreateTrain
|
||||||
for index, _ := range infoList.AiInfoList {
|
for index, _ := range infoList.AiInfoList {
|
||||||
if infoList.AiInfoList[index].Status == "Saved" {
|
if infoList.AiInfoList[index].Status == "Saved" {
|
||||||
submitReq := modelarts.CreateTrainingJobReq{
|
submitReq := modelarts.CreateTrainingJobReq{
|
||||||
Kind: "job",
|
ModelArtsType: "cn-north-4.myhuawei",
|
||||||
ProjectId: "0a62ffb0d48026c12fbfc011b8d23f0b",
|
Kind: "job",
|
||||||
|
ProjectId: "0a62ffb0d48026c12fbfc011b8d23f0b",
|
||||||
Metadata: &modelarts.MetadataS{
|
Metadata: &modelarts.MetadataS{
|
||||||
Name: infoList.AiInfoList[index].Name,
|
Name: infoList.AiInfoList[index].Name,
|
||||||
WorkspaceId: "0",
|
WorkspaceId: "0",
|
||||||
|
|
|
@ -4,7 +4,7 @@ NacosConfig:
|
||||||
ServerConfigs:
|
ServerConfigs:
|
||||||
# - IpAddr: 127.0.0.1
|
# - IpAddr: 127.0.0.1
|
||||||
# Port: 8848
|
# Port: 8848
|
||||||
- IpAddr: nacos.jcce.dev
|
- IpAddr: 10.101.15.7
|
||||||
Port: 8848
|
Port: 8848
|
||||||
ClientConfig:
|
ClientConfig:
|
||||||
NamespaceId: test
|
NamespaceId: test
|
||||||
|
|
|
@ -3,10 +3,15 @@ package logic
|
||||||
import (
|
import (
|
||||||
"PCM/adaptor/PCM-HPC/PCM-AC/rpc/hpcAC"
|
"PCM/adaptor/PCM-HPC/PCM-AC/rpc/hpcAC"
|
||||||
"PCM/adaptor/PCM-HPC/PCM-AC/rpc/internal/svc"
|
"PCM/adaptor/PCM-HPC/PCM-AC/rpc/internal/svc"
|
||||||
"PCM/adaptor/PCM-HPC/PCM-AC/rpc/internal/util"
|
|
||||||
"context"
|
"context"
|
||||||
|
"github.com/bitly/go-simplejson"
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
"io"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ListHistoryJobLogic struct {
|
type ListHistoryJobLogic struct {
|
||||||
|
@ -26,31 +31,99 @@ func NewListHistoryJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Li
|
||||||
// ListHistoryJob list all history jobs
|
// ListHistoryJob list all history jobs
|
||||||
func (l *ListHistoryJobLogic) ListHistoryJob(in *hpcAC.ListHistoryJobReq) (*hpcAC.ListHistoryJobResp, error) {
|
func (l *ListHistoryJobLogic) ListHistoryJob(in *hpcAC.ListHistoryJobReq) (*hpcAC.ListHistoryJobResp, error) {
|
||||||
|
|
||||||
|
var resp hpcAC.ListHistoryJobResp
|
||||||
|
historyJobUrl := "hpc/openapi/v2/historyjobs?"
|
||||||
|
|
||||||
getTokenLogic := NewGetACTokenLogic(l.ctx, l.svcCtx)
|
getTokenLogic := NewGetACTokenLogic(l.ctx, l.svcCtx)
|
||||||
tokenResp, _ := getTokenLogic.GetACToken(&hpcAC.ACTokenReq{})
|
tokenResp, _ := getTokenLogic.GetACToken(&hpcAC.ACTokenReq{})
|
||||||
token := tokenResp.GetData().Token
|
token := tokenResp.GetData().Token
|
||||||
|
|
||||||
url := "hpc/openapi/v2/historyjobs"
|
getACClusterIdLogic := NewGetACClusterIdLogic(l.ctx, l.svcCtx)
|
||||||
resp := hpcAC.ListHistoryJobResp{}
|
clusterIdResp, _ := getACClusterIdLogic.GetACClusterId(&hpcAC.ACClusterReq{Token: token})
|
||||||
params := map[string]string{
|
clusterId := clusterIdResp.GetData().Id
|
||||||
"strClusterNameList": in.StrClusterNameList,
|
|
||||||
"startTime": in.StartTime,
|
c := http.Client{Timeout: time.Duration(3) * time.Second}
|
||||||
"endTime": in.EndTime,
|
|
||||||
"timeType": in.TimeType,
|
params := url.Values{}
|
||||||
"queue": in.Queue,
|
params.Add("strClusterIDList", strconv.FormatInt(clusterId, 10))
|
||||||
"appType": in.AppType,
|
params.Add("startTime", in.StartTime)
|
||||||
"sort": in.Sort,
|
params.Add("endTime", in.EndTime)
|
||||||
"orderBy": in.OrderBy,
|
params.Add("timeType", in.TimeType)
|
||||||
"jobId": in.JobId,
|
params.Add("start", string(in.Start))
|
||||||
"jobState": in.JobState,
|
params.Add("limit", string(in.Limit))
|
||||||
"hostName": in.HostName,
|
params.Add("isQueryByQueueTime", in.IsQueryByQueueTime)
|
||||||
"strUser": in.StrUser,
|
|
||||||
"jobName": in.JobName,
|
reqUrl, err := http.NewRequest("GET", "https://api01.hpccube.com:65106/"+historyJobUrl+params.Encode(), nil)
|
||||||
"start": strconv.Itoa(int(in.Start)),
|
|
||||||
"limit": strconv.Itoa(int(in.Limit)),
|
if err != nil {
|
||||||
"isQueryByQueueTime": in.IsQueryByQueueTime,
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
_, _ = util.Get(token, l.svcCtx.Config.ClusterUrl, url, nil, ¶ms, &resp)
|
|
||||||
|
reqUrl.Header.Add("token", token)
|
||||||
|
|
||||||
|
respUrl, err := c.Do(reqUrl)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
body, err := io.ReadAll(respUrl.Body)
|
||||||
|
|
||||||
|
jsonResult, err := simplejson.NewJson(body)
|
||||||
|
jsonData := jsonResult.Get("data")
|
||||||
|
if jsonData.Get("total").MustInt() == 0 {
|
||||||
|
resp.Code = "200"
|
||||||
|
resp.Msg = "success"
|
||||||
|
return &resp, nil
|
||||||
|
}
|
||||||
|
historyJobList := jsonResult.Get("data").Get("list")
|
||||||
|
rows, err := historyJobList.Array()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
defer func(Body io.ReadCloser) {
|
||||||
|
err := Body.Close()
|
||||||
|
if err != nil {
|
||||||
|
|
||||||
|
}
|
||||||
|
}(respUrl.Body)
|
||||||
|
|
||||||
|
var Jobs []*hpcAC.HistoryJobList
|
||||||
|
|
||||||
|
for index := range rows {
|
||||||
|
jobShuguang := historyJobList.GetIndex(index)
|
||||||
|
var job hpcAC.HistoryJobList
|
||||||
|
|
||||||
|
job.AppType = jobShuguang.Get("appType").MustString()
|
||||||
|
job.JobId = jobShuguang.Get("jobId").MustString()
|
||||||
|
job.JobName = jobShuguang.Get("jobName").MustString()
|
||||||
|
job.JobStartTime = jobShuguang.Get("jobStartTime").MustString()
|
||||||
|
job.Queue = jobShuguang.Get("queue").MustString()
|
||||||
|
job.JobState = jobShuguang.Get("jobState").MustString()
|
||||||
|
job.JobEndTime = jobShuguang.Get("jobEndTime").MustString()
|
||||||
|
job.JobExecHost = jobShuguang.Get("jobExecHost").MustString()
|
||||||
|
job.JobWalltimeUsed = jobShuguang.Get("jobWalltimeUsed").MustString()
|
||||||
|
job.UserName = jobShuguang.Get("userName").MustString()
|
||||||
|
job.JobExitStatus = int32(jobShuguang.Get("jobExitStatus").MustInt())
|
||||||
|
job.AcctTime = jobShuguang.Get("acctTime").MustString()
|
||||||
|
job.JobProcNum = int32(jobShuguang.Get("jobProcNum").MustInt())
|
||||||
|
job.Nodect = int32(jobShuguang.Get("nodect").MustInt())
|
||||||
|
job.Workdir = jobShuguang.Get("workdir").MustString()
|
||||||
|
|
||||||
|
startTime, err := time.Parse(l.svcCtx.Config.ShuguangConf.Layout, jobShuguang.Get("jobStartTime").MustString())
|
||||||
|
if err == nil {
|
||||||
|
job.JobStartTime = startTime.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
Jobs = append(Jobs, &job)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if jsonResult.Get("code").MustInt() == 0 {
|
||||||
|
resp.Code = "200"
|
||||||
|
}
|
||||||
|
resp.Msg = jsonResult.Get("msg").MustString()
|
||||||
|
resp.Data.List = Jobs
|
||||||
|
|
||||||
return &resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,10 +66,12 @@ func submitJob(infoList *pcmcoreclient.InfoListResp, submitJobLogic *SubmitJobLo
|
||||||
for index, _ := range infoList.HpcInfoList {
|
for index, _ := range infoList.HpcInfoList {
|
||||||
if infoList.HpcInfoList[index].Status == "Saved" {
|
if infoList.HpcInfoList[index].Status == "Saved" {
|
||||||
submitReq := hpcTH.SubmitJobReq{
|
submitReq := hpcTH.SubmitJobReq{
|
||||||
Account: infoList.HpcInfoList[index].Account,
|
Account: infoList.HpcInfoList[index].Account,
|
||||||
Name: infoList.HpcInfoList[index].Name,
|
Name: infoList.HpcInfoList[index].Name,
|
||||||
Script: infoList.HpcInfoList[index].CmdScript,
|
WorkDir: "/root",
|
||||||
UserId: 123,
|
Script: infoList.HpcInfoList[index].CmdScript,
|
||||||
|
UserId: 0,
|
||||||
|
MinNodes: 1,
|
||||||
}
|
}
|
||||||
jobResult, _ := submitJobLogic.SubmitJob(&submitReq)
|
jobResult, _ := submitJobLogic.SubmitJob(&submitReq)
|
||||||
// 任务提交成功
|
// 任务提交成功
|
||||||
|
|
|
@ -13,4 +13,5 @@ spec:
|
||||||
protocol: TCP
|
protocol: TCP
|
||||||
port: 2001
|
port: 2001
|
||||||
targetPort: 2001
|
targetPort: 2001
|
||||||
type: ClusterIP
|
nodePort: 31617
|
||||||
|
type: NodePort
|
Loading…
Reference in New Issue