Add interactive shell for celery tasks

That's pretty useful for developing new tasks or just running one-off
tasks.
This commit is contained in:
mvdbeek
2021-11-29 10:34:01 +01:00
parent 6036a234c1
commit 0091d37469
2 changed files with 29 additions and 4 deletions
+27 -3
View File
@@ -1,8 +1,32 @@
from scripts.db_shell import *
"""
Run this script from galaxy's root with
```
ipython -i scripts/celery_shell.py -- -c config/galaxy.yml
```
"""
import logging
import os
WARNING_MODULES = ['parso', 'asyncio', 'galaxy.datatypes']
for mod in WARNING_MODULES:
logger = logging.getLogger(mod)
logger.setLevel('WARNING')
from scripts.db_shell import config
os.environ['GALAXY_CONFIG_FILE'] = os.environ.get('GALAXY_CONFIG_FILE', config['config_file'])
from galaxy.celery import get_galaxy_app
from galaxy.celery import tasks # noqa: F401
from galaxy.celery.tasks import *
HELP = """
============
Run celery tasks interactively.
tasks are collected in task module.
To run recalculate_user_disk_usage for user 1 in a celery worker
type
>>> tasks.recalculate_user_disk_usage.deley(user_id=1)
"""
app = get_galaxy_app()
assert app, 'Set GALAXY_CONFIG_FILE to the path of your galaxy.yml file'
print(HELP)