added imageinference api

Former-commit-id: 8bf23cca01d6b82ea5fa1f1078d608e83b206362
This commit is contained in:
tzwang 2024-06-19 16:06:47 +08:00
parent 4181adbbf2
commit b4b93d2c09
6 changed files with 132 additions and 0 deletions

View File

@ -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"`
// }
)

View File

@ -10,6 +10,7 @@ import (
"storelink/pcm-storelink.api"
"schedule/pcm-schedule.api"
"monitoring/pcm-monitoring.api"
"inference/inference.api"
)
info(
@ -901,6 +902,15 @@ service pcm {
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(
prefix: pcm/v1
group: dictionary

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

View File

@ -10,6 +10,7 @@ import (
core "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler/core"
dictionary "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler/dictionary"
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"
schedule "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/handler/schedule"
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"),
)
server.AddRoutes(
[]rest.Route{
{
Method: http.MethodPost,
Path: "/inference/images",
Handler: inference.ImageInferenceHandler(serverCtx),
},
},
rest.WithPrefix("/pcm/v1"),
)
server.AddRoutes(
[]rest.Route{
{

View File

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

View File

@ -5878,3 +5878,15 @@ type Link struct {
type Category struct {
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 {
}