From d700581bd18613d0efa3816344249f850f50a4ae Mon Sep 17 00:00:00 2001 From: John Chilton Date: Fri, 16 Sep 2022 15:33:34 -0400 Subject: [PATCH] Eliminate configuresgalaxymixin. At this point it is only used in one place so just dump the methods into there. --- lib/galaxy/app.py | 95 +++++++++++++++++------------------ lib/galaxy/config/__init__.py | 6 +++ 2 files changed, 51 insertions(+), 50 deletions(-) diff --git a/lib/galaxy/app.py b/lib/galaxy/app.py index ba065d78c59..3b0b8e62d6c 100644 --- a/lib/galaxy/app.py +++ b/lib/galaxy/app.py @@ -205,9 +205,10 @@ class SentryClientMixin: self.application_stack.register_postfork_function(postfork_sentry_client) -class ConfiguresGalaxyMixin: - """Shared code for configuring Galaxy-like app objects.""" +class MinimalGalaxyApplication(BasicSharedApp, HaltableContainer, SentryClientMixin): + """Encapsulates the state of a minimal Galaxy application""" + model: GalaxyModelMapping config: config.GalaxyAppConfiguration tool_cache: ToolCache job_config: jobs.JobConfiguration @@ -216,6 +217,48 @@ class ConfiguresGalaxyMixin: container_finder: containers.ContainerFinder install_model: ModelMapping + def __init__(self, fsmon=False, **kwargs) -> None: + super().__init__() + self.haltables = [ + ("object store", self._shutdown_object_store), + ("database connection", self._shutdown_model), + ] + self._register_singleton(BasicSharedApp, self) + if not log.handlers: + # Paste didn't handle it, so we need a temporary basic log + # configured. The handler added here gets dumped and replaced with + # an appropriately configured logger in configure_logging below. + logging.basicConfig(level=logging.DEBUG) + log.debug("python path is: %s", ", ".join(sys.path)) + self.name = "galaxy" + self.is_webapp = False + # Read config file and check for errors + self.config: Any = self._register_singleton(config.Configuration, config.Configuration(**kwargs)) + self.config.check() + self._configure_object_store(fsmon=True) + self._register_singleton(BaseObjectStore, self.object_store) + config_file = kwargs.get("global_conf", {}).get("__file__", None) + if config_file: + log.debug('Using "galaxy.ini" config file: %s', config_file) + self._configure_models(check_migrate_databases=self.config.check_migrate_databases, config_file=config_file) + # Security helper + self._configure_security() + self._register_singleton(IdEncodingHelper, self.security) + self._register_singleton(SharedModelMapping, self.model) + self._register_singleton(GalaxyModelMapping, self.model) + self._register_singleton(galaxy_scoped_session, self.model.context) + self._register_singleton(install_model_scoped_session, self.install_model.context) + + def configure_fluent_log(self): + if self.config.fluent_log: + from galaxy.util.custom_logging.fluent_log import FluentTraceLogger + + self.trace_logger: Optional[FluentTraceLogger] = FluentTraceLogger( + "galaxy", self.config.fluent_host, self.config.fluent_port + ) + else: + self.trace_logger = None + def _configure_genome_builds(self, data_table_name="__dbkeys__", load_old_style=True): self.genome_builds = GenomeBuilds(self, data_table_name=data_table_name, load_old_style=load_old_style) @@ -442,54 +485,6 @@ class ConfiguresGalaxyMixin: def tool_dependency_dir(self): return self.toolbox.dependency_manager.default_base_path - -class MinimalGalaxyApplication(BasicSharedApp, ConfiguresGalaxyMixin, HaltableContainer, SentryClientMixin): - """Encapsulates the state of a minimal Galaxy application""" - - model: GalaxyModelMapping - - def __init__(self, fsmon=False, **kwargs) -> None: - super().__init__() - self.haltables = [ - ("object store", self._shutdown_object_store), - ("database connection", self._shutdown_model), - ] - self._register_singleton(BasicSharedApp, self) - if not log.handlers: - # Paste didn't handle it, so we need a temporary basic log - # configured. The handler added here gets dumped and replaced with - # an appropriately configured logger in configure_logging below. - logging.basicConfig(level=logging.DEBUG) - log.debug("python path is: %s", ", ".join(sys.path)) - self.name = "galaxy" - self.is_webapp = False - # Read config file and check for errors - self.config: Any = self._register_singleton(config.Configuration, config.Configuration(**kwargs)) - self.config.check() - self._configure_object_store(fsmon=True) - self._register_singleton(BaseObjectStore, self.object_store) - config_file = kwargs.get("global_conf", {}).get("__file__", None) - if config_file: - log.debug('Using "galaxy.ini" config file: %s', config_file) - self._configure_models(check_migrate_databases=self.config.check_migrate_databases, config_file=config_file) - # Security helper - self._configure_security() - self._register_singleton(IdEncodingHelper, self.security) - self._register_singleton(SharedModelMapping, self.model) - self._register_singleton(GalaxyModelMapping, self.model) - self._register_singleton(galaxy_scoped_session, self.model.context) - self._register_singleton(install_model_scoped_session, self.install_model.context) - - def configure_fluent_log(self): - if self.config.fluent_log: - from galaxy.util.custom_logging.fluent_log import FluentTraceLogger - - self.trace_logger: Optional[FluentTraceLogger] = FluentTraceLogger( - "galaxy", self.config.fluent_host, self.config.fluent_port - ) - else: - self.trace_logger = None - def _shutdown_object_store(self): self.object_store.shutdown() diff --git a/lib/galaxy/config/__init__.py b/lib/galaxy/config/__init__.py index f114da31f56..087269c4c2b 100644 --- a/lib/galaxy/config/__init__.py +++ b/lib/galaxy/config/__init__.py @@ -681,6 +681,12 @@ class GalaxyAppConfiguration(BaseAppConfiguration, CommonConfigurationMixin): database_connection: str tool_path: str tool_data_path: str + new_file_path: str + drmaa_external_runjob_script: str + track_jobs_in_database: bool + monitor_thread_join_timeout: int + manage_dependency_relationships: bool + enable_tool_shed_check: bool builds_file_path: str len_file_path: str integrated_tool_panel_config: str