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.

createnotebooklogic.go 1.4 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package ai
  2. import (
  3. "context"
  4. "github.com/jinzhu/copier"
  5. "github.com/pkg/errors"
  6. "gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
  7. "gitlink.org.cn/jcce-pcm/utils/tool"
  8. "gitlink.org.cn/jcce-pcm/utils/xerr"
  9. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
  10. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
  11. "github.com/zeromicro/go-zero/core/logx"
  12. )
  13. type CreateNotebookLogic struct {
  14. logx.Logger
  15. ctx context.Context
  16. svcCtx *svc.ServiceContext
  17. }
  18. func NewCreateNotebookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateNotebookLogic {
  19. return &CreateNotebookLogic{
  20. Logger: logx.WithContext(ctx),
  21. ctx: ctx,
  22. svcCtx: svcCtx,
  23. }
  24. }
  25. func (l *CreateNotebookLogic) CreateNotebook(req *types.CreateNotebookReq) (resp *types.CreateNotebookResp, err error) {
  26. modelartsReq := &modelarts.CreateNotebookReq{}
  27. err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: tool.Converters})
  28. createNotebookResp, err := l.svcCtx.ModelArtsRpc.CreateNotebook(l.ctx, modelartsReq)
  29. if err != nil {
  30. return nil, errors.Wrapf(xerr.NewErrMsg("Failed to create notebook"), "Failed to create notebook err : %v ,req:%+v", err, req)
  31. }
  32. resp = &types.CreateNotebookResp{}
  33. err = copier.CopyWithOption(resp, createNotebookResp, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: tool.Converters})
  34. return resp, nil
  35. }

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.