updated inference api logics
Former-commit-id: 64f183b77efd974618fc6306aa78db6dd2d1f893
This commit is contained in:
parent
5ec517690a
commit
1103e589f4
|
@ -1,6 +1,7 @@
|
||||||
package inference
|
package inference
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/rest/httpx"
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
@ -13,16 +14,12 @@ func GetDeployTasksByTypeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
var req types.GetDeployTasksByTypeReq
|
var req types.GetDeployTasksByTypeReq
|
||||||
if err := httpx.Parse(r, &req); err != nil {
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
result.ParamErrorResult(r, w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
l := inference.NewGetDeployTasksByTypeLogic(r.Context(), svcCtx)
|
l := inference.NewGetDeployTasksByTypeLogic(r.Context(), svcCtx)
|
||||||
resp, err := l.GetDeployTasksByType(&req)
|
resp, err := l.GetDeployTasksByType(&req)
|
||||||
if err != nil {
|
result.HttpResult(r, w, resp, err)
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
|
||||||
} else {
|
|
||||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package inference
|
package inference
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/rest/httpx"
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
@ -13,16 +14,13 @@ func GetRunningInstanceByTypeHandler(svcCtx *svc.ServiceContext) http.HandlerFun
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
var req types.GetRunningInstanceReq
|
var req types.GetRunningInstanceReq
|
||||||
if err := httpx.Parse(r, &req); err != nil {
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
result.ParamErrorResult(r, w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
l := inference.NewGetRunningInstanceByTypeLogic(r.Context(), svcCtx)
|
l := inference.NewGetRunningInstanceByTypeLogic(r.Context(), svcCtx)
|
||||||
resp, err := l.GetRunningInstanceByType(&req)
|
resp, err := l.GetRunningInstanceByType(&req)
|
||||||
if err != nil {
|
result.HttpResult(r, w, resp, err)
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
|
||||||
} else {
|
|
||||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package inference
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||||
|
@ -24,7 +25,17 @@ func NewGetDeployTasksByTypeLogic(ctx context.Context, svcCtx *svc.ServiceContex
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *GetDeployTasksByTypeLogic) GetDeployTasksByType(req *types.GetDeployTasksByTypeReq) (resp *types.GetDeployTasksByTypeResp, err error) {
|
func (l *GetDeployTasksByTypeLogic) GetDeployTasksByType(req *types.GetDeployTasksByTypeReq) (resp *types.GetDeployTasksByTypeResp, err error) {
|
||||||
// todo: add your logic here and delete this line
|
resp = &types.GetDeployTasksByTypeResp{}
|
||||||
|
|
||||||
return
|
list, err := l.svcCtx.Scheduler.AiStorages.GetDeployTaskListByType(req.ModelType)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(list) == 0 {
|
||||||
|
return nil, errors.New("实列不存在")
|
||||||
|
}
|
||||||
|
|
||||||
|
resp.List = list
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ func NewGetRunningInstanceByTypeLogic(ctx context.Context, svcCtx *svc.ServiceCo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *GetRunningInstanceByTypeLogic) GetRunningInstanceByType(req *types.GetRunningInstanceReq) (resp *types.GetRunningInstanceResp, err error) {
|
func (l *GetRunningInstanceByTypeLogic) GetRunningInstanceByType(req *types.GetRunningInstanceReq) (resp *types.GetRunningInstanceResp, err error) {
|
||||||
// todo: add your logic here and delete this line
|
resp = &types.GetRunningInstanceResp{}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,9 +37,9 @@ func (l *ImageInferenceLogic) ImageInfer(r *http.Request, req *types.ImageInfere
|
||||||
opt := &option.InferOption{
|
opt := &option.InferOption{
|
||||||
TaskName: req.TaskName,
|
TaskName: req.TaskName,
|
||||||
TaskDesc: req.TaskDesc,
|
TaskDesc: req.TaskDesc,
|
||||||
AdapterId: req.AdapterId,
|
//AdapterId: req.AdapterId,
|
||||||
AiClusterIds: req.AiClusterIds,
|
//AiClusterIds: req.AiClusterIds,
|
||||||
ModelName: req.ModelName,
|
//ModelName: req.ModelName,
|
||||||
ModelType: req.ModelType,
|
ModelType: req.ModelType,
|
||||||
Strategy: req.Strategy,
|
Strategy: req.Strategy,
|
||||||
StaticWeightMap: req.StaticWeightMap,
|
StaticWeightMap: req.StaticWeightMap,
|
||||||
|
|
|
@ -431,6 +431,16 @@ func (s *AiStorage) GetDeployTaskById(id int64) (*models.AiDeployInstanceTask, e
|
||||||
return &task, nil
|
return &task, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *AiStorage) GetDeployTaskListByType(modelType string) ([]*models.AiDeployInstanceTask, error) {
|
||||||
|
var tasks []*models.AiDeployInstanceTask
|
||||||
|
tx := s.DbEngin.Raw("select * from ai_deploy_instance_task where `model_type` = ?", modelType).Scan(&tasks)
|
||||||
|
if tx.Error != nil {
|
||||||
|
logx.Errorf(tx.Error.Error())
|
||||||
|
return nil, tx.Error
|
||||||
|
}
|
||||||
|
return tasks, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *AiStorage) GetAllDeployTasks() ([]*models.AiDeployInstanceTask, error) {
|
func (s *AiStorage) GetAllDeployTasks() ([]*models.AiDeployInstanceTask, error) {
|
||||||
var tasks []*models.AiDeployInstanceTask
|
var tasks []*models.AiDeployInstanceTask
|
||||||
tx := s.DbEngin.Raw("select * from ai_deploy_instance_task").Scan(&tasks)
|
tx := s.DbEngin.Raw("select * from ai_deploy_instance_task").Scan(&tasks)
|
||||||
|
|
Loading…
Reference in New Issue