Merge pull request 'fix stat empty errors' (#283) from tzwang/pcm-coordinator:master into master

This commit is contained in:
tzwang 2024-08-17 15:31:34 +08:00
commit 21fd8cf886
6 changed files with 29 additions and 38 deletions

2
go.mod
View File

@ -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

4
go.sum
View File

@ -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=

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
}