数据集导入接口提交
This commit is contained in:
parent
3471f62558
commit
ca4ac988b6
|
@ -0,0 +1,30 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/adaptor/AIComputing/AICore/api/internal/svc"
|
||||
"PCM/adaptor/AIComputing/AICore/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
|
||||
|
||||
return
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"PCM/adaptor/AIComputing/modelarts/rpc/modelarts"
|
||||
"PCM/common/tool"
|
||||
"PCM/common/xerr"
|
||||
"context"
|
||||
"github.com/jinzhu/copier"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"PCM/adaptor/AIComputing/AICore/api/internal/svc"
|
||||
"PCM/adaptor/AIComputing/AICore/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ListImportLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewListImportLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListImportLogic {
|
||||
return &ListImportLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *ListImportLogic) ListImport(req *types.ListImportTasksReq) (resp *types.ListImportTasksResp, err error) {
|
||||
modelartsReq := &modelarts.ListImportTasksReq{}
|
||||
err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: tool.Converters})
|
||||
listDataSetResp, err := l.svcCtx.ModelArtsRpc.GetImportTaskList(l.ctx, modelartsReq)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db DataSet list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req)
|
||||
}
|
||||
resp = &types.ListImportTasksResp{}
|
||||
for i := 0; i < len(listDataSetResp.ImportTasks); i++ {
|
||||
historyJob := types.ImportTasks{}
|
||||
resp.ImportTasks = append(resp.ImportTasks, historyJob)
|
||||
}
|
||||
|
||||
err = copier.CopyWithOption(&resp, &listDataSetResp, copier.Option{Converters: tool.Converters})
|
||||
/*if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i := range resp.DataSet {
|
||||
resp.DataSet[i]. = "modelarts"
|
||||
}*/
|
||||
|
||||
return resp, nil
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"PCM/adaptor/AIComputing/modelarts/rpc/modelarts"
|
||||
"PCM/common/tool"
|
||||
"PCM/common/xerr"
|
||||
"context"
|
||||
"github.com/jinzhu/copier"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"PCM/adaptor/AIComputing/AICore/api/internal/svc"
|
||||
"PCM/adaptor/AIComputing/AICore/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ListTrainingJobsreqLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewListTrainingJobsreqLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListTrainingJobsreqLogic {
|
||||
return &ListTrainingJobsreqLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *ListTrainingJobsreqLogic) ListTrainingJobsreq(req *types.ListTrainingJobsreq) (resp *types.ListTrainingJobsresp, err error) {
|
||||
modelartsReq := &modelarts.ListTrainingJobsreq{}
|
||||
err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: tool.Converters})
|
||||
listDataSetResp, err := l.svcCtx.ModelArtsRpc.GetListTrainingJobs(l.ctx, modelartsReq)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db DataSet list"), "Failed to get db DataSet list err : %v ,req:%+v", err, req)
|
||||
}
|
||||
resp = &types.ListTrainingJobsresp{}
|
||||
for i := 0; i < len(listDataSetResp.Items); i++ {
|
||||
historyJob := types.Items{}
|
||||
resp.Items = append(resp.Items, historyJob)
|
||||
}
|
||||
|
||||
err = copier.CopyWithOption(&resp, &listDataSetResp, copier.Option{Converters: tool.Converters})
|
||||
/*if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i := range resp.DataSet {
|
||||
resp.DataSet[i]. = "modelarts"
|
||||
}*/
|
||||
|
||||
return resp, nil
|
||||
}
|
Loading…
Reference in New Issue