Merge pull request 'modify ai replicas' (#178) from master-wq into master

Former-commit-id: 1fe43cd8eff3a1986305a3d02fad93df149ace9e
This commit is contained in:
qiwang 2024-05-16 16:08:21 +08:00
commit 32b4c340be
7 changed files with 6 additions and 6 deletions

View File

@ -44,6 +44,7 @@ type (
Params []string `json:"params,optional"` Params []string `json:"params,optional"`
Envs []string `json:"envs,optional"` Envs []string `json:"envs,optional"`
Cmd string `json:"cmd,optional"` Cmd string `json:"cmd,optional"`
Replica int32 `json:"replicas"`
} }
AiResourceTypesResp { AiResourceTypesResp {

View File

@ -110,7 +110,6 @@ func (l *CommitVmTaskLogic) CommitVmTask(req *types.CommitVmTaskReq) (resp *type
AND vf.public_flavor_id = ? AND vf.public_flavor_id = ?
AND vi.public_image_id = ? AND vi.public_image_id = ?
AND vn.public_network_id = ?` AND vn.public_network_id = ?`
// err2 := l.svcCtx.DbEngin.Raw(sql, clusterId, req.FlavorRef, req.ImageRef, req.Uuid).Scan(&taskVm).Error
txVm := l.svcCtx.DbEngin.Raw(sql, clusterId, req.FlavorRef, req.ImageRef, req.Uuid).Scan(&VmObject) txVm := l.svcCtx.DbEngin.Raw(sql, clusterId, req.FlavorRef, req.ImageRef, req.Uuid).Scan(&VmObject)
if txVm.Error != nil { if txVm.Error != nil {
logx.Error(err) logx.Error(err)
@ -118,7 +117,6 @@ func (l *CommitVmTaskLogic) CommitVmTask(req *types.CommitVmTaskReq) (resp *type
} }
if err2 != nil { if err2 != nil {
logx.Errorf("CommitGeneralTask() => sql execution error: %v", err) logx.Errorf("CommitGeneralTask() => sql execution error: %v", err)
//return errors.Errorf("the cluster does not match the drive resources. Check the data"), nil
} }
taskVm.Name = req.VmName taskVm.Name = req.VmName
taskVm.Status = "Saved" taskVm.Status = "Saved"

View File

@ -33,8 +33,8 @@ func (l *ScheduleSubmitLogic) ScheduleSubmit(req *types.ScheduleReq) (resp *type
AdapterId: req.AiOption.AdapterId, AdapterId: req.AiOption.AdapterId,
TaskName: req.AiOption.TaskName, TaskName: req.AiOption.TaskName,
ResourceType: req.AiOption.ResourceType, ResourceType: req.AiOption.ResourceType,
Replica: req.AiOption.Replica,
ComputeCard: req.AiOption.ComputeCard, ComputeCard: req.AiOption.ComputeCard,
Replica: 1,
Tops: req.AiOption.Tops, Tops: req.AiOption.Tops,
TaskType: req.AiOption.TaskType, TaskType: req.AiOption.TaskType,
DatasetsName: req.AiOption.Datasets, DatasetsName: req.AiOption.Datasets,

View File

@ -120,7 +120,7 @@ func (s *AiStorage) SaveAiTask(taskId int64, option *option.AiOption, clusterId
ClusterId: cId, ClusterId: cId,
ClusterName: clusterName, ClusterName: clusterName,
Name: option.TaskName, Name: option.TaskName,
Replica: option.Replica, Replica: int64(option.Replica),
JobId: jobId, JobId: jobId,
TaskType: option.TaskType, TaskType: option.TaskType,
Strategy: option.StrategyName, Strategy: option.StrategyName,

View File

@ -105,7 +105,7 @@ func (as *AiScheduler) PickOptimalStrategy() (strategy.Strategy, error) {
return strategy, nil return strategy, nil
case strategy.STATIC_WEIGHT: case strategy.STATIC_WEIGHT:
//todo resources should match cluster StaticWeightMap //todo resources should match cluster StaticWeightMap
strategy := strategy.NewStaticWeightStrategy(as.option.ClusterToStaticWeight, 1) strategy := strategy.NewStaticWeightStrategy(as.option.ClusterToStaticWeight, as.option.Replica)
return strategy, nil return strategy, nil
} }

View File

@ -4,7 +4,7 @@ type AiOption struct {
AdapterId string AdapterId string
ClusterIds []string ClusterIds []string
TaskName string TaskName string
Replica int64 Replica int32
ResourceType string // cpu/gpu/compute card ResourceType string // cpu/gpu/compute card
CpuCoreNum int64 CpuCoreNum int64
TaskType string // pytorch/tensorflow/mindspore TaskType string // pytorch/tensorflow/mindspore

View File

@ -5647,6 +5647,7 @@ type AiOption struct {
Params []string `json:"params,optional"` Params []string `json:"params,optional"`
Envs []string `json:"envs,optional"` Envs []string `json:"envs,optional"`
Cmd string `json:"cmd,optional"` Cmd string `json:"cmd,optional"`
Replica int32 `json:"replicas"`
} }
type AiResourceTypesResp struct { type AiResourceTypesResp struct {