forked from JointCloud/pcm-coordinator
modelarts 增加资源规格接口
Signed-off-by: devad <cossjie@foxmail.com>
This commit is contained in:
parent
a7b9c27d37
commit
9d851b10e3
|
@ -10,11 +10,12 @@ import (
|
|||
)
|
||||
|
||||
type ModelArtsLink struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
platform string
|
||||
pageIndex int32
|
||||
pageSize int32
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
platform string
|
||||
pageIndex int32
|
||||
pageSize int32
|
||||
participant *models.ScParticipantPhyInfo
|
||||
}
|
||||
|
||||
//const (
|
||||
|
@ -141,5 +142,18 @@ func (o *ModelArtsLink) DeleteTask(taskId string) (interface{}, error) {
|
|||
}
|
||||
|
||||
func (o *ModelArtsLink) QuerySpecs() (interface{}, error) {
|
||||
return nil, nil
|
||||
// octopus查询资源规格
|
||||
req := &modelarts.TrainingJobFlavorsReq{}
|
||||
resp, err := o.svcCtx.ModelArtsRpc.GetTrainingJobFlavors(o.ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
//转换成统一返回类型
|
||||
specsResp, err := ConvertType[modelarts.TrainingJobFlavorsResp](resp, o.participant)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return specsResp, nil
|
||||
}
|
||||
|
|
|
@ -319,6 +319,27 @@ func ConvertType[T any](in *T, participant *models.ScParticipantPhyInfo) (interf
|
|||
spec.SpecId = SHUGUANGAI_CUSTOM_RESOURCE_ID
|
||||
resp.ResourceSpecs = append(resp.ResourceSpecs, &spec)
|
||||
}
|
||||
return resp, nil
|
||||
case *modelarts.TrainingJobFlavorsResp:
|
||||
var resp types.GetResourceSpecsResp
|
||||
resp.Success = true
|
||||
inresp := (interface{})(in).(*modelarts.TrainingJobFlavorsResp)
|
||||
if inresp.Flavors == nil {
|
||||
resp.Success = false
|
||||
resp.ResourceSpecs = nil
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
for _, spec := range inresp.Flavors {
|
||||
var respec types.ResourceSpecSl
|
||||
respec.SpecId = spec.FlavorId
|
||||
respec.SpecName = spec.FlavorName
|
||||
respec.ParticipantId = strconv.FormatInt(participant.Id, 10)
|
||||
respec.ParticipantName = participant.Name
|
||||
respec.SpecPrice = 0
|
||||
resp.ResourceSpecs = append(resp.ResourceSpecs, &respec)
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
default:
|
||||
return nil, errors.New("type convert fail")
|
||||
|
|
Loading…
Reference in New Issue