Skip to content

Commit

Permalink
Make sure data_dir is used for default result backend DB
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed Apr 10, 2024
1 parent 9d9630d commit f009b75
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
7 changes: 4 additions & 3 deletions doc/source/admin/galaxy_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<data_dir>/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
Expand Down
14 changes: 14 additions & 0 deletions lib/galaxy/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand Down
7 changes: 4 additions & 3 deletions lib/galaxy/config/sample/galaxy.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<data_dir>/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

Expand Down
4 changes: 2 additions & 2 deletions lib/galaxy/config/schemas/config_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<data_dir>/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:
Expand Down

0 comments on commit f009b75

Please sign in to comment.