fix: Complete the modelarts createServeic of ai

Former-commit-id: f31284ff45656057babe3d24252ae7c1939f3ce3
This commit is contained in:
qiwang 2024-08-27 17:48:30 +08:00
parent e58d00a980
commit 46fac6b148
3 changed files with 40 additions and 2 deletions

View File

@ -19,6 +19,13 @@ type InferOption struct {
ResourceId string
AlgorithmId string
ImageId string
//modelarts
InferType string
Specification string
Weight int32
ModelId string
InstanceCount int32
}
func (a InferOption) GetOptionType() string {

View File

@ -260,6 +260,16 @@ func (m *ModelArtsLink) UploadAlgorithmCode(ctx context.Context, resourceType st
return nil
}
func (m *ModelArtsLink) GetModelId(ctx context.Context, option *option.AiOption, ifoption *option.InferOption) error {
req := &modelarts.ListModelReq{}
specResp, err := m.modelArtsRpc.ListModels(ctx, req)
if err != nil {
return err
}
return nil
}
func (m *ModelArtsLink) GetTrainingTaskLog(ctx context.Context, taskId string, instanceNum string) (string, error) {
req := &modelartsservice.GetTrainingJobLogsPreviewReq{
Platform: m.platform,
@ -364,7 +374,7 @@ func (m *ModelArtsLink) GenerateSubmitParams(ctx context.Context, option *option
return nil
}
func (m *ModelArtsLink) generateResourceId(ctx context.Context, option *option.AiOption) error {
func (m *ModelArtsLink) generateResourceId(ctx context.Context, option *option.AiOption, ifoption *option.InferOption) error {
option.ResourceId = "modelarts.kat1.xlarge"
return nil
}
@ -541,5 +551,25 @@ func (m *ModelArtsLink) GetInferResult(ctx context.Context, url string, file mul
}
func (m *ModelArtsLink) CreateInferDeployInstance(ctx context.Context, option *option.InferOption) (string, error) {
return "", nil
configParam := &modelarts.ServiceConfig{
Specification: option.Specification,
Weight: option.Weight,
ModelId: option.ModelId,
InstanceCount: option.InstanceCount,
}
var configItems []*modelarts.ServiceConfig
configItems = append(configItems, configParam)
req := &modelarts.CreateServiceReq{
Platform: m.platform,
Config: configItems,
InferType: option.InferType,
ServiceName: option.TaskName,
}
resp, err := m.modelArtsRpc.CreateService(ctx, req)
if err != nil {
return "", err
}
return resp.ServiceId, nil
}

View File

@ -883,5 +883,6 @@ func (s *ShuguangAi) GetInferResult(ctx context.Context, url string, file multip
}
func (s *ShuguangAi) CreateInferDeployInstance(ctx context.Context, option *option.InferOption) (string, error) {
return "", nil
}