diff --git a/swh/scheduler/celery_backend/config.py b/swh/scheduler/celery_backend/config.py --- a/swh/scheduler/celery_backend/config.py +++ b/swh/scheduler/celery_backend/config.py @@ -5,6 +5,7 @@ import logging import os +import pkg_resources import urllib.parse from celery import Celery @@ -197,6 +198,11 @@ # Load the Celery config CONFIG = load_named_config(CONFIG_NAME, DEFAULT_CONFIG) +CONFIG.setdefault('task_modules', []) +# load tasks modules declared as plugin entry points +for entrypoint in pkg_resources.iter_entry_points('swh.workers'): + CONFIG['task_modules'].append(entrypoint.load()()['tasks']) + # Celery Queues CELERY_QUEUES = [Queue('celery', Exchange('celery'), routing_key='celery')] diff --git a/swh/scheduler/tests/conftest.py b/swh/scheduler/tests/conftest.py --- a/swh/scheduler/tests/conftest.py +++ b/swh/scheduler/tests/conftest.py @@ -34,9 +34,13 @@ @pytest.fixture(scope='session') def celery_includes(): - return [ + task_modules = [ 'swh.scheduler.tests.tasks', ] + import pkg_resources + for entrypoint in pkg_resources.iter_entry_points('swh.workers'): + task_modules.append(entrypoint.load()()['tasks']) + return task_modules @pytest.fixture(scope='session')