Merge pull request 'Complete the modelarts createServeic of ai' (#295) from qiwang/pcm-coordinator:upmaster into master
Former-commit-id: 6ad8cc3a437d553f11b7746bd3ba84c1ee406676
This commit is contained in:
commit
b2631704e3
|
@ -261,13 +261,25 @@ func (m *ModelArtsLink) UploadAlgorithmCode(ctx context.Context, resourceType st
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ModelArtsLink) GetModelId(ctx context.Context, option *option.AiOption, ifoption *option.InferOption) error {
|
func (m *ModelArtsLink) GetModelId(ctx context.Context, option *option.AiOption, ifoption *option.InferOption) error {
|
||||||
req := &modelarts.ListModelReq{}
|
req := &modelarts.ListModelReq{
|
||||||
specResp, err := m.modelArtsRpc.ListModels(ctx, req)
|
Platform: m.platform,
|
||||||
|
Limit: int64(m.pageIndex),
|
||||||
|
Offset: int64(m.pageSize),
|
||||||
|
ModelName: option.ModelName,
|
||||||
|
//ModelType: option.ModelType,
|
||||||
|
}
|
||||||
|
ListResp, err := m.modelArtsRpc.ListModels(ctx, req)
|
||||||
|
for _, Models := range ListResp.Models {
|
||||||
|
if Models.ModelName == option.ModelName {
|
||||||
|
ifoption.ModelId = Models.ModelId
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return errors.New("failed to set ModelId")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ModelArtsLink) GetTrainingTaskLog(ctx context.Context, taskId string, instanceNum string) (string, error) {
|
func (m *ModelArtsLink) GetTrainingTaskLog(ctx context.Context, taskId string, instanceNum string) (string, error) {
|
||||||
|
@ -347,7 +359,7 @@ func (m *ModelArtsLink) Execute(ctx context.Context, option *option.AiOption) (i
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ModelArtsLink) GenerateSubmitParams(ctx context.Context, option *option.AiOption) error {
|
func (m *ModelArtsLink) GenerateSubmitParams(ctx context.Context, option *option.AiOption) error {
|
||||||
err := m.generateResourceId(ctx, option)
|
err := m.generateResourceId(ctx, option, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -552,8 +564,13 @@ func (m *ModelArtsLink) GetInferResult(ctx context.Context, url string, file mul
|
||||||
|
|
||||||
func (m *ModelArtsLink) CreateInferDeployInstance(ctx context.Context, option *option.InferOption) (string, error) {
|
func (m *ModelArtsLink) CreateInferDeployInstance(ctx context.Context, option *option.InferOption) (string, error) {
|
||||||
|
|
||||||
|
err := m.GetModelId(ctx, nil, option)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
configParam := &modelarts.ServiceConfig{
|
configParam := &modelarts.ServiceConfig{
|
||||||
Specification: option.Specification,
|
Specification: "modelarts.kat1.xlarge.al",
|
||||||
Weight: option.Weight,
|
Weight: option.Weight,
|
||||||
ModelId: option.ModelId,
|
ModelId: option.ModelId,
|
||||||
InstanceCount: option.InstanceCount,
|
InstanceCount: option.InstanceCount,
|
||||||
|
@ -575,5 +592,14 @@ func (m *ModelArtsLink) CreateInferDeployInstance(ctx context.Context, option *o
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ModelArtsLink) CheckModelExistence(ctx context.Context, name string, mtype string) bool {
|
func (m *ModelArtsLink) CheckModelExistence(ctx context.Context, name string, mtype string) bool {
|
||||||
return false
|
ifoption := &option.InferOption{
|
||||||
|
ModelName: name,
|
||||||
|
ModelType: mtype,
|
||||||
|
}
|
||||||
|
err := m.GetModelId(ctx, nil, ifoption)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue