|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- package ai
-
- import (
- "context"
- "github.com/jinzhu/copier"
- "gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
- "gitlink.org.cn/jcce-pcm/utils/result"
- "gitlink.org.cn/jcce-pcm/utils/tool"
- "k8s.io/apimachinery/pkg/util/json"
-
- "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
- "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
-
- "github.com/zeromicro/go-zero/core/logx"
- )
-
- type CreateTrainingJobLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
-
- func NewCreateTrainingJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateTrainingJobLogic {
- return &CreateTrainingJobLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx,
- }
- }
-
- func (l *CreateTrainingJobLogic) CreateTrainingJob(req *types.CreateTrainingJobReq) (resp *types.CreateTrainingJobResp, err error) {
- // todo: add your logic here and delete this line
- //modelartsType := req.ModelartsType
- modelartsReq := &modelarts.CreateTrainingJobReq{}
- err = copier.CopyWithOption(modelartsReq, req, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: tool.Converters})
- CreateTrainingJobResp, err := l.svcCtx.ModelArtsRpc.CreateTrainingJob(l.ctx, modelartsReq)
- if err != nil {
- return nil, result.NewDefaultError(err.Error())
- }
- marshal, err := json.Marshal(&CreateTrainingJobResp)
- if err != nil {
- return nil, result.NewDefaultError(err.Error())
- }
- json.Unmarshal(marshal, &resp)
- err = copier.CopyWithOption(&resp, &CreateTrainingJobResp, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: tool.Converters})
- return resp, nil
- }
|