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.
This commit is contained in:
mvdbeek
2026-07-28 17:27:48 +02:00
parent 40b682d706
commit 0843c364c9
4 changed files with 7 additions and 6 deletions
+2 -3
View File
@@ -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
@@ -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__()
+1 -1
View File
@@ -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,
+2 -2
View File
@@ -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