updated inferurl logics

Former-commit-id: 0c4ee483a0f9a247dc278e894339c339619bc96b
This commit is contained in:
tzwang 2024-07-24 17:55:33 +08:00
parent ef9cbab35d
commit a2f99bf2d0
4 changed files with 71 additions and 6 deletions

View File

@ -1 +1,33 @@
package updater
import (
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
"net/http"
"strconv"
)
//func UpdateDeployInstanceStatus(svc *svc.ServiceContext, list []*models.AiInferDeployInstance) {
//
//}
func UpdateDeployInstanceStatus(svc *svc.ServiceContext, instance *models.AiInferDeployInstance) {
amap, found := svc.Scheduler.AiService.InferenceAdapterMap[strconv.FormatInt(instance.AdapterId, 10)]
if !found {
return
}
cmap, found := amap[strconv.FormatInt(instance.ClusterId, 10)]
if !found {
return
}
h := http.Request{}
ins, err := cmap.GetInferDeployInstance(h.Context(), instance.InstanceId)
if err != nil {
return
}
instance.Status = ins.Status
err = svc.Scheduler.AiStorages.UpdateInferDeployInstance(instance)
if err != nil {
return
}
}

View File

@ -877,6 +877,7 @@ func (o *OctopusLink) GetInferUrl(ctx context.Context, option *option.InferOptio
Platform: o.platform,
PageIndex: o.pageIndex,
PageSize: o.pageSize,
SearchKey: DEPLOY_INSTANCE_PREFIEX,
}
list, err := o.octopusRpc.GetNotebookList(ctx, req)
if err != nil {
@ -885,9 +886,9 @@ func (o *OctopusLink) GetInferUrl(ctx context.Context, option *option.InferOptio
var imageUrls []*inference.InferUrl
for _, notebook := range list.Payload.GetNotebooks() {
if strings.Contains(notebook.AlgorithmName, option.ModelName) && notebook.Status == "running" {
if strings.Contains(notebook.Desc, option.ModelName) && notebook.Status == "running" {
url := strings.Replace(notebook.Tasks[0].Url, FORWARD_SLASH, "", -1)
names := strings.Split(notebook.AlgorithmName, UNDERSCORE)
names := strings.Split(notebook.Desc, FORWARD_SLASH)
imageUrl := &inference.InferUrl{
Url: DOMAIN + url,
Card: names[2],
@ -955,5 +956,23 @@ func (o *OctopusLink) StopInferDeployInstance(ctx context.Context, id string) bo
}
func (o *OctopusLink) GetInferDeployInstance(ctx context.Context, id string) (*inference.DeployInstance, error) {
return nil, nil
ins := &inference.DeployInstance{}
req := &octopus.GetNotebookReq{
Platform: o.platform,
Id: id,
}
resp, err := o.octopusRpc.GetNotebook(ctx, req)
if err != nil {
return nil, err
}
if resp.Payload == nil {
return nil, errors.New("instance does not exist")
}
ins.InstanceName = resp.Payload.Notebook.Name
ins.InstanceId = resp.Payload.Notebook.Id
ins.ClusterName = o.platform
ins.Status = resp.Payload.Notebook.Status
return ins, nil
}

View File

@ -851,5 +851,19 @@ func (s *ShuguangAi) StopInferDeployInstance(ctx context.Context, id string) boo
}
func (s *ShuguangAi) GetInferDeployInstance(ctx context.Context, id string) (*inference.DeployInstance, error) {
return nil, nil
ins := &inference.DeployInstance{}
req := &hpcAC.GetInstanceServiceDetailReq{
Id: id,
}
resp, err := s.aCRpc.GetInstanceServiceDetail(ctx, req)
if err != nil || resp.Code != "0" {
return nil, err
}
ins.InstanceName = resp.Data.InstanceServiceName
ins.InstanceId = resp.Data.Id
ins.ClusterName = s.platform
ins.Status = resp.Data.Status
ins.InferCard = DCU
ins.CreatedTime = resp.Data.CreateTime
return ins, nil
}

View File

@ -78,8 +78,8 @@ var (
4: "制作失败",
}
ModelTypeMap = map[string][]string{
"image_recognition": {"imagenet_resnet50"},
"text_to_text": {"chatGLM_6B"},
"image_classification": {"imagenet_resnet50"},
"text_to_text": {"chatGLM_6B"},
}
AITYPE = map[string]string{
"1": OCTOPUS,