|
|
|
@@ -338,37 +338,53 @@ func CloudBrainDel(ctx *context.Context) { |
|
|
|
func CloudBrainShowModels(ctx *context.Context) { |
|
|
|
ctx.Data["PageIsCloudBrain"] = true |
|
|
|
|
|
|
|
var jobID = ctx.Params(":jobid") |
|
|
|
jobID := ctx.Params(":jobid") |
|
|
|
parentDir := ctx.Query("parentDir") |
|
|
|
task, err := models.GetCloudbrainByJobID(jobID) |
|
|
|
if err != nil { |
|
|
|
log.Error("no such job!") |
|
|
|
ctx.RenderWithErr("no such job!", tplCloudBrainIndex, nil) |
|
|
|
ctx.ServerError("no such job:", err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
//get dirs |
|
|
|
dirs, err := getModelDirs(task.JobName, parentDir) |
|
|
|
if err != nil { |
|
|
|
log.Error("getModelDirs failed:", err.Error()) |
|
|
|
ctx.ServerError("getModelDirs failed:", err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
var fileInfos []FileInfo |
|
|
|
err = json.Unmarshal([]byte(dirs), &fileInfos) |
|
|
|
if err != nil { |
|
|
|
log.Error("json.Unmarshal failed:", err.Error()) |
|
|
|
ctx.ServerError("json.Unmarshal failed:", err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ctx.Data["Dirs"] = fileInfos |
|
|
|
ctx.Data["task"] = task |
|
|
|
ctx.Data["jobID"] = jobID |
|
|
|
ctx.HTML(200, tplCloudBrainShowModels) |
|
|
|
} |
|
|
|
|
|
|
|
func getModelDirs(uuid string, parentDir string) (string, error) { |
|
|
|
func getModelDirs(jobName string, parentDir string) (string, error) { |
|
|
|
var req string |
|
|
|
modelActualPath := setting.JobPath + jobName + "/model/" |
|
|
|
if parentDir == "" { |
|
|
|
req = "uuid=" + uuid |
|
|
|
req = "baseDir=" + modelActualPath |
|
|
|
} else { |
|
|
|
req = "uuid=" + uuid + "&parentDir=" + parentDir |
|
|
|
req = "baseDir=" + modelActualPath + "&parentDir=" + parentDir |
|
|
|
} |
|
|
|
|
|
|
|
return getDirs(req) |
|
|
|
} |
|
|
|
|
|
|
|
func CloudBrainDownloadModel(ctx *context.Context) { |
|
|
|
filePath := ctx.Query("file_path") |
|
|
|
fileName := ctx.Query("file_name") |
|
|
|
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 { |
|
|
|
log.Error("PresignedGetURL failed: %v", err.Error()) |
|
|
|
|