updated imageinference logics
Former-commit-id: 99ca94792385319288589344217693282e5d3eff
This commit is contained in:
parent
ef72b1014f
commit
5eda8232b1
|
@ -46,11 +46,14 @@ func (l *ImageInferenceLogic) ImageInfer(r *http.Request, req *types.ImageInfere
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if instance == nil {
|
||||
return nil, errors.New("instance is empty ")
|
||||
}
|
||||
instanceList = append(instanceList, instance)
|
||||
}
|
||||
|
||||
if len(instanceList) == 0 {
|
||||
return nil, errors.New("instances are empty")
|
||||
return nil, errors.New("instanceList are empty")
|
||||
}
|
||||
|
||||
// process uploaded images
|
||||
|
@ -110,7 +113,7 @@ func (l *ImageInferenceLogic) ImageInfer(r *http.Request, req *types.ImageInfere
|
|||
}
|
||||
|
||||
// set strategy
|
||||
if opt.Strategy != "" {
|
||||
if opt.Strategy == "" {
|
||||
return nil, errors.New("strategy is empty")
|
||||
}
|
||||
|
||||
|
|
|
@ -413,23 +413,23 @@ func (s *AiStorage) UpdateInferDeployInstance(instance *models.AiInferDeployInst
|
|||
}
|
||||
|
||||
func (s *AiStorage) GetInferDeployInstanceById(id int64) (*models.AiInferDeployInstance, error) {
|
||||
var deployIns models.AiInferDeployInstance
|
||||
var deployIns *models.AiInferDeployInstance
|
||||
tx := s.DbEngin.Raw("select * from ai_infer_deploy_instance where `id` = ?", id).Scan(&deployIns)
|
||||
if tx.Error != nil {
|
||||
logx.Errorf(tx.Error.Error())
|
||||
return nil, tx.Error
|
||||
}
|
||||
return &deployIns, nil
|
||||
return deployIns, nil
|
||||
}
|
||||
|
||||
func (s *AiStorage) GetDeployTaskById(id int64) (*models.AiDeployInstanceTask, error) {
|
||||
var task models.AiDeployInstanceTask
|
||||
var task *models.AiDeployInstanceTask
|
||||
tx := s.DbEngin.Raw("select * from ai_deploy_instance_task where `id` = ?", id).Scan(&task)
|
||||
if tx.Error != nil {
|
||||
logx.Errorf(tx.Error.Error())
|
||||
return nil, tx.Error
|
||||
}
|
||||
return &task, nil
|
||||
return task, nil
|
||||
}
|
||||
|
||||
func (s *AiStorage) GetDeployTaskListByType(modelType string) ([]*models.AiDeployInstanceTask, error) {
|
||||
|
|
|
@ -198,6 +198,8 @@ func (i *ImageInference) filterClusters() ([]*FilteredCluster, error) {
|
|||
for _, cluster := range i.clusters {
|
||||
var inferurls []*inference.InferUrl
|
||||
var clustertype string
|
||||
var clusterName string
|
||||
|
||||
for _, instance := range i.instances {
|
||||
clusterId := strconv.FormatInt(instance.ClusterId, 10)
|
||||
adapterId := strconv.FormatInt(instance.AdapterId, 10)
|
||||
|
@ -214,6 +216,7 @@ func (i *ImageInference) filterClusters() ([]*FilteredCluster, error) {
|
|||
inferurls = append(inferurls, &url)
|
||||
|
||||
clustertype = deployInstance.ClusterType
|
||||
clusterName = deployInstance.ClusterName
|
||||
}
|
||||
}
|
||||
if len(inferurls) == 0 {
|
||||
|
@ -224,7 +227,8 @@ func (i *ImageInference) filterClusters() ([]*FilteredCluster, error) {
|
|||
|
||||
var f FilteredCluster
|
||||
f.urls = inferurls
|
||||
f.clusterName = cluster.ClusterName
|
||||
f.clusterId = cluster.ClusterId
|
||||
f.clusterName = clusterName
|
||||
f.clusterType = clustertype
|
||||
f.imageNum = cluster.Replicas
|
||||
cs = append(cs, &f)
|
||||
|
@ -448,12 +452,19 @@ func (i *ImageInference) saveAiSubTasks(id int64, aiTaskList []*models.TaskAi, c
|
|||
}
|
||||
|
||||
func getInferResult(url string, file multipart.File, fileName string, clusterId string, clusterType string, inferAdapter map[string]map[string]inference.ICluster, adapterId string) (string, error) {
|
||||
inferMap := inferAdapter[adapterId]
|
||||
adapter, found := inferAdapter[adapterId]
|
||||
if !found {
|
||||
return "", errors.New("adapterId not found")
|
||||
}
|
||||
iCluster, found := adapter[clusterId]
|
||||
if !found {
|
||||
return "", errors.New("clusterId not found")
|
||||
}
|
||||
|
||||
switch clusterType {
|
||||
case storeLink.TYPE_OCTOPUS:
|
||||
r := http.Request{}
|
||||
result, err := inferMap[clusterId].GetInferResult(r.Context(), url, file, fileName)
|
||||
result, err := iCluster.GetInferResult(r.Context(), url, file, fileName)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
@ -1158,12 +1158,21 @@ func (o *OctopusLink) GetInferDeployInstance(ctx context.Context, id string) (*i
|
|||
url := strings.Replace(resp.Payload.Notebook.Tasks[0].Url, FORWARD_SLASH, "", -1)
|
||||
inferUrl := DOMAIN + url
|
||||
|
||||
var card string
|
||||
if resp.Payload.Notebook.Desc != "" {
|
||||
str := strings.Split(resp.Payload.Notebook.Desc, FORWARD_SLASH)
|
||||
if len(str) == 3 {
|
||||
card = str[2]
|
||||
}
|
||||
}
|
||||
|
||||
ins.InstanceName = resp.Payload.Notebook.Name
|
||||
ins.InstanceId = resp.Payload.Notebook.Id
|
||||
ins.ClusterName = o.platform
|
||||
ins.Status = resp.Payload.Notebook.Status
|
||||
ins.ClusterType = TYPE_OCTOPUS
|
||||
ins.InferUrl = inferUrl
|
||||
ins.InferCard = card
|
||||
|
||||
return ins, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue