|
|
@@ -281,15 +281,6 @@ func TrainJobGetLog(ctx *context.APIContext) { |
|
|
|
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{}{ |
|
|
@@ -299,11 +290,26 @@ func TrainJobGetLog(ctx *context.APIContext) { |
|
|
|
"EndLine": result.EndLine, |
|
|
|
"Content": result.Content, |
|
|
|
"Lines": result.Lines, |
|
|
|
"CanLogDownload": canLogDownload, |
|
|
|
"CanLogDownload": canLogDownload(ctx.User, task), |
|
|
|
"StartTime": task.StartTime, |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
func canLogDownload(user *models.User, task *models.Cloudbrain) bool { |
|
|
|
if user == nil { |
|
|
|
return false |
|
|
|
} |
|
|
|
if !user.IsAdmin && user.ID != task.UserID { |
|
|
|
return false |
|
|
|
} |
|
|
|
prefix := strings.TrimPrefix(path.Join(setting.TrainJobModelPath, task.JobName, modelarts.LogPath, task.VersionName), "/") + "/job" |
|
|
|
_, err := storage.GetObsLogFileName(prefix) |
|
|
|
if err != nil { |
|
|
|
return false |
|
|
|
} |
|
|
|
return true |
|
|
|
} |
|
|
|
|
|
|
|
func trainJobGetLogContent(jobID string, versionID int64, baseLine string, order string, lines int) (*models.GetTrainJobLogFileNamesResult, *models.GetTrainJobLogResult, error) { |
|
|
|
|
|
|
|
resultLogFile, err := modelarts.GetTrainJobLogFileNames(jobID, strconv.FormatInt(versionID, 10)) |
|
|
|