From 4be93e40cf9274f6f07bb8ab919c1a90c3fc0010 Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 19 Aug 2022 11:46:17 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4GPU=E8=AE=AD=E7=BB=83?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=9A=84=E6=97=A5=E5=BF=97=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E3=80=82#2706?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/api/v1/repo/cloudbrain.go | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/routers/api/v1/repo/cloudbrain.go b/routers/api/v1/repo/cloudbrain.go index 0e5afe88e..e4ed4a8b9 100755 --- a/routers/api/v1/repo/cloudbrain.go +++ b/routers/api/v1/repo/cloudbrain.go @@ -381,13 +381,24 @@ func CloudbrainGetLog(ctx *context.Context) { return } result := GetLogFromModelDir(job.JobName, startLine, startLine+lines) - //result := CloudbrainGetLogByJobId(job.JobID, job.JobName) if result == nil { log.Error("GetJobLog failed: %v", err, ctx.Data["MsgID"]) ctx.ServerError(err.Error(), err) return } - ctx.JSON(http.StatusOK, result) + + re := map[string]interface{}{ + "JobID": ID, + "LogFileName": result["FileName"], + "StartLine": startLine, + "EndLine": startLine + lines, + "Content": result["Content"], + "Lines": lines, + "CanLogDownload": result["Content"] != "", + } + //result := CloudbrainGetLogByJobId(job.JobID, job.JobName) + + ctx.JSON(http.StatusOK, re) } func GetLogFromModelDir(jobName string, startLine int, endLine int) map[string]interface{} { @@ -399,8 +410,10 @@ func GetLogFromModelDir(jobName string, startLine int, endLine int) map[string]i } re := "" + fileName := "" for _, file := range files { if strings.HasSuffix(file.FileName, "log.txt") { + fileName = file.FileName path := storage.GetMinioPath(jobName+"/model/", file.FileName) log.Info("path=" + path) reader, err := os.Open(path) @@ -432,8 +445,9 @@ func GetLogFromModelDir(jobName string, startLine int, endLine int) map[string]i } return map[string]interface{}{ - "JobName": jobName, - "Content": re, + "JobName": jobName, + "Content": re, + "FileName": fileName, } }