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.

taskdetailslogic.go 2.3 kB

1 year ago
1 year ago
4 months ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package core
  2. import (
  3. "context"
  4. "github.com/pkg/errors"
  5. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  6. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  7. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
  8. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
  9. "gorm.io/gorm"
  10. "strings"
  11. "github.com/zeromicro/go-zero/core/logx"
  12. )
  13. type TaskDetailsLogic struct {
  14. logx.Logger
  15. ctx context.Context
  16. svcCtx *svc.ServiceContext
  17. }
  18. func NewTaskDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TaskDetailsLogic {
  19. return &TaskDetailsLogic{
  20. Logger: logx.WithContext(ctx),
  21. ctx: ctx,
  22. svcCtx: svcCtx,
  23. }
  24. }
  25. func (l *TaskDetailsLogic) TaskDetails(req *types.FId) (resp *types.TaskDetailsResp, err error) {
  26. resp = &types.TaskDetailsResp{}
  27. task := &models.Task{}
  28. if errors.Is(l.svcCtx.DbEngin.Where("id", req.Id).First(&task).Error, gorm.ErrRecordNotFound) {
  29. return nil, errors.New("记录不存在")
  30. }
  31. clusterIds := make([]string, 0)
  32. var cList []*types.ClusterInfo
  33. var subList []*types.SubTaskInfo
  34. switch task.AdapterTypeDict {
  35. case "0":
  36. l.svcCtx.DbEngin.Table("task_cloud").Where("task_id", task.Id).Scan(&subList)
  37. if len(subList) <= 0 {
  38. l.svcCtx.DbEngin.Table("task_vm").Where("task_id", task.Id).Find(&subList)
  39. }
  40. case "1":
  41. l.svcCtx.DbEngin.Table("task_ai").Where("task_id", task.Id).Scan(&subList)
  42. if len(subList) <= 0 {
  43. l.svcCtx.DbEngin.Table("task_ai_asynchronous").Where("task_id", task.Id).Scan(&subList)
  44. }
  45. case "2":
  46. l.svcCtx.DbEngin.Table("task_hpc").Where("task_id", task.Id).Scan(&subList)
  47. for _, hpc := range subList {
  48. var cluster types.ClusterInfo
  49. tx := l.svcCtx.DbEngin.Table("t_cluster").Where("id = ?", hpc.ClusterId).Scan(&cluster)
  50. if tx.Error != nil {
  51. }
  52. hpc.WorkDir = strings.TrimPrefix(hpc.WorkDir, cluster.WorkDir)
  53. }
  54. }
  55. for _, sub := range subList {
  56. clusterIds = append(clusterIds, sub.ClusterId)
  57. }
  58. err = l.svcCtx.DbEngin.Table("t_cluster").Select("id,adapter_id,name,nickname,description,create_time").Where("id in ?", clusterIds).Scan(&cList).Error
  59. if err != nil {
  60. return resp, err
  61. }
  62. utils.Convert(&task, &resp)
  63. resp.ClusterInfos = cList
  64. resp.SubTaskInfos = subList
  65. return
  66. }
  67. func (l *TaskDetailsLogic) deployTaskDetail() {
  68. //l.svcCtx.Scheduler.AiStorages.GetInferDeployInstanceById()
  69. }

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.