|
|
|
@@ -462,3 +462,46 @@ func ResultList(ctx *context.APIContext) { |
|
|
|
"PageIsCloudBrain": true, |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
func TrainJobGetMetricStatistic(ctx *context.APIContext) { |
|
|
|
var ( |
|
|
|
err error |
|
|
|
) |
|
|
|
|
|
|
|
var jobID = ctx.Params(":jobid") |
|
|
|
var versionName = ctx.Query("version_name") |
|
|
|
|
|
|
|
result, err := trainJobGetMetricStatistic(jobID, versionName) |
|
|
|
if err != nil { |
|
|
|
log.Error("trainJobGetMetricStatistic(%s) failed:%v", jobID, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
ctx.JSON(http.StatusOK, map[string]interface{}{ |
|
|
|
"JobID": jobID, |
|
|
|
"Interval": result.Interval, |
|
|
|
"MetricsInfo": result.MetricsInfo, |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
func trainJobGetMetricStatistic(jobID string, versionName string) (*models.GetTrainJobMetricStatisticResult, error) { |
|
|
|
task, err := models.GetCloudbrainByJobIDAndVersionName(jobID, versionName) |
|
|
|
if err != nil { |
|
|
|
log.Error("GetCloudbrainByJobIDAndVersionName(%s) failed:%v", jobID, err.Error()) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
|
|
|
|
resultLogFile, err := modelarts.GetTrainJobLogFileNames(jobID, strconv.FormatInt(task.VersionID, 10)) |
|
|
|
if err != nil { |
|
|
|
log.Error("GetTrainJobLogFileNames(%s) failed:%v", jobID, err.Error()) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
|
|
|
|
result, err := modelarts.GetTrainJobMetricStatistic(jobID, strconv.FormatInt(task.VersionID, 10), resultLogFile.LogFileList[0]) |
|
|
|
if err != nil { |
|
|
|
log.Error("GetTrainJobMetricStatistic(%s) failed:%v", jobID, err.Error()) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
|
|
|
|
return result, err |
|
|
|
} |