modified schedule apis

Former-commit-id: a30d161c27346206ae0eaeaa2056eb2b1e97f756
This commit is contained in:
tzwang 2024-02-05 17:27:33 +08:00
parent ceaad28539
commit 3102a154c5
7 changed files with 33 additions and 18 deletions

View File

@ -2,6 +2,7 @@ package schedule
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/storeLink"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
@ -24,7 +25,9 @@ func NewScheduleGetAiResourceTypesLogic(ctx context.Context, svcCtx *svc.Service
}
func (l *ScheduleGetAiResourceTypesLogic) ScheduleGetAiResourceTypes() (resp *types.AiResourceTypesResp, err error) {
// todo: add your logic here and delete this line
resp = &types.AiResourceTypesResp{}
resourceTypes := storeLink.GetResourceTypes()
resp.ResourceTypes = resourceTypes
return
return resp, nil
}

View File

@ -2,6 +2,7 @@ package schedule
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/storeLink"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
@ -24,7 +25,9 @@ func NewScheduleGetAiTaskTypesLogic(ctx context.Context, svcCtx *svc.ServiceCont
}
func (l *ScheduleGetAiTaskTypesLogic) ScheduleGetAiTaskTypes() (resp *types.AiTaskTypesResp, err error) {
// todo: add your logic here and delete this line
resp = &types.AiTaskTypesResp{}
taskTypes := storeLink.GetTaskTypes()
resp.TaskTypes = taskTypes
return
return resp, nil
}

View File

@ -2,6 +2,8 @@ package schedule
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/scheduler/service"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/storeLink"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
@ -24,7 +26,12 @@ func NewScheduleGetDatasetsLogic(ctx context.Context, svcCtx *svc.ServiceContext
}
func (l *ScheduleGetDatasetsLogic) ScheduleGetDatasets() (resp *types.AiDatasetsResp, err error) {
// todo: add your logic here and delete this line
return
resp = &types.AiDatasetsResp{}
_, colMap := service.InitAiClusterMap(l.ctx, l.svcCtx)
names, err := storeLink.GetDatasetsNames(colMap)
if err != nil {
return nil, err
}
resp.Datasets = names
return resp, nil
}

View File

@ -2,7 +2,7 @@ package schedule
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/scheduler/strategy"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
@ -24,7 +24,9 @@ func NewScheduleGetStrategyLogic(ctx context.Context, svcCtx *svc.ServiceContext
}
func (l *ScheduleGetStrategyLogic) ScheduleGetStrategy() (resp *types.AiStrategyResp, err error) {
// todo: add your logic here and delete this line
resp = &types.AiStrategyResp{}
names := strategy.GetStrategyNames()
resp.Strategies = names
return
return resp, nil
}

View File

@ -71,7 +71,7 @@ func (as *AiScheduler) PickOptimalStrategy() (strategy.Strategy, error) {
case strategy.REPLICATION:
strategy := strategy.NewReplicationStrategy(&param.ReplicationParams{Params: params, Replicas: 1})
return strategy, nil
case strategy.RESOURCE_PRICING:
case strategy.RESOURCES_PRICING:
strategy := strategy.NewPricingStrategy(&param.ResourcePricingParams{Params: params, Replicas: 1})
return strategy, nil
}

View File

@ -1,14 +1,14 @@
package strategy
const (
REPLICATION = "replication"
RESOURCE_PRICING = "resourcePricing"
STATIC_WEIGHT = "staticWeight"
DYNAMIC_WEIGHT = "dynamicWeight"
REPLICATION = "replication"
RESOURCES_PRICING = "resourcesPricing"
STATIC_WEIGHT = "staticWeight"
DYNAMIC_RESOURCES = "dynamicResources"
)
var (
strategyNames = []string{REPLICATION, RESOURCE_PRICING}
strategyNames = []string{REPLICATION, RESOURCES_PRICING, STATIC_WEIGHT, DYNAMIC_RESOURCES}
)
type Strategy interface {

View File

@ -15,7 +15,7 @@ func TestReplication(t *testing.T) {
{Name: "test2", Participant_id: 2},
{Name: "test3", Participant_id: 3},
}
rsc := []*collector.ResourceSpecs{
rsc := []*collector.ResourceStats{
{
ParticipantId: 1,
Name: "test1",
@ -31,7 +31,7 @@ func TestReplication(t *testing.T) {
name string
replica int32
ps []entity.Participant
res []*collector.ResourceSpecs
res []*collector.ResourceStats
}{
{
name: "test1",