Former-commit-id: 59b87d86eccc625f925bd4dc96c688ba45135f77
This commit is contained in:
zhangwei 2024-06-22 17:16:31 +08:00
commit d851ec5572
7 changed files with 119 additions and 7 deletions

View File

@ -45,14 +45,25 @@ type (
}
InferenceTaskDetailReq{
aiTaskId int64 `json:"aiTaskId"`
taskId int64 `form:"taskId"`
}
InferenceTaskDetailResp{
imageName string `json:"imageName"`
result string `json:"result"`
card string `json:"card"`
clusterName string `json:"clusterName"`
InferenceResults []InferenceResult `json:"data"`
Code int32 `json:"code,omitempty"`
Msg string `json:"msg,omitempty"`
}
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"`
}
)

View File

@ -928,6 +928,9 @@ service pcm {
@handler ModelNamesByTypeHandler
get /inference/modelNames (ModelNamesReq) returns (ModelNamesResp)
@handler InferenceTaskDetailHandler
get /inference/taskDetail (InferenceTaskDetailReq) returns (InferenceTaskDetailResp)
}
@server(

View File

@ -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)
}
}
}

View File

@ -1168,6 +1168,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"),
)

View File

@ -1,6 +1,5 @@
package inference
import "C"
import (
"bytes"
"context"

View File

@ -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
}

View File

@ -5912,11 +5912,19 @@ type ImageResult struct {
}
type InferenceTaskDetailReq struct {
AiTaskId int64 `json:"aiTaskId"`
TaskId int64 `form:"taskId"`
}
type InferenceTaskDetailResp struct {
InferenceResults []InferenceResult `json:"data"`
Code int32 `json:"code,omitempty"`
Msg string `json:"msg,omitempty"`
}
type InferenceResult struct {
ImageName string `json:"imageName"`
TaskName string `json:"taskName"`
TaskAiName string `json:"taskAiName"`
Result string `json:"result"`
Card string `json:"card"`
ClusterName string `json:"clusterName"`