updated getAdapterByModel logics
Former-commit-id: d777cb359c79a7c6fd96d4ed7de6fb79fcd1d8a1
This commit is contained in:
parent
5a88f9e766
commit
c5b0dc925f
|
@ -2,8 +2,6 @@ package inference
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
|
||||
|
@ -32,9 +30,36 @@ func (l *GetAdaptersByModelLogic) GetAdaptersByModel(req *types.GetAdaptersByMod
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if len(adapterList) == 0 {
|
||||
return nil, errors.New("适配器不存在")
|
||||
for _, adapter := range adapterList {
|
||||
var clusterAvail []*types.ClusterAvail
|
||||
clusters, err := l.svcCtx.Scheduler.AiStorages.GetClustersByAdapterId(adapter.Id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, cluster := range clusters.List {
|
||||
exist := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[adapter.Id][cluster.Id].CheckModelExistence(l.ctx, req.ModelName, req.ModelType)
|
||||
if exist {
|
||||
c := &types.ClusterAvail{
|
||||
ClusterId: cluster.Id,
|
||||
ClusterName: cluster.Name,
|
||||
}
|
||||
clusterAvail = append(clusterAvail, c)
|
||||
}
|
||||
}
|
||||
|
||||
if len(clusterAvail) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
adapterAvail := &types.AdapterAvail{
|
||||
AdapterId: adapter.Id,
|
||||
AdapterName: adapter.Name,
|
||||
Clusters: clusterAvail,
|
||||
}
|
||||
|
||||
resp.Adapters = append(resp.Adapters, adapterAvail)
|
||||
}
|
||||
|
||||
return
|
||||
return resp, nil
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ type ICluster interface {
|
|||
StopInferDeployInstance(ctx context.Context, id string) bool
|
||||
GetInferDeployInstance(ctx context.Context, id string) (*DeployInstance, error)
|
||||
CreateInferDeployInstance(ctx context.Context, option *option.InferOption) (string, error)
|
||||
CheckModelExistence(ctx context.Context, name string, mtype string) bool
|
||||
CheckModelExistence(ctx context.Context, modelName string, modelType string) bool
|
||||
}
|
||||
|
||||
type IInference interface {
|
||||
|
|
|
@ -1253,5 +1253,14 @@ func (o *OctopusLink) CreateInferDeployInstance(ctx context.Context, option *opt
|
|||
}
|
||||
|
||||
func (o *OctopusLink) CheckModelExistence(ctx context.Context, name string, mtype string) bool {
|
||||
return false
|
||||
ifoption := &option.InferOption{
|
||||
ModelName: name,
|
||||
ModelType: mtype,
|
||||
}
|
||||
err := o.generateAlgorithmId(ctx, nil, ifoption)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue