Browse Source

Merge pull request 'fix createinferencetask model option' (#472) from tzwang/pcm-coordinator:master into master

pull/473/head
tzwang 6 months ago
parent
commit
c94c0a00c2
1 changed files with 19 additions and 14 deletions
  1. +19
    -14
      internal/logic/inference/createinferencetasklogic.go

+ 19
- 14
internal/logic/inference/createinferencetasklogic.go View File

@@ -172,14 +172,13 @@ func generateClustersForTaskCreation(distributes types.DataDistribute, taskName
var assignedClusters []*strategy.AssignedCluster
clusterMap := make(map[string]*strategy.AssignedCluster)

for _, distribute := range distributes.Model {
for _, distribute := range distributes.Code {
if len(distribute.Clusters) == 0 {
return nil, fmt.Errorf("Model distribute: must specify at least one cluster")
return nil, fmt.Errorf("Code distribute: must specify at least one cluster")
}

for _, c := range distribute.Clusters {
if c.ClusterID == "" {
return nil, fmt.Errorf("Model distribute: clusterId can not be empty")
return nil, fmt.Errorf("Code distribute: clusterId can not be empty")
}
cluster := &strategy.AssignedCluster{}
cluster.ClusterId = c.ClusterID
@@ -187,31 +186,31 @@ func generateClustersForTaskCreation(distributes types.DataDistribute, taskName
jsonData := entity.JsonData{}
err := json.Unmarshal([]byte(c.JsonData), &jsonData)
if err != nil {
return nil, fmt.Errorf("jsonData convert failed, task %d, cluster %s, datatype: %s", taskName, c.ClusterID, "Model")
return nil, fmt.Errorf("jsonData convert failed, task %d, cluster %s, datatype: %s", taskName, c.ClusterID, "Code")
}
if jsonData.Id == "" {
continue
}
cluster.ModelId = jsonData.Id
cluster.ModelName = jsonData.Name
cluster.CodeId = jsonData.Id
clusterMap[c.ClusterID] = cluster
}

}

for _, distribute := range distributes.Code {
for _, distribute := range distributes.Model {
if len(distribute.Clusters) == 0 {
return nil, fmt.Errorf("Code distribute: must specify at least one cluster")
return nil, fmt.Errorf("Model distribute: must specify at least one cluster")
}

for _, c := range distribute.Clusters {
if c.ClusterID == "" {
return nil, fmt.Errorf("Code distribute: clusterId can not be empty")
return nil, fmt.Errorf("Model distribute: clusterId can not be empty")
}

jsonData := entity.JsonData{}
err := json.Unmarshal([]byte(c.JsonData), &jsonData)
if err != nil {
return nil, fmt.Errorf("jsonData convert failed, task %d, cluster %s, datatype: %s", taskName, c.ClusterID, "Code")
return nil, fmt.Errorf("jsonData convert failed, task %d, cluster %s, datatype: %s", taskName, c.ClusterID, "Model")
}
if jsonData.Id == "" {
continue
@@ -219,9 +218,11 @@ func generateClustersForTaskCreation(distributes types.DataDistribute, taskName

cluster, ok := clusterMap[c.ClusterID]
if ok {
cluster.CodeId = jsonData.Id
cluster.ModelId = jsonData.Id
cluster.ModelName = jsonData.Name
}
}

}

for _, distribute := range distributes.Image {
@@ -239,6 +240,10 @@ func generateClustersForTaskCreation(distributes types.DataDistribute, taskName
return nil, fmt.Errorf("jsonData convert failed, task %d, cluster %s, datatype: %s", taskName, c.ClusterID, "Image")
}

if jsonData.Id == "" {
continue
}

cluster, ok := clusterMap[c.ClusterID]
if ok {
cluster.ImageId = jsonData.Id
@@ -263,7 +268,7 @@ func generateClustersForTaskCreation(distributes types.DataDistribute, taskName
}

if len(assignedClusters) == 0 {
return nil, fmt.Errorf("no model provided")
return nil, fmt.Errorf("no code provided")
}

return assignedClusters, nil


Loading…
Cancel
Save