task ai sub
Former-commit-id: 31fce577fe3f873facd5bde998a56c5d9fe0041f
This commit is contained in:
parent
5757cd47a3
commit
0e11cbd5f2
|
@ -45,14 +45,21 @@ type (
|
|||
}
|
||||
|
||||
InferenceTaskDetailReq{
|
||||
aiTaskId int64 `json:"aiTaskId"`
|
||||
aiTaskId int64 `form:"aiTaskId"`
|
||||
}
|
||||
|
||||
InferenceTaskDetailResp{
|
||||
imageName string `json:"imageName"`
|
||||
result string `json:"result"`
|
||||
card string `json:"card"`
|
||||
clusterName string `json:"clusterName"`
|
||||
InferenceResults []InferenceResult `json:"inferenceResults"`
|
||||
Code int32 `json:"code,omitempty"`
|
||||
Msg string `json:"msg,omitempty"`
|
||||
|
||||
}
|
||||
|
||||
InferenceResult{
|
||||
imageName string `json:"imageName"`
|
||||
result string `json:"result"`
|
||||
card string `json:"card"`
|
||||
clusterName string `json:"clusterName"`
|
||||
}
|
||||
|
||||
)
|
||||
|
|
|
@ -915,6 +915,9 @@ service pcm {
|
|||
|
||||
@handler ModelNamesByTypeHandler
|
||||
get /inference/modelNames (ModelNamesReq) returns (ModelNamesResp)
|
||||
|
||||
@handler InferenceTaskDetailHandler
|
||||
get /inference/taskDetail (InferenceTaskDetailReq) returns (InferenceTaskDetailResp)
|
||||
}
|
||||
|
||||
@server(
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package inference
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/inference"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||
)
|
||||
|
||||
func InferenceTaskDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.InferenceTaskDetailReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := inference.NewInferenceTaskDetailLogic(r.Context(), svcCtx)
|
||||
resp, err := l.InferenceTaskDetail(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1153,6 +1153,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||
Path: "/inference/modelNames",
|
||||
Handler: inference.ModelNamesByTypeHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/inference/taskDetail",
|
||||
Handler: inference.InferenceTaskDetailHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithPrefix("/pcm/v1"),
|
||||
)
|
||||
|
|
|
@ -43,9 +43,10 @@ func NewImageInferenceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Im
|
|||
}
|
||||
}
|
||||
|
||||
func (l *ImageInferenceLogic) ImageInference(req *types.ImageInferenceReq) (resp *types.ImageInferenceResp, err error) {
|
||||
return nil, nil
|
||||
}
|
||||
//
|
||||
//func (l *ImageInferenceLogic) ImageInference(req *types.ImageInferenceReq) (resp *types.ImageInferenceResp, err error) {
|
||||
// return nil, nil
|
||||
//}
|
||||
|
||||
func (l *ImageInferenceLogic) ImageInfer(r *http.Request, req *types.ImageInferenceReq) (resp *types.ImageInferenceResp, err error) {
|
||||
resp = &types.ImageInferenceResp{}
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
package inference
|
||||
|
||||
import (
|
||||
"context"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
|
||||
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type InferenceTaskDetailLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewInferenceTaskDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InferenceTaskDetailLogic {
|
||||
return &InferenceTaskDetailLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *InferenceTaskDetailLogic) InferenceTaskDetail(req *types.InferenceTaskDetailReq) (resp *types.InferenceTaskDetailResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
var taskAiSub []*models.TaskAiSub
|
||||
var results []types.InferenceResult
|
||||
l.svcCtx.DbEngin.Table("task_ai_sub").Where("id", req.AiTaskId).Scan(&taskAiSub)
|
||||
|
||||
if len(taskAiSub) != 0 {
|
||||
for _, sub := range taskAiSub {
|
||||
result := types.InferenceResult{
|
||||
ImageName: sub.ImageName,
|
||||
Result: sub.Result,
|
||||
Card: sub.Card,
|
||||
ClusterName: sub.ClusterName,
|
||||
}
|
||||
results = append(results, result)
|
||||
}
|
||||
} else {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
resp = &types.InferenceTaskDetailResp{
|
||||
Code: 200,
|
||||
Msg: "success",
|
||||
InferenceResults: results,
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
|
@ -5921,10 +5921,16 @@ type ImageResult struct {
|
|||
}
|
||||
|
||||
type InferenceTaskDetailReq struct {
|
||||
AiTaskId int64 `json:"aiTaskId"`
|
||||
AiTaskId int64 `form:"aiTaskId"`
|
||||
}
|
||||
|
||||
type InferenceTaskDetailResp struct {
|
||||
InferenceResults []InferenceResult `json:"inferenceResults"`
|
||||
Code int32 `json:"code,omitempty"`
|
||||
Msg string `json:"msg,omitempty"`
|
||||
}
|
||||
|
||||
type InferenceResult struct {
|
||||
ImageName string `json:"imageName"`
|
||||
Result string `json:"result"`
|
||||
Card string `json:"card"`
|
||||
|
|
Loading…
Reference in New Issue