Browse Source

Merge pull request 'Complete the modelarts createServeic of ai' (#293) from upmaster into master

Former-commit-id: a7599f67e2
pull/295/head
qiwang 1 year ago
parent
commit
efbac11fe8
3 changed files with 40 additions and 2 deletions
  1. +7
    -0
      internal/scheduler/schedulers/option/inferOption.go
  2. +32
    -2
      internal/storeLink/modelarts.go
  3. +1
    -0
      internal/storeLink/shuguangai.go

+ 7
- 0
internal/scheduler/schedulers/option/inferOption.go 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 {


+ 32
- 2
internal/storeLink/modelarts.go 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,7 +551,27 @@ 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
}

func (m *ModelArtsLink) CheckModelExistence(ctx context.Context, name string, mtype string) bool {


+ 1
- 0
internal/storeLink/shuguangai.go View File

@@ -883,6 +883,7 @@ 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
}



Loading…
Cancel
Save