updated inferurl logics
Former-commit-id: 0c4ee483a0f9a247dc278e894339c339619bc96b
This commit is contained in:
parent
ef9cbab35d
commit
a2f99bf2d0
|
@ -1 +1,33 @@
|
||||||
package updater
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -877,6 +877,7 @@ func (o *OctopusLink) GetInferUrl(ctx context.Context, option *option.InferOptio
|
||||||
Platform: o.platform,
|
Platform: o.platform,
|
||||||
PageIndex: o.pageIndex,
|
PageIndex: o.pageIndex,
|
||||||
PageSize: o.pageSize,
|
PageSize: o.pageSize,
|
||||||
|
SearchKey: DEPLOY_INSTANCE_PREFIEX,
|
||||||
}
|
}
|
||||||
list, err := o.octopusRpc.GetNotebookList(ctx, req)
|
list, err := o.octopusRpc.GetNotebookList(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -885,9 +886,9 @@ func (o *OctopusLink) GetInferUrl(ctx context.Context, option *option.InferOptio
|
||||||
|
|
||||||
var imageUrls []*inference.InferUrl
|
var imageUrls []*inference.InferUrl
|
||||||
for _, notebook := range list.Payload.GetNotebooks() {
|
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)
|
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{
|
imageUrl := &inference.InferUrl{
|
||||||
Url: DOMAIN + url,
|
Url: DOMAIN + url,
|
||||||
Card: names[2],
|
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) {
|
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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) {
|
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
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,8 +78,8 @@ var (
|
||||||
4: "制作失败",
|
4: "制作失败",
|
||||||
}
|
}
|
||||||
ModelTypeMap = map[string][]string{
|
ModelTypeMap = map[string][]string{
|
||||||
"image_recognition": {"imagenet_resnet50"},
|
"image_classification": {"imagenet_resnet50"},
|
||||||
"text_to_text": {"chatGLM_6B"},
|
"text_to_text": {"chatGLM_6B"},
|
||||||
}
|
}
|
||||||
AITYPE = map[string]string{
|
AITYPE = map[string]string{
|
||||||
"1": OCTOPUS,
|
"1": OCTOPUS,
|
||||||
|
|
Loading…
Reference in New Issue