diff --git a/go.mod b/go.mod index 2c0518cbc..b409105aa 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/zeromicro/go-zero v1.6.6 gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240725071305-f751eec4dde1 gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20240724095608-1727d09f030c - gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240815070729-eeab0822f4fe + gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240817071412-44397870b110 gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203 gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5 gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230904090036-24fc730ec87d diff --git a/go.sum b/go.sum index 7e63e8c0f..f55d6c4a1 100644 --- a/go.sum +++ b/go.sum @@ -475,8 +475,8 @@ gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240725071305-f751eec4dde1 h1:DicBXoQiC gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240725071305-f751eec4dde1/go.mod h1:3eECiw9O2bIFkkePlloKyLNXiqBAhOxNrDoGaaGseGY= gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20240724095608-1727d09f030c h1:CodJeGgTYJwA6NDHFnw6B+4pBXUl79tvAcECq39tgZI= gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20240724095608-1727d09f030c/go.mod h1:/eOmBFZKWGoabG3sRVkVvIbLwsd2631k4jkUBR6x1AA= -gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240815070729-eeab0822f4fe h1:4zBOROvGGzmS1p/cuCVKE0d2tIqhkHNzpSspizZ4G2Y= -gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240815070729-eeab0822f4fe/go.mod h1:QOD5+/l2D+AYBjF2h5T0mdJyfGAmF78QmeKdbBXbjLQ= +gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240817071412-44397870b110 h1:GaXwr5sgDh0raHjUf9IewTvnRvajYea7zbLsaerYyXo= +gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240817071412-44397870b110/go.mod h1:QOD5+/l2D+AYBjF2h5T0mdJyfGAmF78QmeKdbBXbjLQ= gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203 h1:s6PsZ1+bev294IWdZRlV7mnOwI1+UzFcldVW/BqhQzI= gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203/go.mod h1:i2rrbMQ+Fve345BY9Heh4MUqVTAimZQElQhzzRee5B8= gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5 h1:+/5vnzkJBfMRnya1NrhOzlroUtRa5ePiYbPKlHLoLV0= diff --git a/internal/logic/ai/trainingtaskstatlogic.go b/internal/logic/ai/trainingtaskstatlogic.go index c745fb815..982b929b8 100644 --- a/internal/logic/ai/trainingtaskstatlogic.go +++ b/internal/logic/ai/trainingtaskstatlogic.go @@ -2,8 +2,6 @@ package ai import ( "context" - "errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" @@ -37,10 +35,6 @@ func (l *TrainingTaskStatLogic) TrainingTaskStat() (resp *types.TrainingTaskStat return nil, err } - if total == 0 { - return nil, errors.New("get statistics failed") - } - resp.Total = total resp.Running = running return resp, nil diff --git a/internal/logic/inference/deployinstancestatlogic.go b/internal/logic/inference/deployinstancestatlogic.go index 92043fa64..b0e72cb3b 100644 --- a/internal/logic/inference/deployinstancestatlogic.go +++ b/internal/logic/inference/deployinstancestatlogic.go @@ -2,8 +2,6 @@ package inference import ( "context" - "errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" @@ -37,10 +35,6 @@ func (l *DeployInstanceStatLogic) DeployInstanceStat(req *types.DeployInstanceSt return nil, err } - if total == 0 { - return nil, errors.New("get statistics failed") - } - resp.Total = total resp.Running = running return resp, nil diff --git a/internal/logic/inference/inferencetaskstatlogic.go b/internal/logic/inference/inferencetaskstatlogic.go index b622d6bfe..9b0e1fe0c 100644 --- a/internal/logic/inference/inferencetaskstatlogic.go +++ b/internal/logic/inference/inferencetaskstatlogic.go @@ -2,8 +2,6 @@ package inference import ( "context" - "errors" - "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" @@ -37,10 +35,6 @@ func (l *InferenceTaskStatLogic) InferenceTaskStat(req *types.InferenceTaskStatR return nil, err } - if total == 0 { - return nil, errors.New("get statistics failed") - } - resp.Total = total resp.Running = running return resp, nil diff --git a/internal/storeLink/octopus.go b/internal/storeLink/octopus.go index be23deea1..e74a6301d 100644 --- a/internal/storeLink/octopus.go +++ b/internal/storeLink/octopus.go @@ -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) - if err != nil { - log.Fatal(err) - } - req := &octopus.InferResultReq{ - Platform: o.platform, - InferUrl: url, - FileName: fileName, - FileBytes: buf, - } - - result, err := o.octopusRpc.GetInferResult(ctx, req) + stream, err := o.octopusRpc.GetInferResult(ctx) if err != nil { return "", err } - if result.Result == "" { - return "", errors.New("get result failed") + 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, + }) } - return result.Result, nil + + recv, err := stream.CloseAndRecv() + if err != nil { + return "", err + } + + return recv.Result, nil }