update TaskLog

This commit is contained in:
tzwang 2025-06-24 17:40:49 +08:00
parent 6a1655e478
commit b82a4a5943
3 changed files with 52 additions and 4 deletions

2
go.mod
View File

@ -24,7 +24,7 @@ require (
gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20250107025835-8fc888b1d170 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-hpc v0.0.0-20241125115811-72f3568255a4
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250313064001-91fb558cfdb6 gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250313064001-91fb558cfdb6
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20250619094959-66dc370c4b6e gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20250624091120-dee975c73c57
gitlink.org.cn/JointCloud/pcm-openi v0.0.0-20250320103718-7bd6650118ee gitlink.org.cn/JointCloud/pcm-openi v0.0.0-20250320103718-7bd6650118ee
gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203 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/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5

4
go.sum
View File

@ -539,8 +539,8 @@ 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-hpc v0.0.0-20241125115811-72f3568255a4/go.mod h1:YbuoRgF9sEVvNJPQtGRjdocX7Du6NBOTLn+GVwqRVjo=
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250313064001-91fb558cfdb6 h1:9o0ONbSiQHTzODptzgtVZjRYFBLncZ6dpHp9YF+v73I= gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250313064001-91fb558cfdb6 h1:9o0ONbSiQHTzODptzgtVZjRYFBLncZ6dpHp9YF+v73I=
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250313064001-91fb558cfdb6/go.mod h1:MxtnJJcU8S4zfGKZVcg2MOXGtwucKy7MMDwA0IemBd0= gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250313064001-91fb558cfdb6/go.mod h1:MxtnJJcU8S4zfGKZVcg2MOXGtwucKy7MMDwA0IemBd0=
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20250619094959-66dc370c4b6e h1:KbgH65QhfOYIrkRz1eUmCa9nJZsmEMnu6Fk84nGoyYA= gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20250624091120-dee975c73c57 h1:+T/ZPk1hjNBQy5pKqLsd27s4PVJbee4CzB0OWV27mg4=
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20250619094959-66dc370c4b6e/go.mod h1:iQtyaoeMP4mNY0xutDBDD/305QwnPjj0zNtiQjXix50= gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20250624091120-dee975c73c57/go.mod h1:iQtyaoeMP4mNY0xutDBDD/305QwnPjj0zNtiQjXix50=
gitlink.org.cn/JointCloud/pcm-openi v0.0.0-20250320103718-7bd6650118ee h1:+YYzcWPX0Up98nOb5ngkCaqiWHpSH7XJQRTUSvYclWU= gitlink.org.cn/JointCloud/pcm-openi v0.0.0-20250320103718-7bd6650118ee h1:+YYzcWPX0Up98nOb5ngkCaqiWHpSH7XJQRTUSvYclWU=
gitlink.org.cn/JointCloud/pcm-openi v0.0.0-20250320103718-7bd6650118ee/go.mod h1:0VMTWXsRx7Z5z+kxBid2zf7kq5YtFlxubXEwPHiicyM= gitlink.org.cn/JointCloud/pcm-openi v0.0.0-20250320103718-7bd6650118ee/go.mod h1:0VMTWXsRx7Z5z+kxBid2zf7kq5YtFlxubXEwPHiicyM=
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 h1:s6PsZ1+bev294IWdZRlV7mnOwI1+UzFcldVW/BqhQzI=

View File

@ -63,6 +63,7 @@ const (
ResourcespecsUrl = "api/v1/resource/specs" ResourcespecsUrl = "api/v1/resource/specs"
CreateTrainJobUrl = "api/v1/job/create" CreateTrainJobUrl = "api/v1/job/create"
TrainJobDetail = "api/v1/job/detail" TrainJobDetail = "api/v1/job/detail"
TrainJobLog = "api/v1/job/log"
) )
// compute source // compute source
@ -287,7 +288,54 @@ func (o *OctopusHttp) GetAlgorithms(ctx context.Context) ([]*collector.Algorithm
} }
func (o *OctopusHttp) GetTrainingTaskLog(ctx context.Context, taskId string, instanceNum string) (string, error) { func (o *OctopusHttp) GetTrainingTaskLog(ctx context.Context, taskId string, instanceNum string) (string, error) {
return "", errors.New(NotImplementError) taskDetailsUrl := o.server + TrainJobLog
token, err := o.token.Get()
if err != nil {
return "", err
}
param := omodel.TrainJobLog{
JobId: taskId,
}
b, _ := json.Marshal(param)
byt := bytes.NewBuffer(b)
resp := &entity.OctResp{}
req := common.GetRestyRequest(common.TIMEOUT)
r, _ := http.NewRequest("GET", taskDetailsUrl, byt)
req.RawRequest = r
req.URL = taskDetailsUrl
_, err = req.
SetHeader("Content-Type", "application/json").
SetQueryParam(Param_Token, token).
SetQueryParam(Param_Addr, o.host).
SetBody(byt).
SetResult(resp).
Send()
if err != nil {
return "", errors.New("failed to invoke taskDetails")
}
if resp.Code != http.StatusOK {
return "", errors.New("failed to invoke taskDetails")
}
var log string
marshal, err := json.Marshal(resp.Data)
if err != nil {
return "", err
}
log = string(marshal)
if strings.Contains(log, "404 Not Found") || log == "" {
log = "waiting for logs..."
}
return log, nil
} }
func (o *OctopusHttp) GetTrainingTask(ctx context.Context, taskId string) (*collector.Task, error) { func (o *OctopusHttp) GetTrainingTask(ctx context.Context, taskId string) (*collector.Task, error) {