From 6f642da6c323b70808360ff9d97a51d02d118a48 Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Tue, 24 May 2022 19:51:40 +0800 Subject: [PATCH] opt --- modules/grampus/grampus.go | 7 ++++--- routers/repo/grampus.go | 38 ++++++++++++++++++++++++++------------ 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/modules/grampus/grampus.go b/modules/grampus/grampus.go index 71e368fa6..5f580189d 100755 --- a/modules/grampus/grampus.go +++ b/modules/grampus/grampus.go @@ -78,6 +78,7 @@ type GenerateTrainJobReq struct { TotalVersionCount int ComputeResource string DatasetName string + Params string } func GenerateTrainJob(ctx *context.Context, req *GenerateTrainJobReq) (err error) { @@ -119,9 +120,9 @@ func GenerateTrainJob(ctx *context.Context, req *GenerateTrainJobReq) (err error //EngineID: req.EngineID, TrainUrl: req.TrainUrl, BranchName: req.BranchName, - //Parameters: req.Params, - BootFile: req.BootFile, - DataUrl: req.DataUrl, + Parameters: req.Params, + BootFile: req.BootFile, + DataUrl: req.DataUrl, //LogUrl: req.LogUrl, //FlavorCode: req.FlavorCode, Description: req.Description, diff --git a/routers/repo/grampus.go b/routers/repo/grampus.go index ab9d71290..bf07cb079 100755 --- a/routers/repo/grampus.go +++ b/routers/repo/grampus.go @@ -236,8 +236,6 @@ func GrampusTrainJobNpuCreate(ctx *context.Context, form auth.CreateGrampusTrain VersionOutputPath := modelarts.GetOutputPathByCount(modelarts.TotalVersionCount) displayJobName := form.DisplayJobName jobName := util.ConvertDisplayJobNameToJobName(displayJobName) - //todo:del - jobName = displayJobName uuid := form.Attachment description := form.Description bootFile := form.BootFile @@ -252,8 +250,6 @@ func GrampusTrainJobNpuCreate(ctx *context.Context, form auth.CreateGrampusTrain VersionCount := modelarts.VersionCount EngineName := form.EngineName - log.Info(jobName) - count, err := models.GetGrampusCountByUserID(ctx.User.ID, string(models.JobTypeTrain), models.NPUResource) if err != nil { log.Error("GetGrampusCountByUserID failed:%v", err, ctx.Data["MsgID"]) @@ -387,10 +383,10 @@ func GrampusTrainJobNpuCreate(ctx *context.Context, form auth.CreateGrampusTrain //PoolID: poolID, Uuid: uuid, //Parameters: param, - CommitID: commitID, - IsLatestVersion: isLatestVersion, - BranchName: branchName, - //Params: form.Params, + CommitID: commitID, + IsLatestVersion: isLatestVersion, + BranchName: branchName, + Params: form.Params, FlavorName: FlavorName, EngineName: EngineName, VersionCount: VersionCount, @@ -507,7 +503,6 @@ func deleteGrampusJob(ctx *context.Context) error { func GrampusTrainJobShow(ctx *context.Context) { ctx.Data["PageIsCloudBrain"] = true - //debugListType := ctx.Query("debugListType") var task *models.Cloudbrain task, err := models.GetCloudbrainByJobIDWithDeleted(ctx.Params(":jobid")) @@ -522,9 +517,24 @@ func GrampusTrainJobShow(ctx *context.Context) { task.DatasetName = attachment.Name } - taskList := make([]*models.Cloudbrain, 0) - taskList = append(taskList, task) - ctx.Data["version_list_task"] = taskList + if len(task.Parameters) > 0 { + var parameters models.Parameters + err := json.Unmarshal([]byte(task.Parameters), ¶meters) + if err != nil { + log.Error("Failed to Unmarshal Parameters: %s (%v)", task.Parameters, err) + ctx.ServerError("system error", err) + return + } + + if len(parameters.Parameter) > 0 { + paramTemp := "" + for _, Parameter := range parameters.Parameter { + param := Parameter.Label + " = " + Parameter.Value + "; " + paramTemp = paramTemp + param + } + task.Parameters = paramTemp[:len(paramTemp)-2] + } + } if task.DeletedAt.IsZero() { //normal record result, err := grampus.GetJob(task.JobID) @@ -555,6 +565,10 @@ func GrampusTrainJobShow(ctx *context.Context) { } } + taskList := make([]*models.Cloudbrain, 0) + taskList = append(taskList, task) + ctx.Data["version_list_task"] = taskList + ctx.HTML(http.StatusOK, tplGrampusTrainJobShow) }