From f009b75841f93682694099c029179cbbba561c75 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Wed, 10 Apr 2024 15:06:11 +0200 Subject: [PATCH] Make sure `data_dir` is used for default result backend DB --- doc/source/admin/galaxy_options.rst | 7 ++++--- lib/galaxy/config/__init__.py | 14 ++++++++++++++ lib/galaxy/config/sample/galaxy.yml.sample | 7 ++++--- lib/galaxy/config/schemas/config_schema.yml | 4 ++-- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/doc/source/admin/galaxy_options.rst b/doc/source/admin/galaxy_options.rst index 5cd5d4d2649f..a8a7066d2554 100644 --- a/doc/source/admin/galaxy_options.rst +++ b/doc/source/admin/galaxy_options.rst @@ -5154,9 +5154,10 @@ only if you have setup a Celery worker for Galaxy and you have configured the `celery_conf` option below. Specifically, you need to set the `result_backend` option in the `celery_conf` option to - a valid Celery result backend URL. By default a SQLite database is - used for storing task results, please use a more robust backend - for production setups like Redis. For details, see + a valid Celery result backend URL. By default, Galaxy uses an + SQLite database at '/results.sqlite' for storing task + results. Please use a more robust backend for production setups + like Redis. For details, see https://docs.galaxyproject.org/en/master/admin/production.html#use-celery-for-asynchronous-tasks :Default: ``false`` :Type: bool diff --git a/lib/galaxy/config/__init__.py b/lib/galaxy/config/__init__.py index ce8e5e8dc2b0..886da6328cea 100644 --- a/lib/galaxy/config/__init__.py +++ b/lib/galaxy/config/__init__.py @@ -1082,6 +1082,9 @@ def _process_config(self, kwargs: Dict[str, Any]) -> None: self.amqp_internal_connection = ( f"sqlalchemy+sqlite:///{self._in_data_dir('control.sqlite')}?isolation_level=IMMEDIATE" ) + + self._process_celery_config(kwargs) + self.pretty_datetime_format = expand_pretty_datetime_format(self.pretty_datetime_format) try: with open(self.user_preferences_extra_conf_path) as stream: @@ -1203,6 +1206,17 @@ def _load_theme(path: str, theme_dict: dict): else: _load_theme(self.themes_config_file, self.themes) + def _process_celery_config(self, kwargs): + self.celery_conf = kwargs.get("celery_conf") + if self.celery_conf: + result_backend = self.celery_conf.get("result_backend") + if result_backend: + # If the result_backend is the default SQLite database, we need to + # ensure that the correct data directory is used. + if "results.sqlite" in result_backend: + result_backend = f"db+sqlite:///{self._in_data_dir('results.sqlite')}?isolation_level=IMMEDIATE" + self.celery_conf["result_backend"] = result_backend + def _check_database_connection_strings(self): """ Verify connection URI strings in galaxy's configuration are parseable with urllib. diff --git a/lib/galaxy/config/sample/galaxy.yml.sample b/lib/galaxy/config/sample/galaxy.yml.sample index b379fa67e838..a7ed80d5a489 100644 --- a/lib/galaxy/config/sample/galaxy.yml.sample +++ b/lib/galaxy/config/sample/galaxy.yml.sample @@ -2761,9 +2761,10 @@ galaxy: # only if you have setup a Celery worker for Galaxy and you have # configured the `celery_conf` option below. Specifically, you need to # set the `result_backend` option in the `celery_conf` option to a - # valid Celery result backend URL. By default a SQLite database is - # used for storing task results, please use a more robust backend for - # production setups like Redis. For details, see + # valid Celery result backend URL. By default, Galaxy uses an SQLite + # database at '/results.sqlite' for storing task results. + # Please use a more robust backend for production setups like Redis. + # For details, see # https://docs.galaxyproject.org/en/master/admin/production.html#use-celery-for-asynchronous-tasks #enable_celery_tasks: false diff --git a/lib/galaxy/config/schemas/config_schema.yml b/lib/galaxy/config/schemas/config_schema.yml index 1f742f869339..8e9c0e44a13e 100644 --- a/lib/galaxy/config/schemas/config_schema.yml +++ b/lib/galaxy/config/schemas/config_schema.yml @@ -3764,8 +3764,8 @@ mapping: Activate this only if you have setup a Celery worker for Galaxy and you have configured the `celery_conf` option below. Specifically, you need to set the `result_backend` option in the `celery_conf` option to a valid Celery result - backend URL. By default a SQLite database is used for storing task results, please - use a more robust backend for production setups like Redis. + backend URL. By default, Galaxy uses an SQLite database at '/results.sqlite' for storing task results. + Please use a more robust backend for production setups like Redis. For details, see https://docs.galaxyproject.org/en/master/admin/production.html#use-celery-for-asynchronous-tasks celery_conf: