From 920549b66b9d858eb43c7c8f82ee8d6823cea407 Mon Sep 17 00:00:00 2001 From: Helena Rasche Date: Fri, 30 Oct 2020 16:48:15 +0100 Subject: [PATCH] Hide unused labels, remove logging Re-add uncategorized, remove WFs, not sure working --- lib/galaxy/tools/toolbox/base.py | 71 ++++++++++++++----------- test/unit/unittest_utils/galaxy_mock.py | 1 + 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/lib/galaxy/tools/toolbox/base.py b/lib/galaxy/tools/toolbox/base.py index 328d98f0e553..6e4f8b6a26a5 100644 --- a/lib/galaxy/tools/toolbox/base.py +++ b/lib/galaxy/tools/toolbox/base.py @@ -8,8 +8,8 @@ OrderedDict ) from errno import ENOENT -from urllib.parse import urlparse import urllib.request +from urllib.parse import urlparse from markupsafe import escape @@ -473,7 +473,6 @@ def _edam_children_of(self, parentTerm): if parentTerm in self.edam[term]['parents']: yield term - def _load_tool_panel_edam(self): execution_timer = ExecutionTimer() @@ -506,17 +505,21 @@ def _load_tool_panel_edam(self): uncategorized.append((tool_id, key, val, val.name)) else: for path in self.edam[term]['path']: - # For 2 component paths, it works, for 1 it does too. + if len(path) == 1: + t = term + else: + t = path[0] + if path[0].startswith('operation_'): - operations[path[0]][tool_id] = (term, tool_id, key, val, val.name) - if path[0].startswith('topic_'): - topics[path[0]][tool_id] = (term, tool_id, key, val, val.name) - elif item_type == panel_item_types.WORKFLOW: - workflow_id = key.replace('workflow_', '', 1) - if workflow_id in self._workflows_by_id: - workflow = self._workflows_by_id[workflow_id] - self._tool_panel[key] = workflow - log.debug(f"Loaded workflow: {workflow_id} {workflow.name}") + operations[t][tool_id] = (term, tool_id, key, val, val.name) + elif path[0].startswith('topic_'): + topics[t][tool_id] = (term, tool_id, key, val, val.name) + # elif item_type == panel_item_types.WORKFLOW: + # workflow_id = key.replace('workflow_', '', 1) + # if workflow_id in self._workflows_by_id: + # workflow = self._workflows_by_id[workflow_id] + # self._tool_panel[key] = workflow + # log.debug(f"Loaded workflow: {workflow_id} {workflow.name}") elif item_type == panel_item_types.SECTION: for section_key, section_item_type, section_val in val.panel_items_iter(): if section_item_type == panel_item_types.TOOL: @@ -524,30 +527,30 @@ def _load_tool_panel_edam(self): if tool_id in self._tools_by_id: for term, label in self._get_edam_sec(section_val): if term == 'uncategorized': - uncategorized.append((tool_id, key, val, val.name)) + uncategorized.append((tool_id, key, section_val, val.name)) else: for path in self.edam[term]['path']: - # For 2 component paths, it works, for 1 it does too. + if len(path) == 1: + t = term + else: + t = path[0] + if path[0].startswith('operation_'): - operations[path[0]][tool_id] = (term, tool_id, key, section_val, val.name) + operations[t][tool_id] = (term, tool_id, key, section_val, val.name) if path[0].startswith('topic_'): - topics[path[0]][tool_id] = (term, tool_id, key, section_val, val.name) - # for section in self._get_section(section_val): - # self.__add_tool_to_tool_panel(section_val, section, section=True) - # self._integrated_section_by_tool[tool_id] = key, val.name - elif section_item_type == panel_item_types.WORKFLOW: - workflow_id = section_key.replace('workflow_', '', 1) - if workflow_id in self._workflows_by_id: - workflow = self._workflows_by_id[workflow_id] - section.elems[section_key] = workflow - log.debug(f"Loaded workflow: {workflow_id} {workflow.name}") + topics[t][tool_id] = (term, tool_id, key, section_val, val.name) + # elif section_item_type == panel_item_types.WORKFLOW: + # workflow_id = section_key.replace('workflow_', '', 1) + # if workflow_id in self._workflows_by_id: + # workflow = self._workflows_by_id[workflow_id] + # section.elems[section_key] = workflow + # log.debug(f"Loaded workflow: {workflow_id} {workflow.name}") log.debug("Loading tool panel finished %s", execution_timer) - # print(operations.keys()) - # print([self._sort_edam_key(x) for x in operations.keys()]) - # print(sorted(operations.keys(), lambda x: self._sort_edam_key(x))) - for term in sorted(operations.keys(), key=lambda x: self._sort_edam_key(x)): + if len(operations[term].keys()) == 0: + continue + elem = etree.Element('label') elem.attrib['text'] = self.edam[term]['label'] elem.attrib['id'] = term @@ -559,6 +562,9 @@ def _load_tool_panel_edam(self): self._integrated_section_by_tool[tool_id] = key, val_name for term in sorted(topics.keys(), key=lambda x: self._sort_edam_key(x)): + if len(topics[term].keys()) == 0: + continue + elem = etree.Element('label') elem.attrib['text'] = self.edam[term]['label'] elem.attrib['id'] = term @@ -570,9 +576,10 @@ def _load_tool_panel_edam(self): self._integrated_section_by_tool[tool_id] = key, val_name section = self._get_section('uncategorized', 'Uncategorized') - # for (tool_id, key, val, val_name) in uncategorized: - # self.__add_tool_to_tool_panel(val, section, section=True) - # self._integrated_section_by_tool[tool_id] = key, val_name + for (tool_id, key, val, val_name) in uncategorized: + print(tool_id, key, val, val_name) + self.__add_tool_to_tool_panel(val, section, section=True) + self._integrated_section_by_tool[tool_id] = key, val_name def _sort_edam_key(self, x): if x in ('operation_0004', 'topic_0003'): diff --git a/test/unit/unittest_utils/galaxy_mock.py b/test/unit/unittest_utils/galaxy_mock.py index 2fc39759f5f2..1f55af673fbe 100644 --- a/test/unit/unittest_utils/galaxy_mock.py +++ b/test/unit/unittest_utils/galaxy_mock.py @@ -162,6 +162,7 @@ def __init__(self, root=None, **kwargs): self.shed_tool_config_file = "config/shed_tool_conf.xml" self.shed_tool_config_file_set = False + self.enable_beta_edam_toolbox = False self.preserve_python_environment = "always" self.enable_beta_gdpr = False self.legacy_eager_objectstore_initialization = True