From 2cb2c3c887e94dd2658773fd38e9c01939705cab Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Wed, 31 Aug 2022 15:19:55 +0800 Subject: [PATCH 01/16] fix issue --- templates/repo/cloudbrain/inference/show.tmpl | 42 ++++++++++++++++++- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/templates/repo/cloudbrain/inference/show.tmpl b/templates/repo/cloudbrain/inference/show.tmpl index 3ec01417e1..70d02f512f 100644 --- a/templates/repo/cloudbrain/inference/show.tmpl +++ b/templates/repo/cloudbrain/inference/show.tmpl @@ -264,7 +264,8 @@ data-tab="first">{{$.i18n.Tr "repo.modelarts.train_job.config"}} {{$.i18n.Tr "repo.cloudbrain.runinfo"}} - + {{$.i18n.Tr "repo.modelarts.log"}} {{$.i18n.Tr "repo.model_download"}} @@ -537,7 +538,44 @@ - +
+
+ + + {{$.i18n.Tr "repo.modelarts.download_log"}} + + +
+
+ + + + + + + +
+
+
+
+ + +

+                             
+ +
+ + +
-- 2.34.1 From 5ebab0a2df0833a62b756e0d3780d9c352b10f7e Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Wed, 31 Aug 2022 15:25:24 +0800 Subject: [PATCH 02/16] fix issue --- templates/repo/cloudbrain/benchmark/show.tmpl | 54 +++++++++++++------ 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/templates/repo/cloudbrain/benchmark/show.tmpl b/templates/repo/cloudbrain/benchmark/show.tmpl index add7d34d4a..d657ac2ff8 100755 --- a/templates/repo/cloudbrain/benchmark/show.tmpl +++ b/templates/repo/cloudbrain/benchmark/show.tmpl @@ -256,8 +256,9 @@
@@ -528,19 +529,42 @@
- -
- - -

-                            
- -
- -
+ + + {{$.i18n.Tr "repo.modelarts.download_log"}} + + +
+
+ + + + + + + +
+
+
+
+ + +

