Skip to content

Commit

Permalink
Move ConfigWatchers into galaxy.webapps.galaxy.config_watchers
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdbeek committed Apr 3, 2017
1 parent c857388 commit 1a5e337
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 44 deletions.
1 change: 1 addition & 0 deletions .ci/flake8_lint_include_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
43 changes: 0 additions & 43 deletions lib/galaxy/tools/toolbox/watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down
47 changes: 47 additions & 0 deletions lib/galaxy/webapps/galaxy/config_watchers.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1a5e337

Please sign in to comment.