"""Celery application instance for the Chrysopedia pipeline.

Usage:
    celery -A worker worker --loglevel=info
"""

from celery import Celery

from config import get_settings

settings = get_settings()

celery_app = Celery(
    "chrysopedia",
    broker=settings.redis_url,
    backend=settings.redis_url,
)

celery_app.conf.update(
    task_serializer="json",
    result_serializer="json",
    accept_content=["json"],
    timezone="UTC",
    enable_utc=True,
    task_track_started=True,
    task_acks_late=True,
    worker_prefetch_multiplier=1,
)

# Import pipeline.stages so that @celery_app.task decorators register tasks.
# This import must come after celery_app is defined.
import pipeline.stages  # noqa: E402, F401
