Merge branch 'master' of https://gitlink.org.cn/JointCloud/pcm-coordinator
Former-commit-id: 59b87d86eccc625f925bd4dc96c688ba45135f77
This commit is contained in:
commit
d851ec5572
|
@ -45,14 +45,25 @@ type (
|
||||||
}
|
}
|
||||||
|
|
||||||
InferenceTaskDetailReq{
|
InferenceTaskDetailReq{
|
||||||
aiTaskId int64 `json:"aiTaskId"`
|
taskId int64 `form:"taskId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
InferenceTaskDetailResp{
|
InferenceTaskDetailResp{
|
||||||
imageName string `json:"imageName"`
|
InferenceResults []InferenceResult `json:"data"`
|
||||||
result string `json:"result"`
|
Code int32 `json:"code,omitempty"`
|
||||||
card string `json:"card"`
|
Msg string `json:"msg,omitempty"`
|
||||||
clusterName string `json:"clusterName"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InferenceResult{
|
||||||
|
imageName string `json:"imageName"`
|
||||||
|
TaskName string `json:"taskName"`
|
||||||
|
TaskAiName string `json:"taskAiName"`
|
||||||
|
result string `json:"result"`
|
||||||
|
card string `json:"card"`
|
||||||
|
clusterName string `json:"clusterName"`
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -928,6 +928,9 @@ service pcm {
|
||||||
|
|
||||||
@handler ModelNamesByTypeHandler
|
@handler ModelNamesByTypeHandler
|
||||||
get /inference/modelNames (ModelNamesReq) returns (ModelNamesResp)
|
get /inference/modelNames (ModelNamesReq) returns (ModelNamesResp)
|
||||||
|
|
||||||
|
@handler InferenceTaskDetailHandler
|
||||||
|
get /inference/taskDetail (InferenceTaskDetailReq) returns (InferenceTaskDetailResp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@server(
|
@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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1168,6 +1168,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||||
Path: "/inference/modelNames",
|
Path: "/inference/modelNames",
|
||||||
Handler: inference.ModelNamesByTypeHandler(serverCtx),
|
Handler: inference.ModelNamesByTypeHandler(serverCtx),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodGet,
|
||||||
|
Path: "/inference/taskDetail",
|
||||||
|
Handler: inference.InferenceTaskDetailHandler(serverCtx),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
rest.WithPrefix("/pcm/v1"),
|
rest.WithPrefix("/pcm/v1"),
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package inference
|
package inference
|
||||||
|
|
||||||
import "C"
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
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("task_id", req.TaskId).Scan(&taskAiSub)
|
||||||
|
|
||||||
|
if len(taskAiSub) != 0 {
|
||||||
|
for _, sub := range taskAiSub {
|
||||||
|
result := types.InferenceResult{
|
||||||
|
TaskName: sub.TaskName,
|
||||||
|
TaskAiName: sub.TaskAiName,
|
||||||
|
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
|
||||||
|
|
||||||
|
}
|
|
@ -5912,11 +5912,19 @@ type ImageResult struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type InferenceTaskDetailReq struct {
|
type InferenceTaskDetailReq struct {
|
||||||
AiTaskId int64 `json:"aiTaskId"`
|
TaskId int64 `form:"taskId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type InferenceTaskDetailResp struct {
|
type InferenceTaskDetailResp struct {
|
||||||
|
InferenceResults []InferenceResult `json:"data"`
|
||||||
|
Code int32 `json:"code,omitempty"`
|
||||||
|
Msg string `json:"msg,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type InferenceResult struct {
|
||||||
ImageName string `json:"imageName"`
|
ImageName string `json:"imageName"`
|
||||||
|
TaskName string `json:"taskName"`
|
||||||
|
TaskAiName string `json:"taskAiName"`
|
||||||
Result string `json:"result"`
|
Result string `json:"result"`
|
||||||
Card string `json:"card"`
|
Card string `json:"card"`
|
||||||
ClusterName string `json:"clusterName"`
|
ClusterName string `json:"clusterName"`
|
||||||
|
|
Loading…
Reference in New Issue