|
|
@@ -274,6 +274,21 @@ func TrainJobGetLog(ctx *context.APIContext) { |
|
|
|
log.Error("GetCloudbrainByJobID(%s) failed:%v", jobID, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if !task.IsUserHasRight(ctx.User) { |
|
|
|
ctx.JSON(http.StatusOK, map[string]interface{}{ |
|
|
|
"JobID": jobID, |
|
|
|
"LogFileName": "", |
|
|
|
"StartLine": 0, |
|
|
|
"EndLine": 0, |
|
|
|
"Content": "", |
|
|
|
"Lines": 0, |
|
|
|
"CanLogDownload": false, |
|
|
|
"StartTime": task.StartTime, |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
resultLogFile, result, err := trainJobGetLogContent(jobID, task.VersionID, baseLine, order, lines_int) |
|
|
|
if err != nil { |
|
|
|
log.Error("trainJobGetLog(%s) failed:%v", jobID, err.Error()) |
|
|
@@ -290,15 +305,12 @@ func TrainJobGetLog(ctx *context.APIContext) { |
|
|
|
"EndLine": result.EndLine, |
|
|
|
"Content": result.Content, |
|
|
|
"Lines": result.Lines, |
|
|
|
"CanLogDownload": canLogDownload(ctx.User, task), |
|
|
|
"CanLogDownload": canLogDownload(task), |
|
|
|
"StartTime": task.StartTime, |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
func canLogDownload(user *models.User, task *models.Cloudbrain) bool { |
|
|
|
if task == nil || !task.IsUserHasRight(user) { |
|
|
|
return false |
|
|
|
} |
|
|
|
func canLogDownload(task *models.Cloudbrain) bool { |
|
|
|
prefix := strings.TrimPrefix(path.Join(setting.TrainJobModelPath, task.JobName, modelarts.LogPath, task.VersionName), "/") + "/job" |
|
|
|
_, err := storage.GetObsLogFileName(prefix) |
|
|
|
if err != nil { |
|
|
|