|
@@ -478,7 +478,6 @@ func TrainJobNewVersion(ctx *context.Context) { |
|
|
func trainJobNewVersionDataPrepare(ctx *context.Context) error { |
|
|
func trainJobNewVersionDataPrepare(ctx *context.Context) error { |
|
|
ctx.Data["PageIsCloudBrain"] = true |
|
|
ctx.Data["PageIsCloudBrain"] = true |
|
|
var jobID = ctx.Params(":jobid") |
|
|
var jobID = ctx.Params(":jobid") |
|
|
// var versionName = ctx.Params(":version-name") |
|
|
|
|
|
var versionName = ctx.Query("version_name") |
|
|
var versionName = ctx.Query("version_name") |
|
|
// canNewJob, err := canUserCreateTrainJobVersion(ctx, jobID, versionName) |
|
|
// canNewJob, err := canUserCreateTrainJobVersion(ctx, jobID, versionName) |
|
|
// if err != nil { |
|
|
// if err != nil { |
|
@@ -548,7 +547,7 @@ func trainJobNewVersionDataPrepare(ctx *context.Context) error { |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ctx.Data["branch"] = Branches |
|
|
|
|
|
|
|
|
ctx.Data["branches"] = Branches |
|
|
ctx.Data["branch_name"] = task.BranchName |
|
|
ctx.Data["branch_name"] = task.BranchName |
|
|
ctx.Data["description"] = task.Description |
|
|
ctx.Data["description"] = task.Description |
|
|
ctx.Data["boot_file"] = task.BootFile |
|
|
ctx.Data["boot_file"] = task.BootFile |
|
@@ -1388,12 +1387,9 @@ func ModelDownload(ctx *context.Context) { |
|
|
|
|
|
|
|
|
var jobID = ctx.Params(":jobid") |
|
|
var jobID = ctx.Params(":jobid") |
|
|
versionName := ctx.Query("version_name") |
|
|
versionName := ctx.Query("version_name") |
|
|
// versionName := "V0001" |
|
|
|
|
|
parentDir := ctx.Query("parent_dir") |
|
|
parentDir := ctx.Query("parent_dir") |
|
|
fileName := ctx.Query("file_name") |
|
|
fileName := ctx.Query("file_name") |
|
|
log.Info("DownloadSingleModelFile start.") |
|
|
log.Info("DownloadSingleModelFile start.") |
|
|
// id := ctx.Params(":ID") |
|
|
|
|
|
// path := Model_prefix + models.AttachmentRelativePath(id) + "/" + parentDir + fileName |
|
|
|
|
|
task, err := models.GetCloudbrainByJobIDAndVersionName(jobID, versionName) |
|
|
task, err := models.GetCloudbrainByJobIDAndVersionName(jobID, versionName) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
log.Error("GetCloudbrainByJobID(%s) failed:%v", task.JobName, err.Error()) |
|
|
log.Error("GetCloudbrainByJobID(%s) failed:%v", task.JobName, err.Error()) |
|
@@ -1402,40 +1398,12 @@ func ModelDownload(ctx *context.Context) { |
|
|
|
|
|
|
|
|
path := strings.TrimPrefix(path.Join(setting.TrainJobModelPath, task.JobName, setting.OutPutPath, versionName, parentDir, fileName), "/") |
|
|
path := strings.TrimPrefix(path.Join(setting.TrainJobModelPath, task.JobName, setting.OutPutPath, versionName, parentDir, fileName), "/") |
|
|
log.Info("Download path is:%s", path) |
|
|
log.Info("Download path is:%s", path) |
|
|
if setting.PROXYURL == "" { |
|
|
|
|
|
body, err := storage.ObsDownloadAFile(setting.Bucket, path) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Info("download error.") |
|
|
|
|
|
} else { |
|
|
|
|
|
//count++ |
|
|
|
|
|
// models.ModifyModelDownloadCount(id) |
|
|
|
|
|
defer body.Close() |
|
|
|
|
|
ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+fileName) |
|
|
|
|
|
ctx.Resp.Header().Set("Content-Type", "application/octet-stream") |
|
|
|
|
|
p := make([]byte, 1024) |
|
|
|
|
|
var readErr error |
|
|
|
|
|
var readCount int |
|
|
|
|
|
// 读取对象内容 |
|
|
|
|
|
for { |
|
|
|
|
|
readCount, readErr = body.Read(p) |
|
|
|
|
|
if readCount > 0 { |
|
|
|
|
|
ctx.Resp.Write(p[:readCount]) |
|
|
|
|
|
//fmt.Printf("%s", p[:readCount]) |
|
|
|
|
|
} |
|
|
|
|
|
if readErr != nil { |
|
|
|
|
|
break |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
url, err := storage.GetObsCreateSignedUrlByBucketAndKey(setting.Bucket, path) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Error("GetObsCreateSignedUrl failed: %v", err.Error(), ctx.Data["msgID"]) |
|
|
|
|
|
ctx.ServerError("GetObsCreateSignedUrl", err) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
//count++ |
|
|
|
|
|
// models.ModifyModelDownloadCount(id) |
|
|
|
|
|
http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusMovedPermanently) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
url, err := storage.GetObsCreateSignedUrlByBucketAndKey(setting.Bucket, path) |
|
|
|
|
|
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) |
|
|
} |
|
|
} |