Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[22.05] Reload built-in converters on toolbox reload #16948

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions lib/galaxy/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,9 +650,6 @@ def __init__(self, **kwargs) -> None:
self.datatypes_registry.load_external_metadata_tool(self.toolbox)
# Load history import/export tools.
load_lib_tools(self.toolbox)
# Load built-in converters
if self.config.display_builtin_converters:
self.toolbox.load_builtin_converters()
self.toolbox.persist_cache(register_postfork=True)
# visualizations registry: associates resources with visualizations, controls how to render
self.visualizations_registry = self._register_singleton(
Expand Down
1 change: 1 addition & 0 deletions lib/galaxy/app_unittest_utils/galaxy_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ def __init__(self, **kwargs):
self.integrated_tool_panel_config = None
self.vault_config_file = kwargs.get("vault_config_file")
self.max_discovered_files = 10000
self.display_builtin_converters = True

@property
def config_dict(self):
Expand Down
3 changes: 3 additions & 0 deletions lib/galaxy/tool_util/toolbox/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1411,6 +1411,9 @@ def __init__(
super().__init__(
config_filenames, tool_root_dir, app, view_sources, default_panel_view, save_integrated_tool_panel
)
# Load built-in converters
if app.config.display_builtin_converters:
self.load_builtin_converters()
old_toolbox = getattr(app, "toolbox", None)
if old_toolbox:
self.dependency_manager = old_toolbox.dependency_manager
Expand Down
30 changes: 21 additions & 9 deletions test/unit/app/tools/test_toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,14 +412,15 @@ def test_group_tools_out_of_section(self):
self._setup_two_versions()
self.__verify_two_test_tools()

# Assert tools merged in tool panel.
assert len(self.toolbox._tool_panel) == 1
# Assert tools merged in tool panel (2nd element is the built in converters section loaded per default)
assert len(self.toolbox._tool_panel) == 2

def test_get_section_by_label(self):
self._add_config(
"""<toolbox><section id="tid" name="Completely unrelated"><label id="lab1" text="Label 1" /><label id="lab2" text="Label 2" /></section></toolbox>"""
)
assert len(self.toolbox._tool_panel) == 1
# assert len of 2: the section + the builtin converters that are loaded per default
assert len(self.toolbox._tool_panel) == 2
section = self.toolbox._tool_panel["tid"]
tool_panel_section_key, section_by_label = self.toolbox.get_section(
section_id="nope", new_label="Completely unrelated", create_if_needed=True
Expand Down Expand Up @@ -466,7 +467,8 @@ def test_workflow_in_panel(self):
stored_workflow = self.__test_workflow()
encoded_id = self.app.security.encode_id(stored_workflow.id)
self._add_config("""<toolbox><workflow id="%s" /></toolbox>""" % encoded_id)
assert len(self.toolbox._tool_panel) == 1
# assert len of 2: the workflow + the builtin converters that are loaded per default
assert len(self.toolbox._tool_panel) == 2
panel_workflow = next(iter(self.toolbox._tool_panel.values()))
assert panel_workflow == stored_workflow.latest_workflow
# TODO: test to_dict with workflows
Expand All @@ -477,22 +479,26 @@ def test_workflow_in_section(self):
self._add_config(
"""<toolbox><section id="tid" name="TID"><workflow id="%s" /></section></toolbox>""" % encoded_id
)
assert len(self.toolbox._tool_panel) == 1
# assert len of 2: the section + the builtin converters that are loaded per default
assert len(self.toolbox._tool_panel) == 2
section = self.toolbox._tool_panel["tid"]
assert len(section.elems) == 1
panel_workflow = next(iter(section.elems.values()))
assert panel_workflow == stored_workflow.latest_workflow

def test_label_in_panel(self):
self._add_config("""<toolbox><label id="lab1" text="Label 1" /><label id="lab2" text="Label 2" /></toolbox>""")
assert len(self.toolbox._tool_panel) == 2

# assert len of 3: 2 labels + the builtin converters that are loaded per default
assert len(self.toolbox._tool_panel) == 3
self.__check_test_labels(self.toolbox._tool_panel)

def test_label_in_section(self):
self._add_config(
"""<toolbox><section id="tid" name="TID"><label id="lab1" text="Label 1" /><label id="lab2" text="Label 2" /></section></toolbox>"""
)
assert len(self.toolbox._tool_panel) == 1
# assert len of 2: section + the builtin converters that are loaded per default
assert len(self.toolbox._tool_panel) == 2
section = self.toolbox._tool_panel["tid"]
self.__check_test_labels(section.elems)

Expand All @@ -510,7 +516,12 @@ def _init_tool_in_section(self, json=False):
self._add_config({"items": [section]}, name="tool_conf.json")

def __check_test_labels(self, panel_dict):
assert list(panel_dict.keys()) == ["label_lab1", "label_lab2"]
# if panel_dict is the complete panel it will contain builtin_converters
# if its a section then not
assert list(panel_dict.keys()) in (
["label_lab1", "label_lab2", "builtin_converters"],
["label_lab1", "label_lab2"],
)
label1 = next(iter(panel_dict.values()))
assert label1.id == "lab1"
assert label1.text == "Label 1"
Expand Down Expand Up @@ -584,7 +595,8 @@ def __init_versioned_tools(self):
self._init_tool(filename="tool_v02.xml", version="0.2")

def __verify_tool_panel_for_default_lineage(self):
assert len(self.toolbox._tool_panel) == 1
# assert len of 2: the section + the builtin converters that are loaded per default
assert len(self.toolbox._tool_panel) == 2
tool = self.toolbox._tool_panel["tool_test_tool"]
assert tool.version == "0.2", tool.version
assert tool.id == "test_tool"
Expand Down
9 changes: 6 additions & 3 deletions test/unit/shed_unit/test_tool_panel_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,23 @@ def test_handle_tool_panel_section(self):
assert section_id == "tid"
assert len(section.elems) == 1 # tool.xml
assert section.id == "tid"
assert len(toolbox._tool_panel) == 1
# assert len of 2: the section + the builtin converters that are loaded per default
assert len(toolbox._tool_panel) == 2

section_id, section = tpm.handle_tool_panel_section(toolbox, new_tool_panel_section_label="tid2")
assert section_id == "tid2"
assert len(section.elems) == 0 # new section
assert section.id == "tid2"
assert len(toolbox._tool_panel) == 2
# assert len of 3: tid, tid2 + the builtin converters that are loaded per default
assert len(toolbox._tool_panel) == 3

# Test re-fetch new section by same id.
section_id, section = tpm.handle_tool_panel_section(toolbox, new_tool_panel_section_label="tid2")
assert section_id == "tid2"
assert len(section.elems) == 0 # new section
assert section.id == "tid2"
assert len(toolbox._tool_panel) == 2
# assert len of 3: tid, tid2 + the builtin converters that are loaded per default
assert len(toolbox._tool_panel) == 3

def test_add_tool_to_panel(self):
self._init_ts_tool(guid=DEFAULT_GUID)
Expand Down
Loading