|
- package schedule
-
- import (
- "context"
- "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers"
- "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers/option"
-
- "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
- "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
-
- "github.com/zeromicro/go-zero/core/logx"
- )
-
- type ScheduleSubmitLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
-
- func NewScheduleSubmitLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScheduleSubmitLogic {
- return &ScheduleSubmitLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx,
- }
- }
-
- func (l *ScheduleSubmitLogic) ScheduleSubmit(req *types.ScheduleReq) (resp *types.ScheduleResp, err error) {
- resp = &types.ScheduleResp{}
- opt := &option.AiOption{
- ResourceType: req.AiOption.ResourceType,
- Tops: 0,
- TaskType: req.AiOption.TaskType,
- DatasetsName: req.AiOption.Datasets,
- //AlgorithmName: "cnn",
- StrategyName: req.AiOption.Strategy,
- ClusterToStaticWeight: nil,
- Params: []string{
- "epoch,1",
- },
- }
- aiSchdl, err := schedulers.NewAiScheduler(l.ctx, "", l.svcCtx.Scheduler, opt)
- if err != nil {
- return nil, err
- }
-
- _, err = l.svcCtx.Scheduler.AssignAndSchedule(aiSchdl)
- if err != nil {
- return nil, err
- }
-
- return resp, nil
- }
|