Browse Source

updated inferurl logics

Former-commit-id: 0c4ee483a0
pull/271/head
tzwang 1 year ago
parent
commit
a2f99bf2d0
4 changed files with 71 additions and 6 deletions
  1. +32
    -0
      internal/scheduler/service/updater/deployInstance.go
  2. +22
    -3
      internal/storeLink/octopus.go
  3. +15
    -1
      internal/storeLink/shuguangai.go
  4. +2
    -2
      internal/storeLink/storeLink.go

+ 32
- 0
internal/scheduler/service/updater/deployInstance.go 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
}
}

+ 22
- 3
internal/storeLink/octopus.go 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
}

+ 15
- 1
internal/storeLink/shuguangai.go 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
}

+ 2
- 2
internal/storeLink/storeLink.go 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,


Loading…
Cancel
Save