Skip to content

Commit

Permalink
Hide unused labels, remove logging
Browse files Browse the repository at this point in the history
Re-add uncategorized, remove WFs, not sure working
  • Loading branch information
hexylena committed Oct 30, 2020
1 parent e506ebf commit 920549b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 32 deletions.
71 changes: 39 additions & 32 deletions lib/galaxy/tools/toolbox/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -506,48 +505,52 @@ 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:
tool_id = section_key.replace('tool_', '', 1)
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
Expand All @@ -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
Expand All @@ -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'):
Expand Down
1 change: 1 addition & 0 deletions test/unit/unittest_utils/galaxy_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 920549b

Please sign in to comment.