| @@ -102,6 +102,14 @@ func GetModelArtsTrainJobVersion(ctx *context.APIContext) { | |||||
| job.Status = modelarts.TransTrainJobStatus(result.IntStatus) | job.Status = modelarts.TransTrainJobStatus(result.IntStatus) | ||||
| job.Duration = result.Duration | job.Duration = result.Duration | ||||
| job.TrainJobDuration = result.TrainJobDuration | job.TrainJobDuration = result.TrainJobDuration | ||||
| if result.Duration != 0 { | |||||
| job.TrainJobDuration = addZero(result.Duration/3600000) + ":" + addZero(result.Duration%3600000/60000) + ":" + addZero(result.Duration%60000/1000) | |||||
| } else { | |||||
| job.TrainJobDuration = "00:00:00" | |||||
| } | |||||
| err = models.UpdateJob(job) | err = models.UpdateJob(job) | ||||
| if err != nil { | if err != nil { | ||||
| log.Error("UpdateJob failed:", err) | log.Error("UpdateJob failed:", err) | ||||
| @@ -110,11 +118,20 @@ func GetModelArtsTrainJobVersion(ctx *context.APIContext) { | |||||
| ctx.JSON(http.StatusOK, map[string]interface{}{ | ctx.JSON(http.StatusOK, map[string]interface{}{ | ||||
| "JobID": jobID, | "JobID": jobID, | ||||
| "JobStatus": job.Status, | "JobStatus": job.Status, | ||||
| "JobDuration": job.Duration, | |||||
| "JobDuration": job.TrainJobDuration, | |||||
| }) | }) | ||||
| } | } | ||||
| func addZero(t int64) (m string) { | |||||
| if t < 10 { | |||||
| m = "0" + strconv.FormatInt(t, 10) | |||||
| return m | |||||
| } else { | |||||
| return strconv.FormatInt(t, 10) | |||||
| } | |||||
| } | |||||
| func TrainJobGetLog(ctx *context.APIContext) { | func TrainJobGetLog(ctx *context.APIContext) { | ||||
| var ( | var ( | ||||
| err error | err error | ||||
| @@ -125,6 +142,11 @@ func TrainJobGetLog(ctx *context.APIContext) { | |||||
| // var logFileName = ctx.Query("file_name") | // var logFileName = ctx.Query("file_name") | ||||
| var baseLine = ctx.Query("base_line") | var baseLine = ctx.Query("base_line") | ||||
| var order = ctx.Query("order") | var order = ctx.Query("order") | ||||
| var lines = ctx.Query("lines") | |||||
| lines_int, err := strconv.Atoi(lines) | |||||
| if err != nil { | |||||
| log.Error("change lines(%d) string to int failed", lines_int) | |||||
| } | |||||
| if order != modelarts.OrderDesc && order != modelarts.OrderAsc { | if order != modelarts.OrderDesc && order != modelarts.OrderAsc { | ||||
| log.Error("order(%s) check failed", order) | log.Error("order(%s) check failed", order) | ||||
| @@ -143,7 +165,7 @@ func TrainJobGetLog(ctx *context.APIContext) { | |||||
| // return | // return | ||||
| // } | // } | ||||
| resultLogFile, result, err := trainJobGetLogContent(jobID, versionName, baseLine, order) | |||||
| resultLogFile, result, err := trainJobGetLogContent(jobID, versionName, baseLine, order, lines_int) | |||||
| if err != nil { | if err != nil { | ||||
| log.Error("trainJobGetLog(%s) failed:%v", jobID, err.Error()) | log.Error("trainJobGetLog(%s) failed:%v", jobID, err.Error()) | ||||
| // ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobShow, nil) | // ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobShow, nil) | ||||
| @@ -170,7 +192,7 @@ func TrainJobGetLog(ctx *context.APIContext) { | |||||
| }) | }) | ||||
| } | } | ||||
| func trainJobGetLogContent(jobID string, versionName string, baseLine string, order string) (*models.GetTrainJobLogFileNamesResult, *models.GetTrainJobLogResult, error) { | |||||
| func trainJobGetLogContent(jobID string, versionName string, baseLine string, order string, lines int) (*models.GetTrainJobLogFileNamesResult, *models.GetTrainJobLogResult, error) { | |||||
| task, err := models.GetCloudbrainByJobIDAndVersionName(jobID, versionName) | task, err := models.GetCloudbrainByJobIDAndVersionName(jobID, versionName) | ||||
| if err != nil { | if err != nil { | ||||
| log.Error("GetCloudbrainByJobID(%s) failed:%v", jobID, err.Error()) | log.Error("GetCloudbrainByJobID(%s) failed:%v", jobID, err.Error()) | ||||
| @@ -183,7 +205,7 @@ func trainJobGetLogContent(jobID string, versionName string, baseLine string, or | |||||
| return nil, nil, err | return nil, nil, err | ||||
| } | } | ||||
| result, err := modelarts.GetTrainJobLog(jobID, strconv.FormatInt(task.VersionID, 10), baseLine, resultLogFile.LogFileList[0], order, modelarts.Lines) | |||||
| result, err := modelarts.GetTrainJobLog(jobID, strconv.FormatInt(task.VersionID, 10), baseLine, resultLogFile.LogFileList[0], order, lines) | |||||
| if err != nil { | if err != nil { | ||||
| log.Error("GetTrainJobLog(%s) failed:%v", jobID, err.Error()) | log.Error("GetTrainJobLog(%s) failed:%v", jobID, err.Error()) | ||||
| return nil, nil, err | return nil, nil, err | ||||