From 0843c364c91b16aa9d62aecc6532232086a1eb33 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Wed, 15 Jul 2026 17:48:48 +0200 Subject: [PATCH] app: declare tool_source_store, drop the getattr guards _init_tool_source_store assigns the attribute unconditionally (None when use_cached_toolbox is off), so every real app has it; the getattr spellings only papered over mock apps, which now declare the attribute instead. --- lib/galaxy/app/__init__.py | 5 ++--- lib/galaxy/app_unittest_utils/galaxy_mock.py | 2 ++ lib/galaxy/queue_worker/__init__.py | 2 +- lib/galaxy/tools/__init__.py | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/galaxy/app/__init__.py b/lib/galaxy/app/__init__.py index 6abc50fa324..a178f2df245 100644 --- a/lib/galaxy/app/__init__.py +++ b/lib/galaxy/app/__init__.py @@ -451,10 +451,9 @@ class MinimalGalaxyApplication(BasicSharedApp, HaltableContainer, SentryClientMi self.haltables.insert(2, ("cached toolbox", self._shutdown_cached_toolbox)) def _shutdown_tool_source_store(self) -> None: - store = getattr(self, "tool_source_store", None) - if store is not None: + if self.tool_source_store is not None: try: - store.close() + self.tool_source_store.close() finally: self.tool_source_store = None diff --git a/lib/galaxy/app_unittest_utils/galaxy_mock.py b/lib/galaxy/app_unittest_utils/galaxy_mock.py index 62cf068baf7..7574e457079 100644 --- a/lib/galaxy/app_unittest_utils/galaxy_mock.py +++ b/lib/galaxy/app_unittest_utils/galaxy_mock.py @@ -70,6 +70,7 @@ from galaxy.tool_util.deps.containers import NullContainerFinder from galaxy.tools import ToolBox from galaxy.tools.cache import ToolCache from galaxy.tools.data import ToolDataTableManager +from galaxy.tools.source_store import ToolSourceStore from galaxy.util import ( galaxy_directory, StructuredExecutionTimer, @@ -126,6 +127,7 @@ class MockApp(di.Container, GalaxyDataTestApp): execution_timer_factory: Any stop: bool is_webapp: bool = True + tool_source_store: ToolSourceStore | None = None def __init__(self, config=None, **kwargs) -> None: super().__init__() diff --git a/lib/galaxy/queue_worker/__init__.py b/lib/galaxy/queue_worker/__init__.py index a869697b0ad..969a2d69035 100644 --- a/lib/galaxy/queue_worker/__init__.py +++ b/lib/galaxy/queue_worker/__init__.py @@ -297,7 +297,7 @@ def _get_new_toolbox(app: "UniverseApplication", save_integrated_tool_panel: boo with app._toolbox_lock: new_toolbox: ToolBox - if getattr(app.config, "use_cached_toolbox", False) and getattr(app, "tool_source_store", None) is not None: + if app.config.use_cached_toolbox and app.tool_source_store is not None: new_toolbox = CachedToolBox( config_filenames=tool_configs, tool_root_dir=app.config.tool_path, diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index b1fa349fa87..fd57bc6bfef 100644 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -566,7 +566,7 @@ class ToolBox(AbstractToolBox): file_count = self._tools_parsed_from_file if store_count > 0 or file_count > 0: - store = getattr(self.app, "tool_source_store", None) + store = self.app.tool_source_store backend = "unknown" if store: try: @@ -697,7 +697,7 @@ class ToolBox(AbstractToolBox): if not self.app.config.use_cached_toolbox: return None - store = getattr(self.app, "tool_source_store", None) + store = self.app.tool_source_store if store is None: return None