diff --git a/.ci/flake8_lint_include_list.txt b/.ci/flake8_lint_include_list.txt index bdb890cf6c61..bf488e8cf5bb 100644 --- a/.ci/flake8_lint_include_list.txt +++ b/.ci/flake8_lint_include_list.txt @@ -185,6 +185,7 @@ lib/galaxy/webapps/galaxy/controllers/requests.py lib/galaxy/webapps/galaxy/controllers/search.py lib/galaxy/webapps/galaxy/controllers/tool_runner.py lib/galaxy/webapps/galaxy/controllers/userskeys.py +lib/galaxy/webapps/galaxy/config_watchers.py lib/galaxy/webapps/galaxy/__init__.py lib/galaxy/webapps/__init__.py lib/galaxy/webapps/reports/config.py diff --git a/lib/galaxy/app.py b/lib/galaxy/app.py index 65fd5644d4cf..04fedaeb90e3 100644 --- a/lib/galaxy/app.py +++ b/lib/galaxy/app.py @@ -16,8 +16,8 @@ from galaxy.visualization.data_providers.registry import DataProviderRegistry from galaxy.visualization.plugins.registry import VisualizationsRegistry from galaxy.tools.special_tools import load_lib_tools -from galaxy.tools.toolbox.watcher import ConfigWatchers from galaxy.tours import ToursRegistry +from galaxy.webapps.galaxy.config_watchers import ConfigWatchers from galaxy.webhooks import WebhooksRegistry from galaxy.sample_tracking import external_service_types from galaxy.openid.providers import OpenIDProviders diff --git a/lib/galaxy/tools/toolbox/watcher.py b/lib/galaxy/tools/toolbox/watcher.py index 881eba472a27..d658f0fab151 100644 --- a/lib/galaxy/tools/toolbox/watcher.py +++ b/lib/galaxy/tools/toolbox/watcher.py @@ -14,10 +14,6 @@ PollingObserver = None can_watch = False -from galaxy.queue_worker import ( - reload_data_managers, - reload_toolbox, -) from galaxy.util.hash_util import md5_hash_file from galaxy.web.stack import register_postfork_function @@ -75,45 +71,6 @@ def get_tool_watcher(toolbox, config): return NullWatcher() -class ConfigWatchers(object): - """Contains ToolConfWatcher, ToolWatcher and ToolDataWatcher objects.""" - - def __init__(self, app): - self.app = app - self.tool_config_watcher = get_tool_conf_watcher(reload_callback=lambda: reload_toolbox(self.app), tool_cache=self.app.tool_cache) - self.data_manager_config_watcher = get_tool_conf_watcher(reload_callback=lambda: reload_data_managers(self.app), tool_cache=self.app.tool_cache) - self.tool_data_watcher = get_tool_data_dir_watcher(self.app.tool_data_tables, config=self.app.config) - self.start() - - def start(self): - [self.tool_config_watcher.watch_file(config) for config in self.tool_config_paths] - [self.data_manager_config_watcher.watch_file(config) for config in self.data_manager_configs] - [self.tool_data_watcher.watch_directory(tool_data_path) for tool_data_path in self.tool_data_paths] - - @property - def data_manager_configs(self): - data_manager_configs = [] - data_manager_configs.append(self.app.config.data_manager_config_file) - if self.app.config.shed_data_manager_config_file: - data_manager_configs.append(self.app.config.shed_data_manager_config_file) - return data_manager_configs - - @property - def tool_data_paths(self): - tool_data_paths = [] - tool_data_paths.append(self.app.config.tool_data_path) - if self.app.config.shed_tool_data_path: - tool_data_paths.append(self.app.config.shed_tool_data_path) - return tool_data_paths - - @property - def tool_config_paths(self): - tool_config_paths = self.app.config.tool_configs - if self.app.config.migrated_tools_config not in tool_config_paths: - tool_config_paths.append( self.app.config.migrated_tools_config ) - return tool_config_paths - - class ToolConfWatcher(object): def __init__(self, reload_callback, tool_cache=None): diff --git a/lib/galaxy/webapps/galaxy/config_watchers.py b/lib/galaxy/webapps/galaxy/config_watchers.py new file mode 100644 index 000000000000..0dd5c22a7c30 --- /dev/null +++ b/lib/galaxy/webapps/galaxy/config_watchers.py @@ -0,0 +1,47 @@ +from galaxy.queue_worker import ( + reload_data_managers, + reload_toolbox, +) +from galaxy.tools.toolbox.watcher import ( + get_tool_conf_watcher, + get_tool_data_dir_watcher +) + + +class ConfigWatchers(object): + """Contains ToolConfWatcher, ToolWatcher and ToolDataWatcher objects.""" + + def __init__(self, app): + self.app = app + self.tool_config_watcher = get_tool_conf_watcher(reload_callback=lambda: reload_toolbox(self.app), tool_cache=self.app.tool_cache) + self.data_manager_config_watcher = get_tool_conf_watcher(reload_callback=lambda: reload_data_managers(self.app), tool_cache=self.app.tool_cache) + self.tool_data_watcher = get_tool_data_dir_watcher(self.app.tool_data_tables, config=self.app.config) + self.start() + + def start(self): + [self.tool_config_watcher.watch_file(config) for config in self.tool_config_paths] + [self.data_manager_config_watcher.watch_file(config) for config in self.data_manager_configs] + [self.tool_data_watcher.watch_directory(tool_data_path) for tool_data_path in self.tool_data_paths] + + @property + def data_manager_configs(self): + data_manager_configs = [] + data_manager_configs.append(self.app.config.data_manager_config_file) + if self.app.config.shed_data_manager_config_file: + data_manager_configs.append(self.app.config.shed_data_manager_config_file) + return data_manager_configs + + @property + def tool_data_paths(self): + tool_data_paths = [] + tool_data_paths.append(self.app.config.tool_data_path) + if self.app.config.shed_tool_data_path: + tool_data_paths.append(self.app.config.shed_tool_data_path) + return tool_data_paths + + @property + def tool_config_paths(self): + tool_config_paths = self.app.config.tool_configs + if self.app.config.migrated_tools_config not in tool_config_paths: + tool_config_paths.append( self.app.config.migrated_tools_config ) + return tool_config_paths