diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index 922c6f42357..f1ba0711c10 100755 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -255,6 +255,19 @@ class ToolBox(BaseGalaxyToolBox): app=app, ) + def can_load_config_file(self, config_filename): + if config_filename == self.app.config.shed_tool_config_file and not self.app.config.shed_tool_config_file_set: + if self.dynamic_confs(): + # Do not load or create a default shed_tool_config_file if another shed_tool_config file has already been loaded + return False + elif self.app.config.tool_config_file_set: + log.warning( + "The default shed tool config file (%s) has been added to the tool_config_file option, if this is " + "not the desired behavior, please set shed_tool_config_file to your primary shed-enabled tool " + "config file", self.app.config.shed_tool_config_file + ) + return True + def has_reloaded(self, other_toolbox): return self._reload_count != other_toolbox._reload_count diff --git a/lib/galaxy/tools/toolbox/base.py b/lib/galaxy/tools/toolbox/base.py index 536cc6f876a..1df15984b40 100644 --- a/lib/galaxy/tools/toolbox/base.py +++ b/lib/galaxy/tools/toolbox/base.py @@ -127,6 +127,9 @@ class AbstractToolBox(Dictifiable, ManagesIntegratedToolPanelMixin): def create_dynamic_tool(self, dynamic_tool): raise NotImplementedError() + def can_load_config_file(self, config_filename): + return True + def _init_tools_from_configs(self, config_filenames): """ Read through all tool config files and initialize tools in each with init_tools_from_config below. @@ -141,16 +144,8 @@ class AbstractToolBox(Dictifiable, ManagesIntegratedToolPanelMixin): config_filenames.remove(config_filename) config_filenames.extend(directory_config_files) for config_filename in config_filenames: - if config_filename == self.app.config.shed_tool_config_file and not self.app.config.shed_tool_config_file_set: - if self.dynamic_confs(): - # Do not load or create a default shed_tool_config_file if another shed_tool_config file has already been loaded - continue - elif self.app.config.tool_config_file_set: - log.warning( - "The default shed tool config file (%s) has been added to the tool_config_file option, if this is " - "not the desired behavior, please set shed_tool_config_file to your primary shed-enabled tool " - "config file", self.app.config.shed_tool_config_file - ) + if not self.can_load_config_file(config_filename): + continue try: self._init_tools_from_config(config_filename) except ParseError: diff --git a/test/unit/unittest_utils/galaxy_mock.py b/test/unit/unittest_utils/galaxy_mock.py index f86abd25987..38f0d8cd367 100644 --- a/test/unit/unittest_utils/galaxy_mock.py +++ b/test/unit/unittest_utils/galaxy_mock.py @@ -145,6 +145,8 @@ class MockAppConfig(Bunch): self.builds_file_path = os.path.join('tool-data', 'shared', 'ucsc', 'builds.txt.sample') self.migrated_tools_config = "/tmp/migrated_tools_conf.xml" + self.shed_tool_config_file = "config/shed_tool_conf.xml" + self.shed_tool_config_file_set = False self.preserve_python_environment = "always" self.enable_beta_gdpr = False self.legacy_eager_objectstore_initialization = True