+                             
+ +
+ + +
-- 2.34.1 From a2ed940896f0676e340af63acb98adcb4204ba06 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Wed, 31 Aug 2022 15:27:22 +0800 Subject: [PATCH 03/16] fix issue --- templates/repo/cloudbrain/inference/show.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/cloudbrain/inference/show.tmpl b/templates/repo/cloudbrain/inference/show.tmpl index 70d02f512f..012baa7f7a 100644 --- a/templates/repo/cloudbrain/inference/show.tmpl +++ b/templates/repo/cloudbrain/inference/show.tmpl @@ -228,7 +228,7 @@ {{with .task}}
+ data-repopath="{{$.RepoRelPath}}/cloudbrain/inference-job" data-jobid="{{.ID}}" data-version="{{.VersionName}}">
-- 2.34.1 From 6898b5df57bd3246f8d452b41eaa7d04fbd368eb Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Wed, 31 Aug 2022 15:31:54 +0800 Subject: [PATCH 04/16] fix issue --- templates/repo/cloudbrain/inference/show.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/cloudbrain/inference/show.tmpl b/templates/repo/cloudbrain/inference/show.tmpl index 012baa7f7a..4ab65ca84c 100644 --- a/templates/repo/cloudbrain/inference/show.tmpl +++ b/templates/repo/cloudbrain/inference/show.tmpl @@ -228,7 +228,7 @@ {{with .task}}
+ data-repopath="{{$.RepoRelPath}}/cloudbrain" data-jobid="{{.ID}}" data-version="{{.VersionName}}">
-- 2.34.1 From 1d64c9bcff26773874a2714d01f190e1865315f1 Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 31 Aug 2022 15:35:47 +0800 Subject: [PATCH 05/16] =?UTF-8?q?#2833=20=E9=9C=80=E6=B1=82=E5=BC=80?= =?UTF-8?q?=E5=8F=91=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- modules/cloudbrain/cloudbrain.go | 6 +++--- routers/repo/cloudbrain.go | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/cloudbrain/cloudbrain.go b/modules/cloudbrain/cloudbrain.go index 30f080335b..25c556278d 100755 --- a/modules/cloudbrain/cloudbrain.go +++ b/modules/cloudbrain/cloudbrain.go @@ -20,7 +20,7 @@ import ( const ( //Command = `pip3 install jupyterlab==2.2.5 -i https://pypi.tuna.tsinghua.edu.cn/simple;service ssh stop;jupyter lab --no-browser --ip=0.0.0.0 --allow-root --notebook-dir="/code" --port=80 --LabApp.token="" --LabApp.allow_origin="self https://cloudbrain.pcl.ac.cn"` //CommandBenchmark = `echo "start benchmark";python /code/test.py;echo "end benchmark"` - CommandBenchmark = `echo "start benchmark";cd /benchmark && bash run_bk.sh;echo "end benchmark"` + CommandBenchmark = `echo "start benchmark";cd /benchmark && bash run_bk.sh | tee /model/benchmark-log.txt;echo "end benchmark"` CodeMountPath = "/code" DataSetMountPath = "/dataset" ModelMountPath = "/model" @@ -30,8 +30,8 @@ const ( Snn4imagenetMountPath = "/snn4imagenet" BrainScoreMountPath = "/brainscore" TaskInfoName = "/taskInfo" - Snn4imagenetCommand = `/opt/conda/bin/python /snn4imagenet/testSNN_script.py --modelname '%s' --modelpath '/dataset' --modeldescription '%s'` - BrainScoreCommand = `bash /brainscore/brainscore_test_par4shSrcipt.sh -b '%s' -n '%s' -p '/dataset' -d '%s'` + Snn4imagenetCommand = `/opt/conda/bin/python /snn4imagenet/testSNN_script.py --modelname '%s' --modelpath '/dataset' --modeldescription '%s' | tee /model/benchmark-log.txt` + BrainScoreCommand = `bash /brainscore/brainscore_test_par4shSrcipt.sh -b '%s' -n '%s' -p '/dataset' -d '%s' | tee /model/benchmark-log.txt` SubTaskName = "task1" diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 2d8bebf4b4..db52f41f09 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -2431,7 +2431,8 @@ func BenchMarkAlgorithmCreate(ctx *context.Context, form auth.CreateCloudBrainFo ctx.RenderWithErr(ctx.Tr("cloudbrain.error.dataset_select"), tplCloudBrainBenchmarkNew, &form) return } - + log.Info("Command=" + command) + log.Info("ModelPath=" + storage.GetMinioPath(jobName, cloudbrain.ModelMountPath+"/")) req := cloudbrain.GenerateCloudBrainTaskReq{ Ctx: ctx, DisplayJobName: displayJobName, @@ -2560,7 +2561,8 @@ func ModelBenchmarkCreate(ctx *context.Context, form auth.CreateCloudBrainForm) ctx.RenderWithErr(ctx.Tr("cloudbrain.error.dataset_select"), tpl, &form) return } - + log.Info("Command=" + command) + log.Info("ModelPath=" + storage.GetMinioPath(jobName, cloudbrain.ModelMountPath+"/")) req := cloudbrain.GenerateCloudBrainTaskReq{ Ctx: ctx, DisplayJobName: displayJobName, @@ -2689,7 +2691,7 @@ func getInferenceJobCommand(form auth.CreateCloudBrainInferencForm) (string, err param += " --modelname" + "=" + form.CkptName - command += "python /code/" + bootFile + param + " > " + cloudbrain.ResultPath + "/" + form.DisplayJobName + "-" + cloudbrain.LogFile + command += "python /code/" + bootFile + param + " | tee " + cloudbrain.ResultPath + "/" + form.DisplayJobName + "-" + cloudbrain.LogFile return command, nil } -- 2.34.1 From b76af052a474e5729b6d1fbea9b2c07dad4f86cb Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 1 Sep 2022 10:24:12 +0800 Subject: [PATCH 06/16] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= 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 | 104 ++++++++++++++++++++++++++++-- 1 file changed, 97 insertions(+), 7 deletions(-) diff --git a/routers/api/v1/repo/cloudbrain.go b/routers/api/v1/repo/cloudbrain.go index b450b2e26b..d127f27ed5 100755 --- a/routers/api/v1/repo/cloudbrain.go +++ b/routers/api/v1/repo/cloudbrain.go @@ -405,8 +405,21 @@ func CloudbrainDownloadLogFile(ctx *context.Context) { func CloudbrainGetLog(ctx *context.Context) { ID := ctx.Params(":id") - startLine := ctx.QueryInt("base_line") + job, err := models.GetCloudbrainByID(ID) + if err != nil { + log.Error("GetCloudbrainByJobName failed: %v", err, ctx.Data["MsgID"]) + ctx.ServerError(err.Error(), err) + return + } lines := ctx.QueryInt("lines") + baseLine := ctx.Query("base_line") + if baseLine == "" { + re := getLastLogFromModelDir(job.JobName, lines) + ctx.JSON(http.StatusOK, re) + return + } + + startLine := ctx.QueryInt("base_line") endLine := startLine + lines order := ctx.Query("order") if order == "asc" { @@ -416,12 +429,7 @@ func CloudbrainGetLog(ctx *context.Context) { startLine = 0 } } - job, err := models.GetCloudbrainByID(ID) - if err != nil { - log.Error("GetCloudbrainByJobName failed: %v", err, ctx.Data["MsgID"]) - ctx.ServerError(err.Error(), err) - return - } + result := getLogFromModelDir(job.JobName, startLine, endLine) if result == nil { log.Error("GetJobLog failed: %v", err, ctx.Data["MsgID"]) @@ -443,6 +451,88 @@ func CloudbrainGetLog(ctx *context.Context) { ctx.JSON(http.StatusOK, re) } +func getAllLineFromFile(path string) int { + count := 0 + reader, err := os.Open(path) + defer reader.Close() + if err == nil { + r := bufio.NewReader(reader) + for { + _, error := r.ReadString('\n') + if error == io.EOF { + log.Info("read file completed.") + break + } + if error != nil { + log.Info("read file error." + error.Error()) + break + } + count = count + 1 + } + } else { + log.Info("error:" + err.Error()) + } + return count +} + +func getLastLogFromModelDir(jobName string, lines int) map[string]interface{} { + prefix := "/" + setting.CBCodePathPrefix + jobName + "/model" + files, err := storage.GetOneLevelAllObjectUnderDirMinio(setting.Attachment.Minio.Bucket, prefix, "") + if err != nil { + log.Error("query cloudbrain model failed: %v", err) + return nil + } + + re := "" + fileName := "" + count := 0 + allLines := 0 + for _, file := range files { + if strings.HasSuffix(file.FileName, "log.txt") { + fileName = file.FileName + path := storage.GetMinioPath(jobName+"/model/", file.FileName) + allLines = getAllLineFromFile(path) + start := allLines - 50 + if start < 0 { + start = 0 + } + count = allLines - start + log.Info("path=" + path) + reader, err := os.Open(path) + defer reader.Close() + if err == nil { + r := bufio.NewReader(reader) + for i := start; i < allLines; i++ { + line, error := r.ReadString('\n') + log.Info("line=" + line) + if error == io.EOF { + log.Info("read file completed.") + break + } + if error != nil { + log.Info("read file error." + error.Error()) + break + } + if error == nil { + re = re + line + } + } + } else { + log.Info("error:" + err.Error()) + } + break + } + } + + return map[string]interface{}{ + "JobName": jobName, + "Content": re, + "FileName": fileName, + "lines": count, + "endLine": allLines, + } +} + func getLogFromModelDir(jobName string, startLine int, endLine int) map[string]interface{} { prefix := "/" + setting.CBCodePathPrefix + jobName + "/model" files, err := storage.GetOneLevelAllObjectUnderDirMinio(setting.Attachment.Minio.Bucket, prefix, "") -- 2.34.1 From a6161bfddbc7e95db6860b0db96b61165610101c Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 1 Sep 2022 10:35:55 +0800 Subject: [PATCH 07/16] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= 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 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/routers/api/v1/repo/cloudbrain.go b/routers/api/v1/repo/cloudbrain.go index d127f27ed5..33d8d89c06 100755 --- a/routers/api/v1/repo/cloudbrain.go +++ b/routers/api/v1/repo/cloudbrain.go @@ -492,17 +492,17 @@ func getLastLogFromModelDir(jobName string, lines int) map[string]interface{} { fileName = file.FileName path := storage.GetMinioPath(jobName+"/model/", file.FileName) allLines = getAllLineFromFile(path) - start := allLines - 50 - if start < 0 { - start = 0 + startLine := allLines - 50 + if startLine < 0 { + startLine = 0 } - count = allLines - start + count = allLines - startLine log.Info("path=" + path) reader, err := os.Open(path) defer reader.Close() if err == nil { r := bufio.NewReader(reader) - for i := start; i < allLines; i++ { + for i := 0; i < allLines; i++ { line, error := r.ReadString('\n') log.Info("line=" + line) if error == io.EOF { @@ -514,7 +514,9 @@ func getLastLogFromModelDir(jobName string, lines int) map[string]interface{} { break } if error == nil { - re = re + line + if i >= startLine { + re = re + line + } } } } else { -- 2.34.1 From e9bfc092cd287ab813e80b11c7db2fde05b0ba2a Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 1 Sep 2022 10:50:02 +0800 Subject: [PATCH 08/16] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= 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 | 74 +++++++++++++++---------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/routers/api/v1/repo/cloudbrain.go b/routers/api/v1/repo/cloudbrain.go index 33d8d89c06..fb20b6c7b6 100755 --- a/routers/api/v1/repo/cloudbrain.go +++ b/routers/api/v1/repo/cloudbrain.go @@ -8,6 +8,7 @@ package repo import ( "bufio" "encoding/json" + "fmt" "io" "net/http" "os" @@ -413,41 +414,37 @@ func CloudbrainGetLog(ctx *context.Context) { } lines := ctx.QueryInt("lines") baseLine := ctx.Query("base_line") + var result map[string]interface{} if baseLine == "" { - re := getLastLogFromModelDir(job.JobName, lines) - ctx.JSON(http.StatusOK, re) - return - } - - startLine := ctx.QueryInt("base_line") - endLine := startLine + lines - order := ctx.Query("order") - if order == "asc" { - endLine = startLine - startLine = endLine - lines - if startLine < 0 { - startLine = 0 + result = getLastLogFromModelDir(job.JobName, lines) + } else { + startLine := ctx.QueryInt("base_line") + endLine := startLine + lines + order := ctx.Query("order") + if order == "asc" { + endLine = startLine + startLine = endLine - lines + if startLine < 0 { + startLine = 0 + } + } + result = getLogFromModelDir(job.JobName, startLine, endLine) + if result == nil { + log.Error("GetJobLog failed: %v", err, ctx.Data["MsgID"]) + ctx.ServerError(err.Error(), err) + return } } - - result := getLogFromModelDir(job.JobName, startLine, endLine) - if result == nil { - log.Error("GetJobLog failed: %v", err, ctx.Data["MsgID"]) - ctx.ServerError(err.Error(), err) - return - } - re := map[string]interface{}{ "JobID": ID, "LogFileName": result["FileName"], - "StartLine": startLine, - "EndLine": result["endLine"], + "StartLine": result["StartLine"], + "EndLine": result["EndLine"], "Content": result["Content"], - "Lines": result["lines"], + "Lines": result["Lines"], "CanLogDownload": result["FileName"] != "", } //result := CloudbrainGetLogByJobId(job.JobID, job.JobName) - ctx.JSON(http.StatusOK, re) } @@ -487,12 +484,13 @@ func getLastLogFromModelDir(jobName string, lines int) map[string]interface{} { fileName := "" count := 0 allLines := 0 + startLine := 0 for _, file := range files { if strings.HasSuffix(file.FileName, "log.txt") { fileName = file.FileName path := storage.GetMinioPath(jobName+"/model/", file.FileName) allLines = getAllLineFromFile(path) - startLine := allLines - 50 + startLine = allLines - lines if startLine < 0 { startLine = 0 } @@ -504,7 +502,6 @@ func getLastLogFromModelDir(jobName string, lines int) map[string]interface{} { r := bufio.NewReader(reader) for i := 0; i < allLines; i++ { line, error := r.ReadString('\n') - log.Info("line=" + line) if error == io.EOF { log.Info("read file completed.") break @@ -515,6 +512,7 @@ func getLastLogFromModelDir(jobName string, lines int) map[string]interface{} { } if error == nil { if i >= startLine { + log.Info("i=" + fmt.Sprint(i)) re = re + line } } @@ -527,11 +525,12 @@ func getLastLogFromModelDir(jobName string, lines int) map[string]interface{} { } return map[string]interface{}{ - "JobName": jobName, - "Content": re, - "FileName": fileName, - "lines": count, - "endLine": allLines, + "JobName": jobName, + "Content": re, + "FileName": fileName, + "Lines": count, + "EndLine": allLines, + "StartLine": startLine, } } @@ -583,11 +582,12 @@ func getLogFromModelDir(jobName string, startLine int, endLine int) map[string]i } return map[string]interface{}{ - "JobName": jobName, - "Content": re, - "FileName": fileName, - "lines": count, - "endLine": fileEndLine, + "JobName": jobName, + "Content": re, + "FileName": fileName, + "Lines": count, + "EndLine": fileEndLine, + "StartLine": startLine, } } -- 2.34.1 From 16b23ff5cb3ae9c794c3c4b098101148afb381d6 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 1 Sep 2022 10:57:56 +0800 Subject: [PATCH 09/16] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= 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 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/routers/api/v1/repo/cloudbrain.go b/routers/api/v1/repo/cloudbrain.go index fb20b6c7b6..20c3cff017 100755 --- a/routers/api/v1/repo/cloudbrain.go +++ b/routers/api/v1/repo/cloudbrain.go @@ -414,13 +414,14 @@ func CloudbrainGetLog(ctx *context.Context) { } lines := ctx.QueryInt("lines") baseLine := ctx.Query("base_line") + order := ctx.Query("order") var result map[string]interface{} - if baseLine == "" { + if baseLine == "" && order == "desc" { result = getLastLogFromModelDir(job.JobName, lines) } else { startLine := ctx.QueryInt("base_line") endLine := startLine + lines - order := ctx.Query("order") + if order == "asc" { endLine = startLine startLine = endLine - lines -- 2.34.1 From 8e1df7854543e6510694d63f3753f9616bf8fc18 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 1 Sep 2022 11:08:17 +0800 Subject: [PATCH 10/16] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= 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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/routers/api/v1/repo/cloudbrain.go b/routers/api/v1/repo/cloudbrain.go index 20c3cff017..5fbaaa03bc 100755 --- a/routers/api/v1/repo/cloudbrain.go +++ b/routers/api/v1/repo/cloudbrain.go @@ -559,7 +559,6 @@ func getLogFromModelDir(jobName string, startLine int, endLine int) map[string]i for i := 0; i < endLine; i++ { line, error := r.ReadString('\n') log.Info("line=" + line) - fileEndLine = i if error == io.EOF { log.Info("read file completed.") break @@ -570,11 +569,13 @@ func getLogFromModelDir(jobName string, startLine int, endLine int) map[string]i } if error == nil { if i >= startLine { + fileEndLine = i re = re + line count++ } } } + fileEndLine = fileEndLine + 1 } else { log.Info("error:" + err.Error()) } -- 2.34.1 From 989b0d8f8a7b64694f4c7e2cee445d20ac72b007 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 1 Sep 2022 11:16:57 +0800 Subject: [PATCH 11/16] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= 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 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/routers/api/v1/repo/cloudbrain.go b/routers/api/v1/repo/cloudbrain.go index 5fbaaa03bc..8c638d6b5e 100755 --- a/routers/api/v1/repo/cloudbrain.go +++ b/routers/api/v1/repo/cloudbrain.go @@ -8,7 +8,6 @@ package repo import ( "bufio" "encoding/json" - "fmt" "io" "net/http" "os" @@ -422,7 +421,7 @@ func CloudbrainGetLog(ctx *context.Context) { startLine := ctx.QueryInt("base_line") endLine := startLine + lines - if order == "asc" { + if order == "asc" && (startLine-lines) > 0 { endLine = startLine startLine = endLine - lines if startLine < 0 { @@ -513,7 +512,6 @@ func getLastLogFromModelDir(jobName string, lines int) map[string]interface{} { } if error == nil { if i >= startLine { - log.Info("i=" + fmt.Sprint(i)) re = re + line } } -- 2.34.1 From da0124ca660eb1e2aa2b62dd2fdfd2c6157890e2 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 1 Sep 2022 11:20:27 +0800 Subject: [PATCH 12/16] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/api/v1/repo/cloudbrain.go b/routers/api/v1/repo/cloudbrain.go index 8c638d6b5e..75ddaf616f 100755 --- a/routers/api/v1/repo/cloudbrain.go +++ b/routers/api/v1/repo/cloudbrain.go @@ -421,7 +421,7 @@ func CloudbrainGetLog(ctx *context.Context) { startLine := ctx.QueryInt("base_line") endLine := startLine + lines - if order == "asc" && (startLine-lines) > 0 { + if order == "asc" && (startLine-lines) >= 0 { endLine = startLine startLine = endLine - lines if startLine < 0 { -- 2.34.1 From 99a5298217e3ca4826841b62a1ffc4d4b538566e Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 1 Sep 2022 11:30:23 +0800 Subject: [PATCH 13/16] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= 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 | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/routers/api/v1/repo/cloudbrain.go b/routers/api/v1/repo/cloudbrain.go index 75ddaf616f..9b222cc6ab 100755 --- a/routers/api/v1/repo/cloudbrain.go +++ b/routers/api/v1/repo/cloudbrain.go @@ -421,11 +421,15 @@ func CloudbrainGetLog(ctx *context.Context) { startLine := ctx.QueryInt("base_line") endLine := startLine + lines - if order == "asc" && (startLine-lines) >= 0 { - endLine = startLine - startLine = endLine - lines - if startLine < 0 { - startLine = 0 + if order == "asc" { + if (startLine - lines) >= 0 { + endLine = startLine + startLine = endLine - lines + if startLine < 0 { + startLine = 0 + } + } else { + endLine = startLine } } result = getLogFromModelDir(job.JobName, startLine, endLine) @@ -540,7 +544,16 @@ func getLogFromModelDir(jobName string, startLine int, endLine int) map[string]i log.Error("query cloudbrain model failed: %v", err) return nil } - + if startLine == endLine { + return map[string]interface{}{ + "JobName": jobName, + "Content": "", + "FileName": "", + "Lines": 0, + "EndLine": startLine, + "StartLine": startLine, + } + } re := "" fileName := "" count := 0 -- 2.34.1 From 24799e1842890dfebc0d109fab25941448c3ef70 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 1 Sep 2022 11:41:25 +0800 Subject: [PATCH 14/16] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= 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 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/routers/api/v1/repo/cloudbrain.go b/routers/api/v1/repo/cloudbrain.go index 9b222cc6ab..f3d1acfad1 100755 --- a/routers/api/v1/repo/cloudbrain.go +++ b/routers/api/v1/repo/cloudbrain.go @@ -420,16 +420,16 @@ func CloudbrainGetLog(ctx *context.Context) { } else { startLine := ctx.QueryInt("base_line") endLine := startLine + lines - if order == "asc" { - if (startLine - lines) >= 0 { + if baseLine == "" { + startLine = 0 + endLine = lines + } else { endLine = startLine startLine = endLine - lines if startLine < 0 { startLine = 0 } - } else { - endLine = startLine } } result = getLogFromModelDir(job.JobName, startLine, endLine) -- 2.34.1 From beb7b8e3a90b4f8396b4f3ec1a91063874bb2cb7 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 1 Sep 2022 15:04:38 +0800 Subject: [PATCH 15/16] =?UTF-8?q?=E6=8E=A8=E7=90=86=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E4=BF=AE=E6=94=B9=E3=80=82?= 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 | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/routers/api/v1/repo/cloudbrain.go b/routers/api/v1/repo/cloudbrain.go index f3d1acfad1..d6b7bb0767 100755 --- a/routers/api/v1/repo/cloudbrain.go +++ b/routers/api/v1/repo/cloudbrain.go @@ -415,8 +415,12 @@ func CloudbrainGetLog(ctx *context.Context) { baseLine := ctx.Query("base_line") order := ctx.Query("order") var result map[string]interface{} + resultPath := "/model" + if job.JobType == string(models.JobTypeInference) { + resultPath = "/result" + } if baseLine == "" && order == "desc" { - result = getLastLogFromModelDir(job.JobName, lines) + result = getLastLogFromModelDir(job.JobName, lines, resultPath) } else { startLine := ctx.QueryInt("base_line") endLine := startLine + lines @@ -432,7 +436,7 @@ func CloudbrainGetLog(ctx *context.Context) { } } } - result = getLogFromModelDir(job.JobName, startLine, endLine) + result = getLogFromModelDir(job.JobName, startLine, endLine, resultPath) if result == nil { log.Error("GetJobLog failed: %v", err, ctx.Data["MsgID"]) ctx.ServerError(err.Error(), err) @@ -476,8 +480,8 @@ func getAllLineFromFile(path string) int { return count } -func getLastLogFromModelDir(jobName string, lines int) map[string]interface{} { - prefix := "/" + setting.CBCodePathPrefix + jobName + "/model" +func getLastLogFromModelDir(jobName string, lines int, resultPath string) map[string]interface{} { + prefix := "/" + setting.CBCodePathPrefix + jobName + resultPath files, err := storage.GetOneLevelAllObjectUnderDirMinio(setting.Attachment.Minio.Bucket, prefix, "") if err != nil { log.Error("query cloudbrain model failed: %v", err) @@ -492,7 +496,7 @@ func getLastLogFromModelDir(jobName string, lines int) map[string]interface{} { for _, file := range files { if strings.HasSuffix(file.FileName, "log.txt") { fileName = file.FileName - path := storage.GetMinioPath(jobName+"/model/", file.FileName) + path := storage.GetMinioPath(jobName+resultPath+"/", file.FileName) allLines = getAllLineFromFile(path) startLine = allLines - lines if startLine < 0 { @@ -537,8 +541,8 @@ func getLastLogFromModelDir(jobName string, lines int) map[string]interface{} { } } -func getLogFromModelDir(jobName string, startLine int, endLine int) map[string]interface{} { - prefix := "/" + setting.CBCodePathPrefix + jobName + "/model" +func getLogFromModelDir(jobName string, startLine int, endLine int, resultPath string) map[string]interface{} { + prefix := "/" + setting.CBCodePathPrefix + jobName + resultPath files, err := storage.GetOneLevelAllObjectUnderDirMinio(setting.Attachment.Minio.Bucket, prefix, "") if err != nil { log.Error("query cloudbrain model failed: %v", err) @@ -561,7 +565,7 @@ func getLogFromModelDir(jobName string, startLine int, endLine int) map[string]i for _, file := range files { if strings.HasSuffix(file.FileName, "log.txt") { fileName = file.FileName - path := storage.GetMinioPath(jobName+"/model/", file.FileName) + path := storage.GetMinioPath(jobName+resultPath+"/", file.FileName) log.Info("path=" + path) reader, err := os.Open(path) defer reader.Close() -- 2.34.1 From 8bc5b8b06386ddb7d9efb7ac5463f8a48893d946 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Thu, 1 Sep 2022 15:35:56 +0800 Subject: [PATCH 16/16] fix issue --- templates/repo/cloudbrain/inference/show.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/cloudbrain/inference/show.tmpl b/templates/repo/cloudbrain/inference/show.tmpl index 4ab65ca84c..6d0cee6426 100644 --- a/templates/repo/cloudbrain/inference/show.tmpl +++ b/templates/repo/cloudbrain/inference/show.tmpl @@ -525,7 +525,7 @@ -
-- 2.34.1