数据集导入接口提交
This commit is contained in:
parent
ca4ac988b6
commit
0a87716f9b
|
@ -300,7 +300,7 @@ service AICore-api {
|
|||
@handler ListImportHandler
|
||||
get /ListImport (ListImportTasksReq) returns (ListImportTasksResp)
|
||||
// ListTrainingJobs 查询训练作业列表
|
||||
@handler ListTrainingJobsreq
|
||||
@handler GetListTrainingJobsHandler
|
||||
get /GetListTrainingJobs (ListTrainingJobsreq) returns (ListTrainingJobsresp)
|
||||
// CreateTrainingJob 创建训练作业
|
||||
@handler CreateTrainingJobHandler
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"PCM/adaptor/AIComputing/AICore/api/internal/logic"
|
||||
"PCM/adaptor/AIComputing/AICore/api/internal/svc"
|
||||
"PCM/adaptor/AIComputing/AICore/api/internal/types"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
func CreateTrainingJobHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.CreateTrainingJobReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := logic.NewCreateTrainingJobLogic(r.Context(), svcCtx)
|
||||
resp, err := l.CreateTrainingJob(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"PCM/adaptor/AIComputing/AICore/api/internal/logic"
|
||||
"PCM/adaptor/AIComputing/AICore/api/internal/svc"
|
||||
"PCM/adaptor/AIComputing/AICore/api/internal/types"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
func GetListTrainingJobsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ListTrainingJobsreq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := logic.NewGetListTrainingJobsLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetListTrainingJobs(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"PCM/adaptor/AIComputing/AICore/api/internal/logic"
|
||||
"PCM/adaptor/AIComputing/AICore/api/internal/svc"
|
||||
"PCM/adaptor/AIComputing/AICore/api/internal/types"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
func ListImportHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ListImportTasksReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := logic.NewListImportLogic(r.Context(), svcCtx)
|
||||
resp, err := l.ListImport(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +1,14 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"PCM/adaptor/AIComputing/AICore/api/internal/svc"
|
||||
"PCM/adaptor/AIComputing/AICore/api/internal/types"
|
||||
"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"
|
||||
)
|
||||
|
||||
|
@ -29,7 +27,6 @@ func NewCreateTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Create
|
|||
}
|
||||
|
||||
func (l *CreateTaskLogic) CreateTask(req *types.ImportTaskDataReq) (resp *types.ImportTaskDataResp, err error) {
|
||||
|
||||
modelartsReq := &modelarts.ImportTaskDataReq{}
|
||||
err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: tool.Converters})
|
||||
ImportTaskDataResp, err := l.svcCtx.ModelArtsRpc.CreateTask(l.ctx, modelartsReq)
|
||||
|
@ -39,12 +36,6 @@ func (l *CreateTaskLogic) CreateTask(req *types.ImportTaskDataReq) (resp *types.
|
|||
resp = &types.ImportTaskDataResp{}
|
||||
|
||||
err = copier.CopyWithOption(&resp, &ImportTaskDataResp, copier.Option{Converters: tool.Converters})
|
||||
/*if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i := range resp.DataSet {
|
||||
resp.DataSet[i]. = "modelarts"
|
||||
}*/
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
|
|
@ -14,21 +14,21 @@ import (
|
|||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ListTrainingJobsreqLogic struct {
|
||||
type GetListTrainingJobsLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewListTrainingJobsreqLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListTrainingJobsreqLogic {
|
||||
return &ListTrainingJobsreqLogic{
|
||||
func NewGetListTrainingJobsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetListTrainingJobsLogic {
|
||||
return &GetListTrainingJobsLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *ListTrainingJobsreqLogic) ListTrainingJobsreq(req *types.ListTrainingJobsreq) (resp *types.ListTrainingJobsresp, err error) {
|
||||
func (l *GetListTrainingJobsLogic) GetListTrainingJobs(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)
|
Loading…
Reference in New Issue