diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index 57d50847f..e8cac4568 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -1288,15 +1288,17 @@ func TrainJobVersionShowModels(ctx *context.Context) { jobID := ctx.Params(":jobid") parentDir := ctx.Query("parentDir") versionName := ctx.Query("version_name") - dirArray := strings.Split(parentDir, "/") + // dirArray := strings.Split(parentDir, "/") task, err := models.GetCloudbrainByJobIDAndVersionName(jobID, versionName) if err != nil { log.Error("no such job!", ctx.Data["msgID"]) ctx.ServerError("no such job:", err) return } - parentDir = versionName - models, err := storage.GetVersionObsListObject(task.JobName, parentDir) + // parentDir = versionName + VersionOutputPath := "V" + strconv.Itoa(task.TotalVersionCount) + dirArray := strings.Split(VersionOutputPath, "/") + models, err := storage.GetObsListObjectVersion(task.JobName, parentDir, VersionOutputPath) if err != nil { log.Info("get TrainJobListModel failed:", err) ctx.ServerError("GetVersionObsListObject:", err) @@ -1304,6 +1306,7 @@ func TrainJobVersionShowModels(ctx *context.Context) { } ctx.Data["Path"] = dirArray + // ctx.Data["Path"] = VersionOutputPath ctx.Data["Dirs"] = models ctx.Data["task"] = task ctx.Data["JobID"] = jobID @@ -1322,3 +1325,26 @@ func TrainJobDownloadModel(ctx *context.Context) { } http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusMovedPermanently) } + +func TrainJobVersionDownloadModel(ctx *context.Context) { + var jobID = ctx.Params(":jobid") + + parentDir := ctx.Query("parentDir") + fileName := ctx.Query("fileName") + versionName := ctx.Query("version_name") + + task, err := models.GetCloudbrainByJobIDAndVersionName(jobID, versionName) + if err != nil { + log.Error("GetCloudbrainByJobID(%s) failed:%v", task.JobName, err.Error()) + return + } + VersionOutputPath := "V" + strconv.Itoa(task.TotalVersionCount) + + url, err := storage.GetObsCreateVersionSignedUrl(task.JobName, parentDir, fileName, VersionOutputPath) + if err != nil { + log.Error("GetObsCreateSignedUrl failed: %v", err.Error(), ctx.Data["msgID"]) + ctx.ServerError("GetObsCreateSignedUrl", err) + return + } + http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusMovedPermanently) +} diff --git a/routers/routes/routes.go b/routers/routes/routes.go index d98764571..15ce87c3d 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -992,8 +992,8 @@ func RegisterRoutes(m *macaron.Macaron) { // m.Get("/log", reqRepoCloudBrainReader, repo.TrainJobGetLog) // m.Get("/models", reqRepoCloudBrainReader, repo.TrainJobShowModels) m.Get("/models", reqRepoCloudBrainReader, repo.TrainJobVersionShowModels) - m.Get("/download_model", reqRepoCloudBrainReader, repo.TrainJobDownloadModel) - m.Get("/version_models", reqRepoCloudBrainReader, repo.TrainJobVersionShowModels) + // m.Get("/download_model", reqRepoCloudBrainReader, repo.TrainJobDownloadModel) + m.Get("/download_model", reqRepoCloudBrainReader, repo.TrainJobVersionDownloadModel) m.Get("/create_version", reqRepoCloudBrainReader, repo.TrainJobNewVersion) m.Post("/create_version", reqRepoCloudBrainWriter, bindIgnErr(auth.CreateModelArtsTrainJobForm{}), repo.TrainJobCreateVersion) // })