|
|
|
@@ -47,8 +47,8 @@ func (l *ScheduleRunTaskLogic) ScheduleRunTask(req *types.RunTaskReq) (resp *typ |
|
|
|
return nil, errors.New("task has been cancelled ") |
|
|
|
} |
|
|
|
|
|
|
|
var clusters []*strategy.AssignedCluster |
|
|
|
err = yaml.Unmarshal([]byte(task.YamlString), &clusters) |
|
|
|
var clustersWithDataDistributes ClustersWithDataDistributes |
|
|
|
err = yaml.Unmarshal([]byte(task.YamlString), &clustersWithDataDistributes) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
@@ -58,8 +58,9 @@ func (l *ScheduleRunTaskLogic) ScheduleRunTask(req *types.RunTaskReq) (resp *typ |
|
|
|
TaskName: task.Name, |
|
|
|
StrategyName: "", |
|
|
|
} |
|
|
|
|
|
|
|
// update assignedClusters |
|
|
|
err = updateClustersByScheduledDatas(task.Id, &clusters, req.ScheduledDatas) |
|
|
|
assignedClusters, err := updateClustersByScheduledDatas(task.Id, &clustersWithDataDistributes, req.ScheduledDatas) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
@@ -69,7 +70,7 @@ func (l *ScheduleRunTaskLogic) ScheduleRunTask(req *types.RunTaskReq) (resp *typ |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
|
|
|
|
results, err := l.svcCtx.Scheduler.AssignAndSchedule(aiSchdl, executor.SUBMIT_MODE_STORAGE_SCHEDULE, clusters) |
|
|
|
results, err := l.svcCtx.Scheduler.AssignAndSchedule(aiSchdl, executor.SUBMIT_MODE_STORAGE_SCHEDULE, assignedClusters) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
@@ -111,8 +112,10 @@ func (l *ScheduleRunTaskLogic) SaveResult(task *models.Task, results []*schedule |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
func updateClustersByScheduledDatas(taskId int64, assignedClusters *[]*strategy.AssignedCluster, scheduledDatas []*types.DataScheduleResults) error { |
|
|
|
for _, cluster := range *assignedClusters { |
|
|
|
func updateClustersByScheduledDatas(taskId int64, clustersWithDataDistributes *ClustersWithDataDistributes, scheduledDatas []*types.DataScheduleResults) ([]*strategy.AssignedCluster, error) { |
|
|
|
assignedClusters := make([]*strategy.AssignedCluster, 0) |
|
|
|
// handle pass-in scheduledDatas |
|
|
|
for _, cluster := range clustersWithDataDistributes.Clusters { |
|
|
|
for _, data := range scheduledDatas { |
|
|
|
switch data.DataType { |
|
|
|
case "dataset": |
|
|
|
@@ -131,7 +134,7 @@ func updateClustersByScheduledDatas(taskId int64, assignedClusters *[]*strategy. |
|
|
|
}{} |
|
|
|
err := json.Unmarshal([]byte(c.JsonData), &jsonData) |
|
|
|
if err != nil { |
|
|
|
return fmt.Errorf("jsonData convert failed, task %d, cluster %s, datatype %s", taskId, cluster.ClusterId, "dataset") |
|
|
|
return nil, fmt.Errorf("pass-in jsonData convert failed, task %d, cluster %s, datatype %s", taskId, cluster.ClusterId, "dataset") |
|
|
|
} |
|
|
|
cluster.DatasetId = jsonData.Id |
|
|
|
} |
|
|
|
@@ -153,7 +156,7 @@ func updateClustersByScheduledDatas(taskId int64, assignedClusters *[]*strategy. |
|
|
|
}{} |
|
|
|
err := json.Unmarshal([]byte(c.JsonData), &jsonData) |
|
|
|
if err != nil { |
|
|
|
return fmt.Errorf("jsonData convert failed, task %d, cluster %s, datatype %s", taskId, cluster.ClusterId, "image") |
|
|
|
return nil, fmt.Errorf("pass-in jsonData convert failed, task %d, cluster %s, datatype %s", taskId, cluster.ClusterId, "image") |
|
|
|
} |
|
|
|
cluster.ImageId = jsonData.Id |
|
|
|
} |
|
|
|
@@ -175,7 +178,7 @@ func updateClustersByScheduledDatas(taskId int64, assignedClusters *[]*strategy. |
|
|
|
}{} |
|
|
|
err := json.Unmarshal([]byte(c.JsonData), &jsonData) |
|
|
|
if err != nil { |
|
|
|
return fmt.Errorf("jsonData convert failed, task %d, cluster %s, datatype %s", taskId, cluster.ClusterId, "code") |
|
|
|
return nil, fmt.Errorf("pass-in jsonData convert failed, task %d, cluster %s, datatype %s", taskId, cluster.ClusterId, "code") |
|
|
|
} |
|
|
|
cluster.CodeId = jsonData.Id |
|
|
|
} |
|
|
|
@@ -197,7 +200,7 @@ func updateClustersByScheduledDatas(taskId int64, assignedClusters *[]*strategy. |
|
|
|
}{} |
|
|
|
err := json.Unmarshal([]byte(c.JsonData), &jsonData) |
|
|
|
if err != nil { |
|
|
|
return fmt.Errorf("jsonData convert failed, task %d, cluster %s, datatype %s", taskId, cluster.ClusterId, "model") |
|
|
|
return nil, fmt.Errorf("pass-in jsonData convert failed, task %d, cluster %s, datatype %s", taskId, cluster.ClusterId, "model") |
|
|
|
} |
|
|
|
cluster.ModelId = jsonData.Id |
|
|
|
} |
|
|
|
@@ -205,21 +208,110 @@ func updateClustersByScheduledDatas(taskId int64, assignedClusters *[]*strategy. |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
assignedClusters = append(assignedClusters, cluster) |
|
|
|
} |
|
|
|
|
|
|
|
// handle db yaml clustersWithDataDistributes |
|
|
|
for _, cluster := range assignedClusters { |
|
|
|
if cluster.DatasetId == "" { |
|
|
|
for _, distribute := range clustersWithDataDistributes.DataDistributes.Dataset { |
|
|
|
for _, c := range distribute.Clusters { |
|
|
|
if cluster.ClusterId == c.ClusterID { |
|
|
|
if c.JsonData == "" { |
|
|
|
continue |
|
|
|
} |
|
|
|
jsonData := struct { |
|
|
|
Name string `json:"name"` |
|
|
|
Id string `json:"id"` |
|
|
|
}{} |
|
|
|
err := json.Unmarshal([]byte(c.JsonData), &jsonData) |
|
|
|
if err != nil { |
|
|
|
return nil, fmt.Errorf("db yaml jsonData convert failed, task %d, cluster %s, datatype %s", taskId, cluster.ClusterId, "dataset") |
|
|
|
} |
|
|
|
cluster.DatasetId = jsonData.Id |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if cluster.ImageId == "" { |
|
|
|
for _, distribute := range clustersWithDataDistributes.DataDistributes.Image { |
|
|
|
for _, c := range distribute.Clusters { |
|
|
|
if cluster.ClusterId == c.ClusterID { |
|
|
|
if c.JsonData == "" { |
|
|
|
continue |
|
|
|
} |
|
|
|
jsonData := struct { |
|
|
|
Name string `json:"name"` |
|
|
|
Id string `json:"id"` |
|
|
|
}{} |
|
|
|
err := json.Unmarshal([]byte(c.JsonData), &jsonData) |
|
|
|
if err != nil { |
|
|
|
return nil, fmt.Errorf("db yaml jsonData convert failed, task %d, cluster %s, datatype %s", taskId, cluster.ClusterId, "image") |
|
|
|
} |
|
|
|
cluster.ImageId = jsonData.Id |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if cluster.CodeId == "" { |
|
|
|
for _, distribute := range clustersWithDataDistributes.DataDistributes.Code { |
|
|
|
for _, c := range distribute.Clusters { |
|
|
|
if cluster.ClusterId == c.ClusterID { |
|
|
|
if c.JsonData == "" { |
|
|
|
continue |
|
|
|
} |
|
|
|
jsonData := struct { |
|
|
|
Name string `json:"name"` |
|
|
|
Id string `json:"id"` |
|
|
|
}{} |
|
|
|
err := json.Unmarshal([]byte(c.JsonData), &jsonData) |
|
|
|
if err != nil { |
|
|
|
return nil, fmt.Errorf("db yaml jsonData convert failed, task %d, cluster %s, datatype %s", taskId, cluster.ClusterId, "code") |
|
|
|
} |
|
|
|
cluster.CodeId = jsonData.Id |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if cluster.ModelId == "" { |
|
|
|
for _, distribute := range clustersWithDataDistributes.DataDistributes.Model { |
|
|
|
for _, c := range distribute.Clusters { |
|
|
|
if cluster.ClusterId == c.ClusterID { |
|
|
|
if c.JsonData == "" { |
|
|
|
continue |
|
|
|
} |
|
|
|
jsonData := struct { |
|
|
|
Name string `json:"name"` |
|
|
|
Id string `json:"id"` |
|
|
|
}{} |
|
|
|
err := json.Unmarshal([]byte(c.JsonData), &jsonData) |
|
|
|
if err != nil { |
|
|
|
return nil, fmt.Errorf("jsonData convert failed, task %d, cluster %s, datatype %s", taskId, cluster.ClusterId, "model") |
|
|
|
} |
|
|
|
cluster.ModelId = jsonData.Id |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
for _, cluster := range *assignedClusters { |
|
|
|
// check empty data |
|
|
|
for _, cluster := range assignedClusters { |
|
|
|
if cluster.DatasetId == "" { |
|
|
|
return fmt.Errorf("failed to run task %d, cluster %s cannot find %s", taskId, cluster.ClusterId, "DatasetId") |
|
|
|
return nil, fmt.Errorf("failed to run task %d, cluster %s cannot find %s", taskId, cluster.ClusterId, "DatasetId") |
|
|
|
} |
|
|
|
|
|
|
|
if cluster.ImageId == "" { |
|
|
|
return fmt.Errorf("failed to run task %d, cluster %s cannot find %s", taskId, cluster.ClusterId, "ImageId") |
|
|
|
return nil, fmt.Errorf("failed to run task %d, cluster %s cannot find %s", taskId, cluster.ClusterId, "ImageId") |
|
|
|
} |
|
|
|
|
|
|
|
if cluster.CodeId == "" { |
|
|
|
return fmt.Errorf("failed to run task %d, cluster %s cannot find %s", taskId, cluster.ClusterId, "CodeId") |
|
|
|
return nil, fmt.Errorf("failed to run task %d, cluster %s cannot find %s", taskId, cluster.ClusterId, "CodeId") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return nil |
|
|
|
return assignedClusters, nil |
|
|
|
} |