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.

createalgorithmlogic.go 1.5 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package ai
  2. import (
  3. "context"
  4. "github.com/jinzhu/copier"
  5. "github.com/zeromicro/go-zero/core/logx"
  6. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
  7. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
  8. "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils"
  9. "gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
  10. "gitlink.org.cn/jcce-pcm/utils/result"
  11. "k8s.io/apimachinery/pkg/util/json"
  12. )
  13. type CreateAlgorithmLogic struct {
  14. logx.Logger
  15. ctx context.Context
  16. svcCtx *svc.ServiceContext
  17. }
  18. func NewCreateAlgorithmLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateAlgorithmLogic {
  19. return &CreateAlgorithmLogic{
  20. Logger: logx.WithContext(ctx),
  21. ctx: ctx,
  22. svcCtx: svcCtx,
  23. }
  24. }
  25. func (l *CreateAlgorithmLogic) CreateAlgorithm(req *types.CreateAlgorithmReq) (resp *types.CreateAlgorithmResp, err error) {
  26. modelartsReq := &modelarts.CreateAlgorithmReq{}
  27. err = copier.CopyWithOption(modelartsReq, req, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters})
  28. ListAlgorithmsResp, err := l.svcCtx.ModelArtsRpc.CreateAlgorithm(l.ctx, modelartsReq)
  29. if err != nil {
  30. return nil, result.NewDefaultError(err.Error())
  31. }
  32. marshal, err := json.Marshal(&ListAlgorithmsResp)
  33. if err != nil {
  34. return nil, result.NewDefaultError(err.Error())
  35. }
  36. json.Unmarshal(marshal, &resp)
  37. err = copier.CopyWithOption(&resp, &ListAlgorithmsResp, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters})
  38. return resp, nil
  39. }

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.