存算联动接口调整
Former-commit-id: 85405ae5a4a320b53b0d98ec166ab91a6a99fd54
This commit is contained in:
parent
6134a3259f
commit
c3bf32b36c
|
@ -26,14 +26,14 @@ func NewSubmitLinkTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Su
|
||||||
func (l *SubmitLinkTaskLogic) SubmitLinkTask(req *types.SubmitLinkTaskReq) (resp *types.SubmitLinkTaskResp, err error) {
|
func (l *SubmitLinkTaskLogic) SubmitLinkTask(req *types.SubmitLinkTaskReq) (resp *types.SubmitLinkTaskResp, err error) {
|
||||||
participant := storeLink.GetParticipantById(req.PartId, l.svcCtx.DbEngin)
|
participant := storeLink.GetParticipantById(req.PartId, l.svcCtx.DbEngin)
|
||||||
storelink := storeLink.NewStoreLink(l.ctx, l.svcCtx, participant)
|
storelink := storeLink.NewStoreLink(l.ctx, l.svcCtx, participant)
|
||||||
var envs []string
|
var params []string
|
||||||
if len(req.Envs) != 0 {
|
if len(req.Params) != 0 {
|
||||||
for _, v := range req.Envs {
|
for _, v := range req.Params {
|
||||||
env := v.Key + storeLink.COMMA + v.Val
|
param := v.Key + storeLink.COMMA + v.Val
|
||||||
envs = append(envs, env)
|
params = append(params, param)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
task, err := storelink.ILinkage.SubmitTask(req.ImageId, req.Cmd, envs, "")
|
task, err := storelink.ILinkage.SubmitTask(req.ImageId, req.Cmd, params, req.ResourceId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils"
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils"
|
||||||
"gitlink.org.cn/jcce-pcm/pcm-participant-octopus/octopus"
|
"gitlink.org.cn/jcce-pcm/pcm-participant-octopus/octopus"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OctopusLink struct {
|
type OctopusLink struct {
|
||||||
|
@ -19,6 +20,7 @@ const (
|
||||||
IMG_NAME_PREFIX = "oct_"
|
IMG_NAME_PREFIX = "oct_"
|
||||||
IMG_VERSION_PREFIX = "version_"
|
IMG_VERSION_PREFIX = "version_"
|
||||||
TASK_NAME_PREFIX = "trainJob_"
|
TASK_NAME_PREFIX = "trainJob_"
|
||||||
|
RESOURCE_POOL = "common-pool"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewOctopusLink(ctx context.Context, svcCtx *svc.ServiceContext, platform string) *OctopusLink {
|
func NewOctopusLink(ctx context.Context, svcCtx *svc.ServiceContext, platform string) *OctopusLink {
|
||||||
|
@ -106,14 +108,23 @@ func (o *OctopusLink) QueryImageList() (interface{}, error) {
|
||||||
return imgListResp, nil
|
return imgListResp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OctopusLink) SubmitTask(imageId string, cmd string, envs []string, resourceId string) (interface{}, error) {
|
func (o *OctopusLink) SubmitTask(imageId string, cmd string, params []string, resourceId string) (interface{}, error) {
|
||||||
// octopus提交任务
|
// octopus提交任务
|
||||||
|
var prms []*octopus.Parameters
|
||||||
|
for _, param := range params {
|
||||||
|
var p octopus.Parameters
|
||||||
|
s := strings.Split(param, COMMA)
|
||||||
|
p.Key = s[0]
|
||||||
|
p.Value = s[1]
|
||||||
|
prms = append(prms, &p)
|
||||||
|
}
|
||||||
|
|
||||||
req := &octopus.CreateTrainJobReq{
|
req := &octopus.CreateTrainJobReq{
|
||||||
Platform: o.platform,
|
Platform: o.platform,
|
||||||
Params: &octopus.CreateTrainJobParam{
|
Params: &octopus.CreateTrainJobParam{
|
||||||
ImageId: imageId,
|
ImageId: imageId,
|
||||||
Name: TASK_NAME_PREFIX + utils.RandomString(5),
|
Name: TASK_NAME_PREFIX + utils.RandomString(7),
|
||||||
ResourcePool: "common-pool",
|
ResourcePool: RESOURCE_POOL,
|
||||||
Config: []*octopus.Config{
|
Config: []*octopus.Config{
|
||||||
{
|
{
|
||||||
Command: cmd,
|
Command: cmd,
|
||||||
|
@ -121,6 +132,7 @@ func (o *OctopusLink) SubmitTask(imageId string, cmd string, envs []string, reso
|
||||||
MinFailedTaskCount: 1,
|
MinFailedTaskCount: 1,
|
||||||
MinSucceededTaskCount: 1,
|
MinSucceededTaskCount: 1,
|
||||||
TaskNumber: 1,
|
TaskNumber: 1,
|
||||||
|
Parameters: prms,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,7 +14,7 @@ type Linkage interface {
|
||||||
UploadImage(path string) (interface{}, error)
|
UploadImage(path string) (interface{}, error)
|
||||||
DeleteImage(imageId string) (interface{}, error)
|
DeleteImage(imageId string) (interface{}, error)
|
||||||
QueryImageList() (interface{}, error)
|
QueryImageList() (interface{}, error)
|
||||||
SubmitTask(imageId string, cmd string, envs []string, resourceId string) (interface{}, error)
|
SubmitTask(imageId string, cmd string, params []string, resourceId string) (interface{}, error)
|
||||||
QueryTask(taskId string) (interface{}, error)
|
QueryTask(taskId string) (interface{}, error)
|
||||||
DeleteTask(taskId string) (interface{}, error)
|
DeleteTask(taskId string) (interface{}, error)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue