|
|
@@ -9,6 +9,7 @@ import ( |
|
|
|
"io/ioutil" |
|
|
|
"net/http" |
|
|
|
"os" |
|
|
|
"path" |
|
|
|
"strings" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/models" |
|
|
@@ -661,13 +662,21 @@ func ModelConvertDownloadModel(ctx *context.Context) { |
|
|
|
ctx.ServerError("no file to download.", err) |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
Prefix := strings.TrimPrefix(path.Join(setting.TrainJobModelPath, job.CloudBrainTaskId, "output/", "V0001", ""), "/") |
|
|
|
allFile, err := storage.GetAllObjectByBucketAndPrefix(setting.Bucket, Prefix) |
|
|
|
if err == nil { |
|
|
|
returnFileName := job.Name + ".zip" |
|
|
|
ObsDownloadManyFile(Prefix, ctx, returnFileName, allFile) |
|
|
|
} else { |
|
|
|
log.Info("error,msg=" + err.Error()) |
|
|
|
ctx.ServerError("no file to download.", err) |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
parentDir := ctx.Query("parentDir") |
|
|
|
fileName := ctx.Query("fileName") |
|
|
|
jobName := ctx.Query("jobName") |
|
|
|
if job.IsGpuTrainTask() { |
|
|
|
parentDir := ctx.Query("parentDir") |
|
|
|
fileName := ctx.Query("fileName") |
|
|
|
jobName := ctx.Query("jobName") |
|
|
|
filePath := "jobs/" + jobName + "/model/" + parentDir |
|
|
|
url, err := storage.Attachments.PresignedGetURL(filePath, fileName) |
|
|
|
if err != nil { |
|
|
@@ -679,6 +688,15 @@ func ModelConvertDownloadModel(ctx *context.Context) { |
|
|
|
http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusTemporaryRedirect) |
|
|
|
} else { |
|
|
|
//TODO |
|
|
|
ObjectKey := path.Join(setting.TrainJobModelPath, job.CloudBrainTaskId, "output/", "V0001", parentDir, fileName) |
|
|
|
log.Info("ObjectKey=" + ObjectKey) |
|
|
|
url, err := storage.GetObsCreateSignedUrlByBucketAndKey(setting.Bucket, ObjectKey) |
|
|
|
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) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|