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.

trainingtaskstatlogic.go 1.0 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package ai
  2. import (
  3. "context"
  4. "errors"
  5. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  6. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  7. "github.com/zeromicro/go-zero/core/logx"
  8. )
  9. type TrainingTaskStatLogic struct {
  10. logx.Logger
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. }
  14. func NewTrainingTaskStatLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TrainingTaskStatLogic {
  15. return &TrainingTaskStatLogic{
  16. Logger: logx.WithContext(ctx),
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. }
  20. }
  21. func (l *TrainingTaskStatLogic) TrainingTaskStat() (resp *types.TrainingTaskStatResp, err error) {
  22. resp = &types.TrainingTaskStatResp{}
  23. total, err := l.svcCtx.Scheduler.AiStorages.GetTrainingTaskTotalNum()
  24. if err != nil {
  25. return nil, err
  26. }
  27. running, err := l.svcCtx.Scheduler.AiStorages.GetTrainingTaskRunningNum()
  28. if err != nil {
  29. return nil, err
  30. }
  31. if total == 0 {
  32. return nil, errors.New("get statistics failed")
  33. }
  34. resp.Total = total
  35. resp.Running = running
  36. return resp, nil
  37. }

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.