|
|
@@ -7,8 +7,10 @@ package repo |
|
|
|
|
|
|
|
import ( |
|
|
|
"code.gitea.io/gitea/modules/grampus" |
|
|
|
"code.gitea.io/gitea/modules/setting" |
|
|
|
"encoding/json" |
|
|
|
"net/http" |
|
|
|
"path" |
|
|
|
"strconv" |
|
|
|
"strings" |
|
|
|
|
|
|
@@ -263,39 +265,49 @@ func TrainJobGetLog(ctx *context.APIContext) { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
resultLogFile, result, err := trainJobGetLogContent(jobID, versionName, baseLine, order, lines_int) |
|
|
|
task, err := models.GetCloudbrainByJobIDAndVersionName(jobID, versionName) |
|
|
|
if err != nil { |
|
|
|
log.Error("GetCloudbrainByJobID(%s) failed:%v", jobID, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
resultLogFile, result, err := trainJobGetLogContent(jobID, task.VersionID, baseLine, order, lines_int) |
|
|
|
if err != nil { |
|
|
|
log.Error("trainJobGetLog(%s) failed:%v", jobID, err.Error()) |
|
|
|
// ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobShow, nil) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
prefix := strings.TrimPrefix(path.Join(setting.TrainJobModelPath, task.JobName, modelarts.LogPath, versionName), "/") + "/job" |
|
|
|
_, err = storage.GetObsLogFileName(prefix) |
|
|
|
var canLogDownload bool |
|
|
|
if err != nil { |
|
|
|
canLogDownload = false |
|
|
|
} else { |
|
|
|
canLogDownload = true |
|
|
|
} |
|
|
|
|
|
|
|
ctx.Data["log_file_name"] = resultLogFile.LogFileList[0] |
|
|
|
|
|
|
|
ctx.JSON(http.StatusOK, map[string]interface{}{ |
|
|
|
"JobID": jobID, |
|
|
|
"LogFileName": resultLogFile.LogFileList[0], |
|
|
|
"StartLine": result.StartLine, |
|
|
|
"EndLine": result.EndLine, |
|
|
|
"Content": result.Content, |
|
|
|
"Lines": result.Lines, |
|
|
|
"JobID": jobID, |
|
|
|
"LogFileName": resultLogFile.LogFileList[0], |
|
|
|
"StartLine": result.StartLine, |
|
|
|
"EndLine": result.EndLine, |
|
|
|
"Content": result.Content, |
|
|
|
"Lines": result.Lines, |
|
|
|
"CanLogDownload": canLogDownload, |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
func trainJobGetLogContent(jobID string, versionName string, baseLine string, order string, lines int) (*models.GetTrainJobLogFileNamesResult, *models.GetTrainJobLogResult, error) { |
|
|
|
task, err := models.GetCloudbrainByJobIDAndVersionName(jobID, versionName) |
|
|
|
if err != nil { |
|
|
|
log.Error("GetCloudbrainByJobID(%s) failed:%v", jobID, err.Error()) |
|
|
|
return nil, nil, err |
|
|
|
} |
|
|
|
func trainJobGetLogContent(jobID string, versionID int64, baseLine string, order string, lines int) (*models.GetTrainJobLogFileNamesResult, *models.GetTrainJobLogResult, error) { |
|
|
|
|
|
|
|
resultLogFile, err := modelarts.GetTrainJobLogFileNames(jobID, strconv.FormatInt(task.VersionID, 10)) |
|
|
|
resultLogFile, err := modelarts.GetTrainJobLogFileNames(jobID, strconv.FormatInt(versionID, 10)) |
|
|
|
if err != nil { |
|
|
|
log.Error("GetTrainJobLogFileNames(%s) failed:%v", jobID, err.Error()) |
|
|
|
return nil, nil, err |
|
|
|
} |
|
|
|
|
|
|
|
result, err := modelarts.GetTrainJobLog(jobID, strconv.FormatInt(task.VersionID, 10), baseLine, resultLogFile.LogFileList[0], order, lines) |
|
|
|
result, err := modelarts.GetTrainJobLog(jobID, strconv.FormatInt(versionID, 10), baseLine, resultLogFile.LogFileList[0], order, lines) |
|
|
|
if err != nil { |
|
|
|
log.Error("GetTrainJobLog(%s) failed:%v", jobID, err.Error()) |
|
|
|
return nil, nil, err |
|
|
|