|
|
|
@@ -288,6 +288,17 @@ func TrainJobIndex(ctx *context.Context) { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
// for i, task := range tasks { |
|
|
|
// result, err := modelarts.GetTrainJob(task.JobID, strconv.FormatInt(task.VersionID, 10)) |
|
|
|
// if err != nil { |
|
|
|
// log.Error("GetJob(%s) failed:%v", task.JobID, err.Error()) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// // tasks[i].Status = modelarts.TransTrainJobStatus(result.Status) |
|
|
|
// tasks[i].Status = result.Status |
|
|
|
// tasks[i].Duration = result.Duration |
|
|
|
// } |
|
|
|
|
|
|
|
pager := context.NewPagination(int(count), setting.UI.IssuePagingNum, page, 5) |
|
|
|
pager.SetDefaultParams(ctx) |
|
|
|
ctx.Data["Page"] = pager |
|
|
|
@@ -957,11 +968,6 @@ func TrainJobShow(ctx *context.Context) { |
|
|
|
ctx.Data["PageIsCloudBrain"] = true |
|
|
|
|
|
|
|
var jobID = ctx.Params(":jobid") |
|
|
|
task, err := models.GetCloudbrainByJobID(jobID) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("GetCloudbrainByJobID faild", err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
repo := ctx.Repo.Repository |
|
|
|
page := ctx.QueryInt("page") |
|
|
|
@@ -996,56 +1002,56 @@ func TrainJobShow(ctx *context.Context) { |
|
|
|
// return |
|
|
|
// } |
|
|
|
|
|
|
|
result, err := modelarts.GetTrainJob(jobID, strconv.FormatInt(task.VersionID, 10)) |
|
|
|
if err != nil { |
|
|
|
log.Error("GetJob(%s) failed:%v", jobID, err.Error()) |
|
|
|
ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobShow, nil) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if result != nil { |
|
|
|
result.CreateTime = time.Unix(int64(result.LongCreateTime/1000), 0).Format("2006-01-02 15:04:05") |
|
|
|
if result.Duration != 0 { |
|
|
|
result.TrainJobDuration = addZero(result.Duration/3600000) + ":" + addZero(result.Duration%3600000/60000) + ":" + addZero(result.Duration%60000/1000) |
|
|
|
|
|
|
|
} else { |
|
|
|
result.TrainJobDuration = "00:00:00" |
|
|
|
} |
|
|
|
result.Status = modelarts.TransTrainJobStatus(result.IntStatus) |
|
|
|
err = models.SetTrainJobStatusByJobID(jobID, result.Status, result.Duration, string(result.TrainJobDuration)) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("UpdateJob failed", err) |
|
|
|
return |
|
|
|
} |
|
|
|
// result, err := modelarts.GetTrainJob(jobID, strconv.FormatInt(task.VersionID, 10)) |
|
|
|
// if err != nil { |
|
|
|
// log.Error("GetJob(%s) failed:%v", jobID, err.Error()) |
|
|
|
// ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobShow, nil) |
|
|
|
// return |
|
|
|
// } |
|
|
|
|
|
|
|
result.DatasetName = task.DatasetName |
|
|
|
} |
|
|
|
// if result != nil { |
|
|
|
// result.CreateTime = time.Unix(int64(result.LongCreateTime/1000), 0).Format("2006-01-02 15:04:05") |
|
|
|
// if result.Duration != 0 { |
|
|
|
// result.TrainJobDuration = addZero(result.Duration/3600000) + ":" + addZero(result.Duration%3600000/60000) + ":" + addZero(result.Duration%60000/1000) |
|
|
|
|
|
|
|
// } else { |
|
|
|
// result.TrainJobDuration = "00:00:00" |
|
|
|
// } |
|
|
|
// result.Status = modelarts.TransTrainJobStatus(result.IntStatus) |
|
|
|
// err = models.SetTrainJobStatusByJobID(jobID, result.Status, result.Duration, string(result.TrainJobDuration)) |
|
|
|
// if err != nil { |
|
|
|
// ctx.ServerError("UpdateJob failed", err) |
|
|
|
// return |
|
|
|
// } |
|
|
|
|
|
|
|
// result.DatasetName = task.DatasetName |
|
|
|
// } |
|
|
|
|
|
|
|
resultLogFile, resultLog, err := trainJobGetLog(jobID) |
|
|
|
if err != nil { |
|
|
|
log.Error("trainJobGetLog(%s) failed:%v", jobID, err.Error()) |
|
|
|
ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobShow, nil) |
|
|
|
return |
|
|
|
} |
|
|
|
// resultLogFile, resultLog, err := trainJobGetLog(jobID) |
|
|
|
// if err != nil { |
|
|
|
// log.Error("trainJobGetLog(%s) failed:%v", jobID, err.Error()) |
|
|
|
// ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobShow, nil) |
|
|
|
// return |
|
|
|
// } |
|
|
|
|
|
|
|
ctx.Data["log_file_name"] = resultLogFile.LogFileList[0] |
|
|
|
ctx.Data["log"] = resultLog |
|
|
|
ctx.Data["task"] = task |
|
|
|
// ctx.Data["log_file_name"] = resultLogFile.LogFileList[0] |
|
|
|
// ctx.Data["log"] = resultLog |
|
|
|
// ctx.Data["task"] = task |
|
|
|
ctx.Data["jobID"] = jobID |
|
|
|
ctx.Data["result"] = result |
|
|
|
// ctx.Data["result"] = result |
|
|
|
ctx.Data["version_list_task"] = VersionListTasks |
|
|
|
ctx.Data["version_list_count"] = VersionListCount |
|
|
|
ctx.HTML(http.StatusOK, tplModelArtsTrainJobShow) |
|
|
|
} |
|
|
|
|
|
|
|
func addZero(t int64) (m string) { |
|
|
|
if t < 10 { |
|
|
|
m = "0" + strconv.FormatInt(t, 10) |
|
|
|
return m |
|
|
|
} else { |
|
|
|
return strconv.FormatInt(t, 10) |
|
|
|
} |
|
|
|
} |
|
|
|
// 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.Context) { |
|
|
|
ctx.Data["PageIsTrainJob"] = true |
|
|
|
@@ -1103,25 +1109,52 @@ func trainJobGetLog(jobID string) (*models.GetTrainJobLogFileNamesResult, *model |
|
|
|
|
|
|
|
func TrainJobDel(ctx *context.Context) { |
|
|
|
var jobID = ctx.Params(":jobid") |
|
|
|
task, err := models.GetCloudbrainByJobID(jobID) |
|
|
|
repo := ctx.Repo.Repository |
|
|
|
page := ctx.QueryInt("page") |
|
|
|
|
|
|
|
if page <= 0 { |
|
|
|
page = 1 |
|
|
|
} |
|
|
|
VersionListTasks, _, err := models.CloudbrainsVersionList(&models.CloudbrainsOptions{ |
|
|
|
ListOptions: models.ListOptions{ |
|
|
|
Page: page, |
|
|
|
PageSize: setting.UI.IssuePagingNum, |
|
|
|
}, |
|
|
|
RepoID: repo.ID, |
|
|
|
Type: models.TypeCloudBrainTwo, |
|
|
|
JobType: string(models.JobTypeTrain), |
|
|
|
JobID: jobID, |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
log.Error("GetCloudbrainByJobID(%s) failed:%v", task.JobName, err.Error()) |
|
|
|
ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobIndex, nil) |
|
|
|
ctx.ServerError("get VersionListTasks failed", err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
for _, task := range VersionListTasks { |
|
|
|
err = models.DeleteJobVersion(&task.Cloudbrain) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("DeleteJobVersion failed", err) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
_, err = modelarts.DelTrainJob(jobID) |
|
|
|
if err != nil { |
|
|
|
log.Error("DelTrainJob(%s) failed:%v", task.JobName, err.Error()) |
|
|
|
log.Error("DelTrainJob(%s) failed:%v", jobID, err.Error()) |
|
|
|
ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobIndex, nil) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
err = models.DeleteJob(task) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("DeleteJob failed", err) |
|
|
|
return |
|
|
|
} |
|
|
|
// task, err := models.GetCloudbrainByJobID(jobID) |
|
|
|
// if err != nil { |
|
|
|
// log.Error("GetCloudbrainByJobID(%s) failed:%v", task.JobName, err.Error()) |
|
|
|
// ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobIndex, nil) |
|
|
|
// return |
|
|
|
// } |
|
|
|
|
|
|
|
// err = models.DeleteJob(task) |
|
|
|
// if err != nil { |
|
|
|
// ctx.ServerError("DeleteJob failed", err) |
|
|
|
// return |
|
|
|
// } |
|
|
|
|
|
|
|
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/modelarts/train-job") |
|
|
|
} |
|
|
|
|