|
|
|
@@ -15,6 +15,7 @@ |
|
|
|
package storeLink |
|
|
|
|
|
|
|
import ( |
|
|
|
"bufio" |
|
|
|
"context" |
|
|
|
"errors" |
|
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/schedulers/option" |
|
|
|
@@ -24,8 +25,7 @@ import ( |
|
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" |
|
|
|
"gitlink.org.cn/JointCloud/pcm-octopus/octopus" |
|
|
|
"gitlink.org.cn/JointCloud/pcm-octopus/octopusclient" |
|
|
|
"io/ioutil" |
|
|
|
"log" |
|
|
|
"io" |
|
|
|
"math" |
|
|
|
"mime/multipart" |
|
|
|
"strconv" |
|
|
|
@@ -990,24 +990,33 @@ func (o *OctopusLink) GetInferDeployInstance(ctx context.Context, id string) (*i |
|
|
|
} |
|
|
|
|
|
|
|
func (o *OctopusLink) GetInferResult(ctx context.Context, url string, file multipart.File, fileName string) (string, error) { |
|
|
|
buf, err := ioutil.ReadAll(file) |
|
|
|
stream, err := o.octopusRpc.GetInferResult(ctx) |
|
|
|
if err != nil { |
|
|
|
log.Fatal(err) |
|
|
|
return "", err |
|
|
|
} |
|
|
|
req := &octopus.InferResultReq{ |
|
|
|
Platform: o.platform, |
|
|
|
InferUrl: url, |
|
|
|
FileName: fileName, |
|
|
|
FileBytes: buf, |
|
|
|
|
|
|
|
buffer := make([]byte, 2048) |
|
|
|
bufferedReader := bufio.NewReader(file) |
|
|
|
for { |
|
|
|
_, err = bufferedReader.Read(buffer) |
|
|
|
if err != nil { |
|
|
|
if err != io.EOF { |
|
|
|
return "", err |
|
|
|
} |
|
|
|
break |
|
|
|
} |
|
|
|
err = stream.Send(&octopus.InferResultReq{ |
|
|
|
Platform: o.platform, |
|
|
|
InferUrl: url, |
|
|
|
FileName: fileName, |
|
|
|
FileBytes: buffer, |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
result, err := o.octopusRpc.GetInferResult(ctx, req) |
|
|
|
recv, err := stream.CloseAndRecv() |
|
|
|
if err != nil { |
|
|
|
return "", err |
|
|
|
} |
|
|
|
|
|
|
|
if result.Result == "" { |
|
|
|
return "", errors.New("get result failed") |
|
|
|
} |
|
|
|
return result.Result, nil |
|
|
|
return recv.Result, nil |
|
|
|
} |