added options for the strategy and the scheduler
Former-commit-id: a81ff31b7c3b6634496fa453bdd439542e964848
This commit is contained in:
parent
6949d513df
commit
7d91e83a4a
|
@ -38,7 +38,7 @@ type Scheduler struct {
|
|||
participantRpc participantservice.ParticipantService
|
||||
ResourceCollector *map[string]collector.ResourceCollector
|
||||
Storages database.Storage
|
||||
AiExecutor *map[string]executor.Executor
|
||||
AiExecutor *map[string]executor.AiExecutor
|
||||
}
|
||||
|
||||
func NewScheduler(subSchedule common.SubSchedule, val string, dbEngin *gorm.DB, participantRpc participantservice.ParticipantService) (*Scheduler, error) {
|
||||
|
@ -50,7 +50,7 @@ func NewScheduler(subSchedule common.SubSchedule, val string, dbEngin *gorm.DB,
|
|||
return &Scheduler{task: task, subSchedule: subSchedule, dbEngin: dbEngin, participantRpc: participantRpc}, nil
|
||||
}
|
||||
|
||||
func NewScheduler2(resourceCollector *map[string]collector.ResourceCollector, storages database.Storage, aiExecutor *map[string]executor.Executor) *Scheduler {
|
||||
func NewScheduler2(resourceCollector *map[string]collector.ResourceCollector, storages database.Storage, aiExecutor *map[string]executor.AiExecutor) *Scheduler {
|
||||
return &Scheduler{ResourceCollector: resourceCollector, Storages: storages, AiExecutor: aiExecutor}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import (
|
|||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/scheduler"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/scheduler/algorithm/providerPricing"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/scheduler/entity"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/scheduler/schedulers/option"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/scheduler/service/collector"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/scheduler/strategy"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/pkg/response"
|
||||
|
@ -30,6 +31,7 @@ type AiScheduler struct {
|
|||
yamlString string
|
||||
task *response.TaskInfo
|
||||
*scheduler.Scheduler
|
||||
option option.AiOption
|
||||
}
|
||||
|
||||
func NewAiScheduler(val string, scheduler *scheduler.Scheduler) (*AiScheduler, error) {
|
||||
|
@ -48,7 +50,7 @@ func (as *AiScheduler) GetNewStructForDb(task *response.TaskInfo, resource strin
|
|||
}
|
||||
|
||||
func (as *AiScheduler) PickOptimalStrategy() (strategy.Strategy, error) {
|
||||
resources, err := as.findProvidersWithResource()
|
||||
resources, err := as.findClustersWithResource()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -83,12 +85,19 @@ func (as *AiScheduler) AssignTask(clusters []*strategy.AssignedCluster) error {
|
|||
return errors.New("clusters is nil")
|
||||
}
|
||||
|
||||
_ = *as.AiExecutor
|
||||
executorMap := *as.AiExecutor
|
||||
for _, cluster := range clusters {
|
||||
_, err := executorMap[cluster.Name].Execute(option.AiOption{})
|
||||
if err != nil {
|
||||
// TODO: database operation
|
||||
}
|
||||
// TODO: database operation
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (as *AiScheduler) findProvidersWithResource() ([]*collector.ResourceSpecs, error) {
|
||||
func (as *AiScheduler) findClustersWithResource() ([]*collector.ResourceSpecs, error) {
|
||||
var resourceSpecs []*collector.ResourceSpecs
|
||||
for _, resourceCollector := range *as.ResourceCollector {
|
||||
spec, err := resourceCollector.GetResourceSpecs()
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package option
|
||||
|
||||
type AiOption struct {
|
||||
aiType string // shuguangAi/octopus
|
||||
resourceType string // cpu/gpu/compute card
|
||||
taskType string // pytorch/tensorflow
|
||||
|
||||
imageId string
|
||||
specId string
|
||||
datasetsId string
|
||||
codeId string
|
||||
|
||||
cmd string
|
||||
|
||||
datasets string
|
||||
code string
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package executor
|
||||
|
||||
import (
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/scheduler/schedulers/option"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/storeLink"
|
||||
)
|
||||
|
||||
type AiExecutor interface {
|
||||
Execute(option option.AiOption) (interface{}, error)
|
||||
storeLink.Linkage
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
package executor
|
||||
|
||||
type Executor interface {
|
||||
QueryImageList() (interface{}, error)
|
||||
SubmitTask(imageId string, cmd string, envs []string, params []string, resourceId string) (interface{}, error)
|
||||
QueryTask(taskId string) (interface{}, error)
|
||||
QuerySpecs() (interface{}, error)
|
||||
}
|
|
@ -2,3 +2,7 @@ package strategy
|
|||
|
||||
type DynamicResourcesStrategy struct {
|
||||
}
|
||||
|
||||
func (ps *DynamicResourcesStrategy) Schedule() ([]*AssignedCluster, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package option
|
||||
|
||||
type Option interface {
|
||||
GetOption() (interface{}, error)
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package option
|
||||
|
||||
type ResourcePricingOption struct {
|
||||
}
|
|
@ -9,6 +9,3 @@ type AssignedCluster struct {
|
|||
Name string
|
||||
Replicas int32
|
||||
}
|
||||
|
||||
type Options struct {
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ package storeLink
|
|||
|
||||
import (
|
||||
"context"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/scheduler/schedulers/option"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/scheduler/service/collector"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils"
|
||||
|
@ -151,3 +152,7 @@ func (o *ModelArtsLink) QuerySpecs() (interface{}, error) {
|
|||
func (o *ModelArtsLink) GetResourceSpecs() (*collector.ResourceSpecs, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (o *ModelArtsLink) Execute(option option.AiOption) (interface{}, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ package storeLink
|
|||
|
||||
import (
|
||||
"context"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/scheduler/schedulers/option"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/scheduler/service/collector"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils"
|
||||
|
@ -198,3 +199,7 @@ func (o *OctopusLink) QuerySpecs() (interface{}, error) {
|
|||
func (o *OctopusLink) GetResourceSpecs() (*collector.ResourceSpecs, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (o *OctopusLink) Execute(option option.AiOption) (interface{}, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-ac/hpcAC"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/scheduler/schedulers/option"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/scheduler/service/collector"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils"
|
||||
|
@ -174,3 +175,7 @@ func (o *ShuguangAi) QuerySpecs() (interface{}, error) {
|
|||
func (o *ShuguangAi) GetResourceSpecs() (*collector.ResourceSpecs, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (o *ShuguangAi) Execute(option option.AiOption) (interface{}, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue