Browse Source

提交代码。

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.22.7.1
zouap 3 years ago
parent
commit
a5ad4f3642
1 changed files with 54 additions and 30 deletions
  1. +54
    -30
      routers/api/v1/repo/cloudbrain.go

+ 54
- 30
routers/api/v1/repo/cloudbrain.go View File

@@ -271,41 +271,65 @@ func CloudBrainModelConvertList(ctx *context.APIContext) {
log.Error("GetCloudbrainByJobID(%s) failed:%v", job.Name, err.Error()) log.Error("GetCloudbrainByJobID(%s) failed:%v", job.Name, err.Error())
return return
} }
if job.SrcEngine == 0 {
//get dirs
dirs, err := routerRepo.GetModelDirs(job.ID, parentDir)
if err != nil {
log.Error("GetModelDirs failed:%v", err.Error(), ctx.Data["msgID"])
ctx.ServerError("GetModelDirs failed:", err)
return
}


//get dirs
dirs, err := routerRepo.GetModelDirs(job.ID, parentDir)
if err != nil {
log.Error("GetModelDirs failed:%v", err.Error(), ctx.Data["msgID"])
ctx.ServerError("GetModelDirs failed:", err)
return
}
var fileInfos []storage.FileInfo
err = json.Unmarshal([]byte(dirs), &fileInfos)
if err != nil {
log.Error("json.Unmarshal failed:%v", err.Error(), ctx.Data["msgID"])
ctx.ServerError("json.Unmarshal failed:", err)
return
}


var fileInfos []storage.FileInfo
err = json.Unmarshal([]byte(dirs), &fileInfos)
if err != nil {
log.Error("json.Unmarshal failed:%v", err.Error(), ctx.Data["msgID"])
ctx.ServerError("json.Unmarshal failed:", err)
return
}
for i, fileInfo := range fileInfos {
temp, _ := time.Parse("2006-01-02 15:04:05", fileInfo.ModTime)
fileInfos[i].ModTime = temp.Local().Format("2006-01-02 15:04:05")
}


for i, fileInfo := range fileInfos {
temp, _ := time.Parse("2006-01-02 15:04:05", fileInfo.ModTime)
fileInfos[i].ModTime = temp.Local().Format("2006-01-02 15:04:05")
}
sort.Slice(fileInfos, func(i, j int) bool {
return fileInfos[i].ModTime > fileInfos[j].ModTime
})


sort.Slice(fileInfos, func(i, j int) bool {
return fileInfos[i].ModTime > fileInfos[j].ModTime
})
ctx.JSON(http.StatusOK, map[string]interface{}{
"JobID": ID,
"VersionName": "",
"StatusOK": 0,
"Path": dirArray,
"Dirs": fileInfos,
"task": job,
"PageIsCloudBrain": true,
})
} else {
var jobID = ctx.Params(":id")
var versionName = "V0001"
parentDir := ctx.Query("parentDir")
dirArray := strings.Split(parentDir, "/")

models, err := storage.GetObsListObject(job.ID, "output/", parentDir, versionName)
if err != nil {
log.Info("get TrainJobListModel failed:", err)
ctx.ServerError("GetObsListObject:", err)
return
}

ctx.JSON(http.StatusOK, map[string]interface{}{
"JobID": jobID,
"VersionName": versionName,
"StatusOK": 0,
"Path": dirArray,
"Dirs": models,
"task": job,
"PageIsCloudBrain": true,
})
}


ctx.JSON(http.StatusOK, map[string]interface{}{
"JobID": ID,
"VersionName": "",
"StatusOK": 0,
"Path": dirArray,
"Dirs": fileInfos,
"task": job,
"PageIsCloudBrain": true,
})
} }


func CloudBrainModelList(ctx *context.APIContext) { func CloudBrainModelList(ctx *context.APIContext) {


Loading…
Cancel
Save