From b601802e0220130c01daa96973feb38e2b41b718 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Tue, 8 Oct 2024 23:36:13 -0400 Subject: [PATCH] Cleaner startup when there are tool problems. --- lib/galaxy/tool_util/toolbox/__init__.py | 2 ++ lib/galaxy/tool_util/toolbox/base.py | 8 ++++++++ lib/galaxy/tools/__init__.py | 11 +++++++---- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/galaxy/tool_util/toolbox/__init__.py b/lib/galaxy/tool_util/toolbox/__init__.py index 34c2070b09f1..b0d611cbff4f 100644 --- a/lib/galaxy/tool_util/toolbox/__init__.py +++ b/lib/galaxy/tool_util/toolbox/__init__.py @@ -3,6 +3,7 @@ from .base import ( AbstractToolBox, AbstractToolTagManager, + ToolLoadError, ) from .panel import ( panel_item_types, @@ -14,6 +15,7 @@ "AbstractToolBox", "AbstractToolTagManager", "panel_item_types", + "ToolLoadError", "ToolSection", "ToolSectionLabel", ) diff --git a/lib/galaxy/tool_util/toolbox/base.py b/lib/galaxy/tool_util/toolbox/base.py index f6ab7bfa98f1..a04845f65ab8 100644 --- a/lib/galaxy/tool_util/toolbox/base.py +++ b/lib/galaxy/tool_util/toolbox/base.py @@ -133,6 +133,10 @@ def handle_tags(self, tool_id, tool_definition_source) -> None: return None +class ToolLoadError(Exception): + pass + + class AbstractToolBox(ManagesIntegratedToolPanelMixin): """ Abstract container for managing a ToolPanel - containing tools and @@ -1073,6 +1077,10 @@ def quick_load(tool_file, async_load=True): self._load_tool_panel_views() self._save_integrated_tool_panel() return tool.id + except ToolLoadError as e: + # no need for full stack trace - ToolLoadError corresponds to a known load + # error with defined cause that is included in the message + log.error(f"Failed to load potential tool {tool_file} - {e}") except Exception: log.exception("Failed to load potential tool %s.", tool_file) return None diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index a7b6c96bc1f3..16fcfce0ba8e 100644 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -95,6 +95,7 @@ from galaxy.tool_util.toolbox import ( AbstractToolBox, AbstractToolTagManager, + ToolLoadError, ToolSection, ) from galaxy.tool_util.toolbox.views.sources import StaticToolBoxViewSources @@ -380,7 +381,10 @@ def create_tool_from_source(app, tool_source: ToolSource, config_file: Optional[ elif tool_type := tool_source.parse_tool_type(): ToolClass = tool_types.get(tool_type) if not ToolClass: - raise ValueError(f"Unrecognized tool type: {tool_type}") + if tool_type == "cwl": + raise ToolLoadError("Runtime support for CWL tools is not implemented currently") + else: + raise ToolLoadError(f"Parsed unrecognized tool type ({tool_type}) from tool") else: # Normal tool root = getattr(tool_source, "root", None) @@ -3227,9 +3231,8 @@ class InteractiveTool(Tool): produces_entry_points = True def __init__(self, config_file, tool_source, app, **kwd): - assert app.config.interactivetools_enable, ValueError( - "Trying to load an InteractiveTool, but InteractiveTools are not enabled." - ) + if not app.config.interactivetools_enable: + raise ToolLoadError("Trying to load an InteractiveTool, but InteractiveTools are not enabled.") super().__init__(config_file, tool_source, app, **kwd) def __remove_interactivetool_by_job(self, job):