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.

schedulegetaijoblogloglogic.go 1.7 kB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package schedule
  2. import (
  3. "context"
  4. "errors"
  5. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants"
  6. "strconv"
  7. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  8. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  9. "github.com/zeromicro/go-zero/core/logx"
  10. )
  11. type ScheduleGetAiJobLogLogLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewScheduleGetAiJobLogLogLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScheduleGetAiJobLogLogLogic {
  17. return &ScheduleGetAiJobLogLogLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. }
  22. }
  23. func (l *ScheduleGetAiJobLogLogLogic) ScheduleGetAiJobLogLog(req *types.AiJobLogReq) (resp *types.AiJobLogResp, err error) {
  24. resp = &types.AiJobLogResp{}
  25. taskId, err := strconv.ParseInt(req.TaskId, 10, 64)
  26. if err != nil {
  27. return nil, err
  28. }
  29. task, err := l.svcCtx.Scheduler.AiStorages.GetTaskById(taskId)
  30. if err != nil {
  31. return nil, err
  32. }
  33. aiTasks, err := l.svcCtx.Scheduler.AiStorages.GetAiTasksByTaskId(req.TaskId)
  34. if err != nil {
  35. return nil, err
  36. }
  37. if len(aiTasks) == 0 && task.Status == constants.Failed {
  38. return nil, errors.New("submit failed, no log available")
  39. } else if len(aiTasks) > 1 {
  40. return nil, errors.New("multiple ai task found")
  41. }
  42. aiTask := aiTasks[0]
  43. adapterId := strconv.FormatInt(aiTask.AdapterId, 10)
  44. clusterId := strconv.FormatInt(aiTask.ClusterId, 10)
  45. jobId := aiTask.JobId
  46. log, err := l.svcCtx.Scheduler.AiService.AiCollectorAdapterMap[adapterId][clusterId].GetTrainingTaskLog(l.ctx, jobId, req.InstanceNum)
  47. if err != nil {
  48. return nil, err
  49. }
  50. resp.Log = log
  51. return resp, nil
  52. }

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.