diff --git a/internal/scheduler/service/updater/deployInstance.go b/internal/scheduler/service/updater/deployInstance.go index 3ffd3d86..0a51f0fe 100644 --- a/internal/scheduler/service/updater/deployInstance.go +++ b/internal/scheduler/service/updater/deployInstance.go @@ -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 + } +} diff --git a/internal/storeLink/octopus.go b/internal/storeLink/octopus.go index 290feedf..b847613e 100644 --- a/internal/storeLink/octopus.go +++ b/internal/storeLink/octopus.go @@ -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 } diff --git a/internal/storeLink/shuguangai.go b/internal/storeLink/shuguangai.go index e8ea0e51..6ad0f23c 100644 --- a/internal/storeLink/shuguangai.go +++ b/internal/storeLink/shuguangai.go @@ -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 } diff --git a/internal/storeLink/storeLink.go b/internal/storeLink/storeLink.go index ac81553a..854b46d3 100644 --- a/internal/storeLink/storeLink.go +++ b/internal/storeLink/storeLink.go @@ -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,