added imageinference api
Former-commit-id: 8bf23cca01d6b82ea5fa1f1078d608e83b206362
This commit is contained in:
parent
4181adbbf2
commit
b4b93d2c09
|
@ -0,0 +1,40 @@
|
||||||
|
syntax = "v1"
|
||||||
|
|
||||||
|
type (
|
||||||
|
InferOption {
|
||||||
|
TaskName string `json:"taskName"`
|
||||||
|
Images []string `form:"images"`
|
||||||
|
// AdapterId string `json:"adapterId"`
|
||||||
|
// AiClusterIds []string `json:"aiClusterIds"`
|
||||||
|
// ResourceType string `json:"resourceType"`
|
||||||
|
// ComputeCard string `json:"card"`
|
||||||
|
// Tops float64 `json:"Tops,optional"`
|
||||||
|
// TaskType string `json:"taskType"`
|
||||||
|
// Datasets string `json:"datasets"`
|
||||||
|
// Algorithm string `json:"algorithm"`
|
||||||
|
// Strategy string `json:"strategy"`
|
||||||
|
// StaticWeightMap map[string]int32 `json:"staticWeightMap,optional"`
|
||||||
|
// Params []string `json:"params,optional"`
|
||||||
|
// Envs []string `json:"envs,optional"`
|
||||||
|
// Cmd string `json:"cmd,optional"`
|
||||||
|
// Replica int32 `json:"replicas"`
|
||||||
|
}
|
||||||
|
/******************image inference*************************/
|
||||||
|
|
||||||
|
ImageInferenceReq {
|
||||||
|
InferOption *InferOption `json:"inferOption,optional"`
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageInferenceResp {
|
||||||
|
}
|
||||||
|
|
||||||
|
// InferResult {
|
||||||
|
// ClusterId string `json:"clusterId"`
|
||||||
|
// TaskId string `json:"taskId"`
|
||||||
|
// Card string `json:"card"`
|
||||||
|
// Strategy string `json:"strategy"`
|
||||||
|
// JobId string `json:"jobId"`
|
||||||
|
// Replica int32 `json:"replica"`
|
||||||
|
// Msg string `json:"msg"`
|
||||||
|
// }
|
||||||
|
)
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"storelink/pcm-storelink.api"
|
"storelink/pcm-storelink.api"
|
||||||
"schedule/pcm-schedule.api"
|
"schedule/pcm-schedule.api"
|
||||||
"monitoring/pcm-monitoring.api"
|
"monitoring/pcm-monitoring.api"
|
||||||
|
"inference/inference.api"
|
||||||
)
|
)
|
||||||
|
|
||||||
info(
|
info(
|
||||||
|
@ -901,6 +902,15 @@ service pcm {
|
||||||
get /schedule/getClusterBalanceById/:adapterId/:clusterId (GetClusterBalanceByIdReq) returns (GetClusterBalanceByIdResp)
|
get /schedule/getClusterBalanceById/:adapterId/:clusterId (GetClusterBalanceByIdReq) returns (GetClusterBalanceByIdResp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@server(
|
||||||
|
prefix: pcm/v1
|
||||||
|
group: inference
|
||||||
|
)
|
||||||
|
service pcm {
|
||||||
|
@handler ImageInferenceHandler
|
||||||
|
post /inference/images (ImageInferenceReq) returns (ImageInferenceResp)
|
||||||
|
}
|
||||||
|
|
||||||
@server(
|
@server(
|
||||||
prefix: pcm/v1
|
prefix: pcm/v1
|
||||||
group: dictionary
|
group: dictionary
|
||||||
|
|
|
@ -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 ImageInferenceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.ImageInferenceReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := inference.NewImageInferenceLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.ImageInference(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,6 +10,7 @@ import (
|
||||||
core "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler/core"
|
core "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler/core"
|
||||||
dictionary "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler/dictionary"
|
dictionary "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler/dictionary"
|
||||||
hpc "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler/hpc"
|
hpc "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler/hpc"
|
||||||
|
inference "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler/inference"
|
||||||
monitoring "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler/monitoring"
|
monitoring "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler/monitoring"
|
||||||
schedule "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler/schedule"
|
schedule "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler/schedule"
|
||||||
storage "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler/storage"
|
storage "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler/storage"
|
||||||
|
@ -1135,6 +1136,17 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||||
rest.WithPrefix("/pcm/v1"),
|
rest.WithPrefix("/pcm/v1"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
server.AddRoutes(
|
||||||
|
[]rest.Route{
|
||||||
|
{
|
||||||
|
Method: http.MethodPost,
|
||||||
|
Path: "/inference/images",
|
||||||
|
Handler: inference.ImageInferenceHandler(serverCtx),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rest.WithPrefix("/pcm/v1"),
|
||||||
|
)
|
||||||
|
|
||||||
server.AddRoutes(
|
server.AddRoutes(
|
||||||
[]rest.Route{
|
[]rest.Route{
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
package inference
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"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 ImageInferenceLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewImageInferenceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ImageInferenceLogic {
|
||||||
|
return &ImageInferenceLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *ImageInferenceLogic) ImageInference(req *types.ImageInferenceReq) (resp *types.ImageInferenceResp, err error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
|
@ -5878,3 +5878,15 @@ type Link struct {
|
||||||
type Category struct {
|
type Category struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type InferOption struct {
|
||||||
|
TaskName string `json:"taskName"`
|
||||||
|
Images []string `form:"images"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ImageInferenceReq struct {
|
||||||
|
InferOption *InferOption `json:"inferOption,optional"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ImageInferenceResp struct {
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue