fix:update GetTrainingTaskLog in modelarts

This commit is contained in:
qiwang 2025-03-06 17:14:08 +08:00
parent 33031c1a91
commit 30f77b4ee1
3 changed files with 34 additions and 6 deletions

2
go.mod
View File

@ -20,7 +20,7 @@ require (
github.com/zeromicro/go-zero v1.7.4
gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20250107025835-8fc888b1d170
gitlink.org.cn/JointCloud/pcm-hpc v0.0.0-20241125115811-72f3568255a4
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250108072048-9adf0597b07c
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250306073530-56ecf1273207
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240817071412-44397870b110
gitlink.org.cn/JointCloud/pcm-openi v0.0.0-20250102093846-164b4884c9ec
gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203

8
go.sum
View File

@ -530,6 +530,14 @@ gitlink.org.cn/JointCloud/pcm-hpc v0.0.0-20241125115811-72f3568255a4 h1:WIs/189l
gitlink.org.cn/JointCloud/pcm-hpc v0.0.0-20241125115811-72f3568255a4/go.mod h1:YbuoRgF9sEVvNJPQtGRjdocX7Du6NBOTLn+GVwqRVjo=
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250108072048-9adf0597b07c h1:9LphS29VNfoWT73eqhgwKV1nG8PcoDUNu7dRev845wA=
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250108072048-9adf0597b07c/go.mod h1:V19vFg8dWRAbaskASoSj70dgpacswOqZu/SaI02dxac=
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250304023304-d556ce8161c7 h1:pv1WX3+ttqsHs7nr7+lfYNkvzUp1KIJQ0XzWbVetj6w=
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250304023304-d556ce8161c7/go.mod h1:MxtnJJcU8S4zfGKZVcg2MOXGtwucKy7MMDwA0IemBd0=
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250304035519-da6ab53b969d h1:EfAxN4oaCVIRsnM3pnC7NskifFRjM/THBUiMGtQQzfg=
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250304035519-da6ab53b969d/go.mod h1:MxtnJJcU8S4zfGKZVcg2MOXGtwucKy7MMDwA0IemBd0=
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250306022112-4ed1f08d3170 h1:NsHFtWPpcL8nF0s4v0DHuHuPaPFgMO9xITQCMM7Du1E=
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250306022112-4ed1f08d3170/go.mod h1:MxtnJJcU8S4zfGKZVcg2MOXGtwucKy7MMDwA0IemBd0=
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250306073530-56ecf1273207 h1:korhOkFl0x1wuQBKoKTsQHeFboDwLFRWwR2G9IPPfNg=
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250306073530-56ecf1273207/go.mod h1:MxtnJJcU8S4zfGKZVcg2MOXGtwucKy7MMDwA0IemBd0=
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-openi v0.0.0-20250102093846-164b4884c9ec h1:Yul2JOAIS94B+eIg0UvmBSe8JrtSrZ2OA47gAYLiBYI=

View File

@ -30,6 +30,7 @@ import (
"gitlink.org.cn/JointCloud/pcm-modelarts/client/modelartsservice"
"gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
modelartsclient "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
"io"
"k8s.io/apimachinery/pkg/util/json"
"log"
"mime/multipart"
@ -550,15 +551,34 @@ func (m *ModelArtsLink) GetTrainingTaskLog(ctx context.Context, taskId string, i
TaskId: "worker-0",
TrainingJobId: taskId,
}
resp, err := m.modelArtsRpc.GetTrainingJobLogsPreview(ctx, req)
//resp, err := m.modelArtsRpc.GetTrainingJobLogsPreview(ctx, req)
stream, err := m.modelArtsRpc.GetTrainingJobLogStream(ctx, req)
if err != nil {
return "", err
log.Fatalf("error calling StreamLogs: %v", err)
}
if strings.Contains(resp.Content, "404 Not Found") {
resp.Content = "waiting for logs..."
var fullLog string
for {
// 接收服务端发送的日志块
logEntry, err := stream.Recv()
if err == io.EOF {
// 流结束
break
}
if err != nil {
log.Fatalf("接收日志块失败: %v", err)
}
// 拼接日志块
fullLog += logEntry.Message
}
return resp.Content, nil
return fullLog, nil
/* if strings.Contains(resp.Content, "404 Not Found") {
= "waiting for logs..."
}*/
//return resp.Content, nil
}
func (m *ModelArtsLink) GetTrainingTask(ctx context.Context, taskId string) (*collector.Task, error) {