存算联动接口调整

Former-commit-id: 3c0322fe5797b3993607002cd02331abff040d06
This commit is contained in:
tzwang 2023-10-11 17:38:35 +08:00
parent a145861b5a
commit fc01760406
4 changed files with 50 additions and 12 deletions

View File

@ -2,9 +2,11 @@ package storelink
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/storeLink"
"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-participant-octopus/octopus"
"strconv"
"github.com/zeromicro/go-zero/core/logx"
)
@ -24,7 +26,41 @@ func NewGetAISpecsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAIS
}
func (l *GetAISpecsLogic) GetAISpecs(req *types.GetResourceSpecsReq) (resp *types.GetResourceSpecsResp, err error) {
// todo: add your logic here and delete this line
var res types.GetResourceSpecsResp
participants := storeLink.GetParticipants(l.svcCtx.DbEngin)
return
for _, participant := range participants {
switch participant.Type {
case storeLink.TYPE_OCTOPUS:
req := &octopus.GetResourceSpecsReq{
Platform: participant.Name,
ResourcePool: "common-pool",
}
specs, err := l.svcCtx.OctopusRpc.GetResourceSpecs(l.ctx, req)
if err != nil || !specs.Success {
continue
}
for _, spec := range specs.TrainResourceSpecs {
var respec types.ResourceSpecSl
respec.SpecId = spec.Id
respec.SpecName = spec.Name
respec.ParticipantId = strconv.FormatInt(participant.Id, 10)
respec.ParticipantName = participant.Name
respec.SpecPrice = spec.Price
res.ResourceSpecs = append(res.ResourceSpecs, respec)
}
}
}
if len(res.ResourceSpecs) == 0 {
res.Success = false
return &res, nil
}
res.Success = true
return &res, nil
}

View File

@ -106,7 +106,7 @@ func (o *OctopusLink) QueryImageList() (interface{}, error) {
return imgListResp, nil
}
func (o *OctopusLink) SubmitTask(imageId string, cmd string, envs []string) (interface{}, error) {
func (o *OctopusLink) SubmitTask(imageId string, cmd string, envs []string, resourceId string) (interface{}, error) {
// octopus提交任务
req := &octopus.CreateTrainJobReq{
Platform: o.platform,
@ -117,7 +117,7 @@ func (o *OctopusLink) SubmitTask(imageId string, cmd string, envs []string) (int
Config: []*octopus.Config{
{
Command: cmd,
ResourceSpecId: "6388d3c27f654fa5b11439a3d6098dbc",
ResourceSpecId: resourceId,
MinFailedTaskCount: 1,
MinSucceededTaskCount: 1,
TaskNumber: 1,

View File

@ -14,15 +14,17 @@ type Linkage interface {
UploadImage(path string) (interface{}, error)
DeleteImage(imageId string) (interface{}, error)
QueryImageList() (interface{}, error)
SubmitTask(imageId string, cmd string, envs []string) (interface{}, error)
SubmitTask(imageId string, cmd string, envs []string, resourceId string) (interface{}, error)
QueryTask(taskId string) (interface{}, error)
DeleteTask(taskId string) (interface{}, error)
}
const (
COMMA = ","
TYPE_OCTOPUS = "octopus"
TYPE_MODELARTS = "modelarts"
TYPE_OCTOPUS = "1"
TYPE_MODELARTS = "2"
OCTOPUS = "Octopus"
MODELARTS = "Modelarts"
)
var (
@ -32,8 +34,8 @@ var (
4: "制作失败",
}
AITYPE = map[string]string{
"1": TYPE_OCTOPUS,
"2": TYPE_MODELARTS,
"1": OCTOPUS,
"2": MODELARTS,
}
)

4
go.mod
View File

@ -1,6 +1,6 @@
module gitlink.org.cn/jcce-pcm/pcm-coordinator
go 1.20
go 1.19
require (
github.com/JCCE-nudt/zero-contrib/zrpc/registry/nacos v0.0.0-20230419021610-13bbc83fbc3c
@ -24,7 +24,7 @@ require (
gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230817103341-2459e5bfc835
gitlink.org.cn/jcce-pcm/pcm-participant-kubernetes v0.0.0-20230830120334-bf6d99c715ef
gitlink.org.cn/jcce-pcm/pcm-participant-modelarts v0.0.0-20230719015658-08a29549d86a
gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20230714030856-601935bc30e2
gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20231011071802-c6a7637b74e4
gitlink.org.cn/jcce-pcm/pcm-participant-openstack v0.0.0-20230904093908-860f0b2b4eb4
gitlink.org.cn/jcce-pcm/pcm-participant-slurm v0.0.0-20230714030125-a52fa198ddf4
gitlink.org.cn/jcce-pcm/utils v0.0.2