Browse Source

updated getdeployinstance logic

pull/462/head
tzwang 7 months ago
parent
commit
7ed4e56ecd
2 changed files with 19 additions and 7 deletions
  1. +4
    -6
      internal/handler/inference/getdeployinstancehandler.go
  2. +15
    -1
      internal/logic/inference/getdeployinstancelogic.go

+ 4
- 6
internal/handler/inference/getdeployinstancehandler.go View File

@@ -1,6 +1,7 @@
package inference

import (
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
"net/http"

"github.com/zeromicro/go-zero/rest/httpx"
@@ -13,16 +14,13 @@ func GetDeployInstanceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetDeployInstanceReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
result.ParamErrorResult(r, w, err)
return
}

l := inference.NewGetDeployInstanceLogic(r.Context(), svcCtx)
resp, err := l.GetDeployInstance(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
result.HttpResult(r, w, resp, err)

}
}

+ 15
- 1
internal/logic/inference/getdeployinstancelogic.go View File

@@ -2,6 +2,7 @@ package inference

import (
"context"
"strconv"

"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
@@ -24,7 +25,20 @@ func NewGetDeployInstanceLogic(ctx context.Context, svcCtx *svc.ServiceContext)
}

func (l *GetDeployInstanceLogic) GetDeployInstance(req *types.GetDeployInstanceReq) (resp *types.GetDeployInstanceResp, err error) {
// todo: add your logic here and delete this line
resp = &types.GetDeployInstanceResp{}

id, err := strconv.ParseInt(req.Id, 10, 64)
ins, err := l.svcCtx.Scheduler.AiStorages.GetInferDeployInstanceById(id)
if err != nil {
return nil, err
}

in, err := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[strconv.FormatInt(ins.AdapterId, 10)][strconv.FormatInt(ins.ClusterId, 10)].GetInferDeployInstance(l.ctx, ins.InstanceId)
if err != nil {
return nil, err
}

resp.Instance = in

return
}

Loading…
Cancel
Save