updated inference apis
Former-commit-id: d907a498a213be552236b306f48903942d63078d
This commit is contained in:
parent
46e3bc064f
commit
5ec517690a
|
@ -92,7 +92,7 @@ type (
|
|||
AiClusterIds []string `form:"aiClusterIds"`
|
||||
}
|
||||
TextToImageInferenceResp{
|
||||
Result []byte
|
||||
Result []byte `json:"result"`
|
||||
}
|
||||
|
||||
/******************Deploy instance*************************/
|
||||
|
@ -156,20 +156,12 @@ type (
|
|||
|
||||
}
|
||||
|
||||
GetDeployTasksReq {
|
||||
PageInfo
|
||||
}
|
||||
|
||||
GetDeployTasksResp {
|
||||
PageResult
|
||||
}
|
||||
|
||||
GetRunningInstanceReq {
|
||||
AdapterIds []string `form:"adapterIds"`
|
||||
ModelType string `form:"modelType"`
|
||||
}
|
||||
GetRunningInstanceResp {
|
||||
List interface{} `json:"list,omitempty"`
|
||||
List interface{} `json:"list"`
|
||||
}
|
||||
|
||||
GetDeployTasksByTypeReq {
|
||||
|
@ -177,6 +169,6 @@ type (
|
|||
}
|
||||
|
||||
GetDeployTasksByTypeResp {
|
||||
List interface{} `json:"list,omitempty"`
|
||||
List interface{} `json:"list"`
|
||||
}
|
||||
)
|
||||
|
|
|
@ -966,11 +966,11 @@ service pcm {
|
|||
@handler StopAllByDeployTaskId
|
||||
post /inference/stopAll (StopAllByDeployTaskIdReq) returns (StopAllByDeployTaskIdResp)
|
||||
|
||||
@handler GetDeployTasks
|
||||
get /inference/getDeployTasks (GetDeployTasksReq) returns (GetDeployTasksResp)
|
||||
@handler GetRunningInstanceByType
|
||||
get /inference/getInstanceByType (GetRunningInstanceReq) returns (GetRunningInstanceResp)
|
||||
|
||||
@handler GetRunningInstanceByModel
|
||||
get /inference/getInstanceByModel (GetRunningInstanceReq) returns (GetRunningInstanceResp)
|
||||
@handler GetDeployTasksByType
|
||||
get /inference/getDeployTasksByType (GetDeployTasksByTypeReq) returns (GetDeployTasksByTypeResp)
|
||||
}
|
||||
|
||||
@server(
|
||||
|
|
|
@ -9,16 +9,16 @@ import (
|
|||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
)
|
||||
|
||||
func GetDeployTasksHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
func GetDeployTasksByTypeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.GetDeployTasksReq
|
||||
var req types.GetDeployTasksByTypeReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := inference.NewGetDeployTasksLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetDeployTasks(&req)
|
||||
l := inference.NewGetDeployTasksByTypeLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetDeployTasksByType(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
|
@ -1,7 +1,6 @@
|
|||
package inference
|
||||
|
||||
import (
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
@ -10,16 +9,20 @@ import (
|
|||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
)
|
||||
|
||||
func GetRunningInstanceByModelHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
func GetRunningInstanceByTypeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.GetRunningInstanceReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := inference.NewGetRunningInstanceByModelLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetRunningInstanceByModel(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
l := inference.NewGetRunningInstanceByTypeLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetRunningInstanceByType(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1225,13 +1225,13 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/inference/getDeployTasks",
|
||||
Handler: inference.GetDeployTasksHandler(serverCtx),
|
||||
Path: "/inference/getInstanceByType",
|
||||
Handler: inference.GetRunningInstanceByTypeHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/inference/getInstanceByModel",
|
||||
Handler: inference.GetRunningInstanceByModelHandler(serverCtx),
|
||||
Path: "/inference/getDeployTasksByType",
|
||||
Handler: inference.GetDeployTasksByTypeHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithPrefix("/pcm/v1"),
|
||||
|
|
|
@ -9,21 +9,21 @@ import (
|
|||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetDeployTasksLogic struct {
|
||||
type GetDeployTasksByTypeLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetDeployTasksLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDeployTasksLogic {
|
||||
return &GetDeployTasksLogic{
|
||||
func NewGetDeployTasksByTypeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDeployTasksByTypeLogic {
|
||||
return &GetDeployTasksByTypeLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetDeployTasksLogic) GetDeployTasks(req *types.GetDeployTasksReq) (resp *types.GetDeployTasksResp, err error) {
|
||||
func (l *GetDeployTasksByTypeLogic) GetDeployTasksByType(req *types.GetDeployTasksByTypeReq) (resp *types.GetDeployTasksByTypeResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return
|
|
@ -1,30 +0,0 @@
|
|||
package inference
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetRunningInstanceByModelLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetRunningInstanceByModelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetRunningInstanceByModelLogic {
|
||||
return &GetRunningInstanceByModelLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetRunningInstanceByModelLogic) GetRunningInstanceByModel(req *types.GetRunningInstanceReq) (resp *types.GetRunningInstanceResp, err error) {
|
||||
resp = &types.GetRunningInstanceResp{}
|
||||
|
||||
return
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package inference
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetRunningInstanceByTypeLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetRunningInstanceByTypeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetRunningInstanceByTypeLogic {
|
||||
return &GetRunningInstanceByTypeLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetRunningInstanceByTypeLogic) GetRunningInstanceByType(req *types.GetRunningInstanceReq) (resp *types.GetRunningInstanceResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return
|
||||
}
|
|
@ -5904,6 +5904,19 @@ type Category struct {
|
|||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type DeployInstance struct {
|
||||
InstanceId string `json:"instanceId"`
|
||||
InstanceName string `json:"instanceName"`
|
||||
AdapterId string `json:"adapterId"`
|
||||
AdapterName string `json:"adapterName"`
|
||||
ClusterId string `json:"clusterId"`
|
||||
ClusterName string `json:"clusterName"`
|
||||
ModelName string `json:"modelName"`
|
||||
ModelType string `json:"modelType"`
|
||||
InferCard string `json:"inferCard"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
type ModelTypesResp struct {
|
||||
ModelTypes []string `json:"types"`
|
||||
}
|
||||
|
@ -5917,20 +5930,13 @@ type ModelNamesResp struct {
|
|||
}
|
||||
|
||||
type ImageInferenceReq struct {
|
||||
TaskName string `form:"taskName"`
|
||||
TaskDesc string `form:"taskDesc"`
|
||||
ModelName string `form:"modelName"`
|
||||
ModelType string `form:"modelType"`
|
||||
AdapterId string `form:"adapterId"`
|
||||
AiClusterIds []string `form:"aiClusterIds,optional"`
|
||||
ResourceType string `form:"resourceType,optional"`
|
||||
ComputeCard string `form:"card,optional"`
|
||||
Strategy string `form:"strategy"`
|
||||
StaticWeightMap map[string]int32 `form:"staticWeightMap,optional"`
|
||||
Params []string `form:"params,optional"`
|
||||
Envs []string `form:"envs,optional"`
|
||||
Cmd string `form:"cmd,optional"`
|
||||
Replica int32 `form:"replicas,optional"`
|
||||
TaskName string `json:"taskName"`
|
||||
TaskDesc string `json:"taskDesc"`
|
||||
ModelType string `json:"modelType"`
|
||||
Instances []DeployInstance `json:"instances"`
|
||||
Strategy string `json:"strategy,,optional"`
|
||||
StaticWeightMap map[string]int32 `json:"staticWeightMap,optional"`
|
||||
Replica int32 `json:"replicas,optional"`
|
||||
}
|
||||
|
||||
type ImageInferenceResp struct {
|
||||
|
@ -5976,6 +5982,18 @@ type TextToTextInferenceReq struct {
|
|||
type TextToTextInferenceResp struct {
|
||||
}
|
||||
|
||||
type TextToImageInferenceReq struct {
|
||||
TaskName string `form:"taskName"`
|
||||
TaskDesc string `form:"taskDesc"`
|
||||
ModelName string `form:"modelName"`
|
||||
ModelType string `form:"modelType"`
|
||||
AiClusterIds []string `form:"aiClusterIds"`
|
||||
}
|
||||
|
||||
type TextToImageInferenceResp struct {
|
||||
Result []byte `json:"result"`
|
||||
}
|
||||
|
||||
type DeployInstanceListReq struct {
|
||||
PageInfo
|
||||
}
|
||||
|
@ -6034,19 +6052,19 @@ type StopAllByDeployTaskIdReq struct {
|
|||
type StopAllByDeployTaskIdResp struct {
|
||||
}
|
||||
|
||||
type GetDeployTasksReq struct {
|
||||
PageInfo
|
||||
}
|
||||
|
||||
type GetDeployTasksResp struct {
|
||||
PageResult
|
||||
}
|
||||
|
||||
type GetRunningInstanceReq struct {
|
||||
ModelType string `path:"modelType"`
|
||||
ModelName string `path:"modelName"`
|
||||
AdapterIds []string `form:"adapterIds"`
|
||||
ModelType string `form:"modelType"`
|
||||
}
|
||||
|
||||
type GetRunningInstanceResp struct {
|
||||
List interface{} `json:"list,omitempty"`
|
||||
List interface{} `json:"list"`
|
||||
}
|
||||
|
||||
type GetDeployTasksByTypeReq struct {
|
||||
ModelType string `form:"modelType"`
|
||||
}
|
||||
|
||||
type GetDeployTasksByTypeResp struct {
|
||||
List interface{} `json:"list"`
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue