|
|
|
@@ -82,48 +82,41 @@ func (l *ImageInferenceLogic) ImageInfer(r *http.Request, req *types.ImageInfere |
|
|
|
//} |
|
|
|
// |
|
|
|
|
|
|
|
var cs []*strategy.AssignedCluster |
|
|
|
var adapterName string |
|
|
|
adapterName, err := l.svcCtx.Scheduler.AiStorages.GetAdapterNameById(opt.AdapterId) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
|
|
|
|
if opt.Strategy != "" { |
|
|
|
var strat strategy.Strategy |
|
|
|
switch opt.Strategy { |
|
|
|
case strategy.STATIC_WEIGHT: |
|
|
|
strat = strategy.NewStaticWeightStrategy(opt.StaticWeightMap, int32(len(ts))) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
default: |
|
|
|
return nil, errors.New("no strategy has been chosen") |
|
|
|
} |
|
|
|
clusters, err := strat.Schedule() |
|
|
|
return nil, errors.New("strategy is empty") |
|
|
|
} |
|
|
|
|
|
|
|
var strat strategy.Strategy |
|
|
|
switch opt.Strategy { |
|
|
|
case strategy.STATIC_WEIGHT: |
|
|
|
strat = strategy.NewStaticWeightStrategy(opt.StaticWeightMap, int32(len(ts))) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
default: |
|
|
|
return nil, errors.New("no strategy has been chosen") |
|
|
|
} |
|
|
|
clusters, err := strat.Schedule() |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
|
|
|
|
if clusters == nil || len(clusters) == 0 { |
|
|
|
return nil, errors.New("clusters is nil") |
|
|
|
} |
|
|
|
|
|
|
|
for i := len(clusters) - 1; i >= 0; i-- { |
|
|
|
if clusters[i].Replicas == 0 { |
|
|
|
clusters = append(clusters[:i], clusters[i+1:]...) |
|
|
|
} |
|
|
|
} |
|
|
|
if clusters == nil || len(clusters) == 0 { |
|
|
|
return nil, errors.New("clusters is nil") |
|
|
|
} |
|
|
|
|
|
|
|
name, err := l.svcCtx.Scheduler.AiStorages.GetAdapterNameById(opt.AdapterId) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
for i := len(clusters) - 1; i >= 0; i-- { |
|
|
|
if clusters[i].Replicas == 0 { |
|
|
|
clusters = append(clusters[:i], clusters[i+1:]...) |
|
|
|
} |
|
|
|
adapterName = name |
|
|
|
} |
|
|
|
|
|
|
|
//else { |
|
|
|
// for i, instance := range req.Instances { |
|
|
|
// |
|
|
|
// } |
|
|
|
//} |
|
|
|
|
|
|
|
imageInfer, err := imageInference.New(imageInference.NewImageClassification(), ts, cs, req.Instances, opt, l.svcCtx.Scheduler.AiStorages, l.svcCtx.Scheduler.AiService.InferenceAdapterMap, adapterName) |
|
|
|
imageInfer, err := imageInference.New(imageInference.NewImageClassification(), ts, clusters, req.Instances, opt, l.svcCtx.Scheduler.AiStorages, l.svcCtx.Scheduler.AiService.InferenceAdapterMap, adapterName) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
|