Browse Source

fix stat empty error

Former-commit-id: 630ed73490
pull/283/head
tzwang 1 year ago
parent
commit
99c376f263
6 changed files with 26 additions and 35 deletions
  1. +1
    -1
      go.mod
  2. +2
    -2
      go.sum
  3. +0
    -6
      internal/logic/ai/trainingtaskstatlogic.go
  4. +0
    -6
      internal/logic/inference/deployinstancestatlogic.go
  5. +0
    -6
      internal/logic/inference/inferencetaskstatlogic.go
  6. +23
    -14
      internal/storeLink/octopus.go

+ 1
- 1
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


+ 2
- 2
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=


+ 0
- 6
internal/logic/ai/trainingtaskstatlogic.go 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


+ 0
- 6
internal/logic/inference/deployinstancestatlogic.go 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


+ 0
- 6
internal/logic/inference/inferencetaskstatlogic.go 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


+ 23
- 14
internal/storeLink/octopus.go 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)
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
}

Loading…
Cancel
Save