You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

taskParamChecker.go 2.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package task
  2. import (
  3. "fmt"
  4. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/common"
  5. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/strategy"
  6. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/storeLink"
  7. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  8. )
  9. func ValidateJobResources(resources types.JobResources, taskType string) error {
  10. switch taskType {
  11. case "training":
  12. if resources.ScheduleStrategy == "" {
  13. return fmt.Errorf("must specify ScheduleStrategy")
  14. }
  15. }
  16. if len(resources.Clusters) == 0 {
  17. return fmt.Errorf("must specify at least one cluster")
  18. }
  19. for _, c := range resources.Clusters {
  20. if c.ClusterID == "" {
  21. return fmt.Errorf("must specify clusterID")
  22. }
  23. if len(c.Resources) == 0 {
  24. return fmt.Errorf("cluster: %s must specify at least one compute resource", c.ClusterID)
  25. //return errors.Wrapf(xerr.NewErrCodeMsg(1234, fmt.Sprintf("cluster: %s must specify at least one compute resource", c.ClusterID)), "")
  26. }
  27. }
  28. return nil
  29. }
  30. func CopyParams(clusters []*strategy.AssignedCluster, clusterInfos []*types.JobClusterInfo, taskType string) []*strategy.AssignedCluster {
  31. var result []*strategy.AssignedCluster
  32. for _, c := range clusters {
  33. for _, info := range clusterInfos {
  34. if c.ClusterId == info.ClusterID {
  35. var envs []string
  36. var params []string
  37. for k, v := range info.Runtime.Envs {
  38. val := common.ConvertTypeToString(v)
  39. if val != "" {
  40. env := k + storeLink.COMMA + val
  41. envs = append(envs, env)
  42. }
  43. }
  44. for k, v := range info.Runtime.Params {
  45. val := common.ConvertTypeToString(v)
  46. if val != "" {
  47. p := k + storeLink.COMMA + val
  48. params = append(params, p)
  49. }
  50. }
  51. cluster := &strategy.AssignedCluster{
  52. ClusterId: c.ClusterId,
  53. ClusterName: c.ClusterName,
  54. Replicas: c.Replicas,
  55. ResourcesRequired: info.Resources,
  56. Cmd: info.Runtime.Command,
  57. Envs: envs,
  58. Params: params,
  59. }
  60. result = append(result, cluster)
  61. }
  62. }
  63. }
  64. if taskType == "inference" {
  65. for _, c := range clusters {
  66. for _, r := range result {
  67. if c.ClusterId == r.ClusterId {
  68. r.ModelId = c.ModelId
  69. r.ModelName = c.ModelName
  70. r.ImageId = c.ImageId
  71. r.CodeId = c.CodeId
  72. }
  73. }
  74. }
  75. }
  76. return result
  77. }

PCM is positioned as Software stack over Cloud, aiming to build the standards and ecology of heterogeneous cloud collaboration for JCC in a non intrusive and autonomous peer-to-peer manner.