modified ai option and dynamicResource strategy

Former-commit-id: 98ae246782e73cca61ee5946d1c85f03ddba4304
This commit is contained in:
tzwang 2024-03-15 17:34:49 +08:00
parent f2cf784a7d
commit fd71bfba72
4 changed files with 37 additions and 2 deletions

View File

@ -74,6 +74,9 @@ func (as *AiScheduler) PickOptimalStrategy() (strategy.Strategy, error) {
case strategy.RESOURCES_PRICING:
strategy := strategy.NewPricingStrategy(&param.ResourcePricingParams{Params: params, Replicas: 1})
return strategy, nil
case strategy.DYNAMIC_RESOURCES:
strategy := strategy.NewDynamicResourcesStrategy(resources, as.option)
return strategy, nil
}
return nil, errors.New("no strategy has been chosen")

View File

@ -29,3 +29,7 @@ type AiOption struct {
Image string
Model interface{}
}
func (a AiOption) GetOptionType() string {
return AI
}

View File

@ -1,5 +1,11 @@
package option
type Option struct {
Name string
const (
AI = "ai"
CLOUD = "cloud"
HPC = "hpc"
)
type Option interface {
GetOptionType() string
}

View File

@ -1,8 +1,30 @@
package strategy
import (
"errors"
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers/option"
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/collector"
)
type DynamicResourcesStrategy struct {
replicas int32
resources []*collector.ResourceStats
opt option.Option
}
func NewDynamicResourcesStrategy(resources []*collector.ResourceStats, opt option.Option) *DynamicResourcesStrategy {
return &DynamicResourcesStrategy{resources: resources, opt: opt}
}
func (ps *DynamicResourcesStrategy) Schedule() ([]*AssignedCluster, error) {
if ps.replicas < 1 {
return nil, errors.New("replicas must be greater than 0")
}
switch ps.opt.GetOptionType() {
case option.AI:
_ = (interface{})(ps.opt).(*option.AiOption)
}
return nil, nil
}