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.

createtrainingjoblogic.go 1.6 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package ai
  2. import (
  3. "context"
  4. "github.com/jinzhu/copier"
  5. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
  6. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
  7. error2 "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/repository/error"
  8. "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils"
  9. "gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
  10. "k8s.io/apimachinery/pkg/util/json"
  11. "github.com/zeromicro/go-zero/core/logx"
  12. )
  13. type CreateTrainingJobLogic struct {
  14. logx.Logger
  15. ctx context.Context
  16. svcCtx *svc.ServiceContext
  17. }
  18. func NewCreateTrainingJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateTrainingJobLogic {
  19. return &CreateTrainingJobLogic{
  20. Logger: logx.WithContext(ctx),
  21. ctx: ctx,
  22. svcCtx: svcCtx,
  23. }
  24. }
  25. func (l *CreateTrainingJobLogic) CreateTrainingJob(req *types.CreateTrainingJobReq) (resp *types.CreateTrainingJobResp, err error) {
  26. // todo: add your logic here and delete this line
  27. //modelartsType := req.ModelartsType
  28. modelartsReq := &modelarts.CreateTrainingJobReq{}
  29. err = copier.CopyWithOption(modelartsReq, req, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters})
  30. CreateTrainingJobResp, err := l.svcCtx.ModelArtsRpc.CreateTrainingJob(l.ctx, modelartsReq)
  31. if err != nil {
  32. return nil, error2.NewDefaultError(err.Error())
  33. }
  34. marshal, err := json.Marshal(&CreateTrainingJobResp)
  35. if err != nil {
  36. return nil, error2.NewDefaultError(err.Error())
  37. }
  38. json.Unmarshal(marshal, &resp)
  39. err = copier.CopyWithOption(&resp, &CreateTrainingJobResp, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters})
  40. return resp, nil
  41. }

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.