diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index d48449f15c7..8120dc676fa 100755 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -24,6 +24,7 @@ from galaxy import model from galaxy.managers import histories from galaxy.datatypes.metadata import JobExternalOutputMetadataWrapper from galaxy import exceptions +from galaxy.queue_worker import reload_toolbox from galaxy.tools.actions import DefaultToolAction from galaxy.tools.actions.upload import UploadToolAction from galaxy.tools.actions.data_source import DataSourceToolAction @@ -103,6 +104,7 @@ class ToolBox( BaseGalaxyToolBox ): """ def __init__( self, config_filenames, tool_root_dir, app, tool_conf_watcher=None ): + self._reload_count = 0 super( ToolBox, self ).__init__( config_filenames=config_filenames, tool_root_dir=tool_root_dir, @@ -110,6 +112,12 @@ class ToolBox( BaseGalaxyToolBox ): tool_conf_watcher=tool_conf_watcher ) + def handle_reload_toolbox(self): + reload_toolbox(self.app) + + def has_reloaded(self, other_toolbox): + return self._reload_count != other_toolbox._reload_count + @property def all_requirements(self): reqs = [json.dumps(req, sort_keys=True) for _, tool in self.tools() for req in tool.tool_requirements] diff --git a/lib/galaxy/tools/toolbox/base.py b/lib/galaxy/tools/toolbox/base.py index f549bbeada0..2ac9b8e7221 100644 --- a/lib/galaxy/tools/toolbox/base.py +++ b/lib/galaxy/tools/toolbox/base.py @@ -9,7 +9,6 @@ from six import iteritems from six.moves.urllib.parse import urlparse from galaxy.exceptions import ObjectNotFound -from galaxy.queue_worker import reload_toolbox # Next two are extra tool dependency not used by AbstractToolBox but by # BaseGalaxyToolBox. from galaxy.tools.deps import build_dependency_manager @@ -62,7 +61,6 @@ class AbstractToolBox( Dictifiable, ManagesIntegratedToolPanelMixin, object ): # In-memory dictionary that defines the layout of the tool panel. self._tool_panel = ToolPanelElements() self._index = 0 - self._reload_count = 0 self.data_manager_tools = odict() self._lineage_map = LineageMap( app ) # Sets self._integrated_tool_panel and self._integrated_tool_panel_config_has_contents @@ -75,7 +73,7 @@ class AbstractToolBox( Dictifiable, ManagesIntegratedToolPanelMixin, object ): if tool_conf_watcher: self._tool_conf_watcher = tool_conf_watcher # Avoids (re-)starting threads in uwsgi else: - self._tool_conf_watcher = get_tool_conf_watcher( lambda: reload_toolbox(app)) + self._tool_conf_watcher = get_tool_conf_watcher(lambda: self.handle_reload_toolbox()) self._filter_factory = FilterFactory( self ) self._tool_tag_manager = tool_tag_manager( app ) self._init_tools_from_configs( config_filenames ) @@ -84,8 +82,12 @@ class AbstractToolBox( Dictifiable, ManagesIntegratedToolPanelMixin, object ): self._load_tool_panel() self._save_integrated_tool_panel() - def has_reloaded(self, other_toolbox): - return self._reload_count != other_toolbox._reload_count + def handle_reload_toolbox(self): + """Extension-point for Galaxy-app specific reload logic. + + This abstract representation of the toolbox shouldn't have details about + interacting with the rest of the Galaxy app or message queues, etc.... + """ def create_tool( self, config_file, repository_id=None, guid=None, **kwds ): raise NotImplementedError()