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.

deletealgorithmlogic.go 2.3 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. "github.com/pkg/errors"
  17. "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
  18. "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
  19. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr"
  20. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
  21. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
  22. "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
  23. "k8s.io/apimachinery/pkg/util/json"
  24. "strings"
  25. "github.com/zeromicro/go-zero/core/logx"
  26. )
  27. type DeleteAlgorithmLogic struct {
  28. logx.Logger
  29. ctx context.Context
  30. svcCtx *svc.ServiceContext
  31. }
  32. func NewDeleteAlgorithmLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteAlgorithmLogic {
  33. return &DeleteAlgorithmLogic{
  34. Logger: logx.WithContext(ctx),
  35. ctx: ctx,
  36. svcCtx: svcCtx,
  37. }
  38. }
  39. func (l *DeleteAlgorithmLogic) DeleteAlgorithm(req *types.DeleteAlgorithmReq) (resp *types.DeleteAlgorithmResp, err error) {
  40. modelartsReq := &modelarts.DeleteAlgorithmsReq{}
  41. reqByte, err := json.Marshal(req)
  42. if err != nil {
  43. return nil, err
  44. }
  45. payload := strings.NewReader(string(reqByte))
  46. println(payload)
  47. err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters})
  48. DeleteAlgorithmResp, err := l.svcCtx.ModelArtsRpc.DeleteAlgorithms(l.ctx, modelartsReq)
  49. if err != nil {
  50. return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db DataSet list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req)
  51. }
  52. marshal, err := json.Marshal(&DeleteAlgorithmResp)
  53. if err != nil {
  54. return nil, result.NewDefaultError(err.Error())
  55. }
  56. json.Unmarshal(marshal, &resp)
  57. err = copier.CopyWithOption(&resp, &DeleteAlgorithmResp, copier.Option{Converters: utils.Converters})
  58. return resp, nil
  59. }

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.