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 2.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. Copyright (c) [2023] [pcm]
  3. [pcm-coordinator] is licensed under Mulan PSL v2.
  4. You can use this software according to the terms and conditions of the Mulan PSL v2.
  5. You may obtain a copy of Mulan PSL v2 at:
  6. http://license.coscl.org.cn/MulanPSL2
  7. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  8. EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  9. MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  10. See the Mulan PSL v2 for more details.
  11. */
  12. package ai
  13. import (
  14. "context"
  15. "github.com/jinzhu/copier"
  16. "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
  17. "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
  18. error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error"
  19. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
  20. "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
  21. "k8s.io/apimachinery/pkg/util/json"
  22. "github.com/zeromicro/go-zero/core/logx"
  23. )
  24. type CreateTrainingJobLogic struct {
  25. logx.Logger
  26. ctx context.Context
  27. svcCtx *svc.ServiceContext
  28. }
  29. func NewCreateTrainingJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateTrainingJobLogic {
  30. return &CreateTrainingJobLogic{
  31. Logger: logx.WithContext(ctx),
  32. ctx: ctx,
  33. svcCtx: svcCtx,
  34. }
  35. }
  36. func (l *CreateTrainingJobLogic) CreateTrainingJob(req *types.CreateTrainingJobReq) (resp *types.CreateTrainingJobResp, err error) {
  37. // todo: add your logic here and delete this line
  38. //modelartsType := req.ModelartsType
  39. modelartsReq := &modelarts.CreateTrainingJobReq{}
  40. err = copier.CopyWithOption(modelartsReq, req, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters})
  41. CreateTrainingJobResp, err := l.svcCtx.ModelArtsRpc.CreateTrainingJob(l.ctx, modelartsReq)
  42. if err != nil {
  43. return nil, error2.NewDefaultError(err.Error())
  44. }
  45. marshal, err := json.Marshal(&CreateTrainingJobResp)
  46. if err != nil {
  47. return nil, error2.NewDefaultError(err.Error())
  48. }
  49. json.Unmarshal(marshal, &resp)
  50. err = copier.CopyWithOption(&resp, &CreateTrainingJobResp, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters})
  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.