From d9c66de52cc4ecbb77cd4ef9877821bbd8d6d897 Mon Sep 17 00:00:00 2001 From: Oleg Zharkov Date: Thu, 4 Feb 2021 17:04:52 +0100 Subject: [PATCH] fix composite images report --- .../Dataset/DatasetIndex/DatasetIndex.vue | 5 +---- .../src/components/Dataset/compositeDatasetUtils.js | 6 +----- lib/galaxy/managers/markdown_util.py | 13 ++++++++++++- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/client/src/components/Dataset/DatasetIndex/DatasetIndex.vue b/client/src/components/Dataset/DatasetIndex/DatasetIndex.vue index 762e014b574..fb89015727e 100644 --- a/client/src/components/Dataset/DatasetIndex/DatasetIndex.vue +++ b/client/src/components/Dataset/DatasetIndex/DatasetIndex.vue @@ -46,10 +46,7 @@ export default { pathDestination.filepath ); } else if (this.path === undefined || this.path === "undefined") { - this.directoryContent = this.removeParentDirectory( - pathDestination.datasetContent, - pathDestination.datasetRootDir - ); + this.directoryContent = pathDestination.datasetContent } else { this.errorMessage = `is not found!`; } diff --git a/client/src/components/Dataset/compositeDatasetUtils.js b/client/src/components/Dataset/compositeDatasetUtils.js index 67a0bdf5f27..9c83c561314 100644 --- a/client/src/components/Dataset/compositeDatasetUtils.js +++ b/client/src/components/Dataset/compositeDatasetUtils.js @@ -6,15 +6,11 @@ export const getPathDestination = async (history_dataset_id, path) => { const services = new Services({ root: getAppRoot() }); const computePathDestination = (pathDestination) => { - if (pathDestination.datasetContent[0].class === "Directory") - pathDestination.datasetRootDir = datasetContent[0].path; - else return; - if (path === undefined || path === "undefined") { return pathDestination; } - const filepath = `${pathDestination.datasetRootDir}/${path}`; + const filepath = path; const datasetEntry = datasetContent.find((datasetEntry) => { return filepath === datasetEntry.path; diff --git a/lib/galaxy/managers/markdown_util.py b/lib/galaxy/managers/markdown_util.py index 70b3e23608d..369889c4bef 100644 --- a/lib/galaxy/managers/markdown_util.py +++ b/lib/galaxy/managers/markdown_util.py @@ -45,6 +45,7 @@ ARG_VAL_CAPTURED_REGEX = r'''(?:([\w_\-]+)|\"([^\"]+)\"|\'([^\']+)\')''' OUTPUT_LABEL_PATTERN = re.compile(r'output=\s*%s\s*' % ARG_VAL_CAPTURED_REGEX) INPUT_LABEL_PATTERN = re.compile(r'input=\s*%s\s*' % ARG_VAL_CAPTURED_REGEX) STEP_LABEL_PATTERN = re.compile(r'step=\s*%s\s*' % ARG_VAL_CAPTURED_REGEX) +PATH_LABEL_PATTERN = re.compile(r'path=\s*%s\s*' % ARG_VAL_CAPTURED_REGEX) # STEP_OUTPUT_LABEL_PATTERN = re.compile(r'step_output=([\w_\-]+)/([\w_\-]+)') UNENCODED_ID_PATTERN = re.compile(r'(workflow_id|history_dataset_id|history_dataset_collection_id|job_id|invocation_id)=([\d]+)') ENCODED_ID_PATTERN = re.compile(r'(workflow_id|history_dataset_id|history_dataset_collection_id|job_id|invocation_id)=([a-z0-9]+)') @@ -378,7 +379,17 @@ class ToBasicMarkdownDirectiveHandler(GalaxyInternalMarkdownDirectiveHandler): def handle_dataset_as_image(self, line, hda): dataset = hda.dataset name = hda.name or '' - with open(dataset.file_name, "rb") as f: + + filepath = re.search(PATH_LABEL_PATTERN, line).group(2) + + + if "path" in line: + file = os.path.join(hda.extra_files_path, filepath) + else: + file = dataset.file_name + + with open(file, "rb") as f: + base64_image_data = base64.b64encode(f.read()).decode("utf-8") rval = ("![{}](data:image/png;base64,{})".format(name, base64_image_data), True) return rval