Skip to content

Commit

Permalink
Cleaner startup when there are tool problems.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Oct 18, 2024
1 parent ccddeaa commit b601802
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 2 additions & 0 deletions lib/galaxy/tool_util/toolbox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from .base import (
AbstractToolBox,
AbstractToolTagManager,
ToolLoadError,
)
from .panel import (
panel_item_types,
Expand All @@ -14,6 +15,7 @@
"AbstractToolBox",
"AbstractToolTagManager",
"panel_item_types",
"ToolLoadError",
"ToolSection",
"ToolSectionLabel",
)
8 changes: 8 additions & 0 deletions lib/galaxy/tool_util/toolbox/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions lib/galaxy/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
from galaxy.tool_util.toolbox import (
AbstractToolBox,
AbstractToolTagManager,
ToolLoadError,
ToolSection,
)
from galaxy.tool_util.toolbox.views.sources import StaticToolBoxViewSources
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit b601802

Please sign in to comment.