forked from JointCloud/pcm-coordinator
59 lines
1.4 KiB
Go
59 lines
1.4 KiB
Go
package inference
|
|
|
|
import (
|
|
"context"
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
|
|
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/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
|
|
|
|
}
|