diff --git a/routers/api/v1/repo/cloudbrain.go b/routers/api/v1/repo/cloudbrain.go index 2dde19aef..aabdc44f8 100755 --- a/routers/api/v1/repo/cloudbrain.go +++ b/routers/api/v1/repo/cloudbrain.go @@ -271,41 +271,65 @@ func CloudBrainModelConvertList(ctx *context.APIContext) { log.Error("GetCloudbrainByJobID(%s) failed:%v", job.Name, err.Error()) 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) {