"""Celery tasks - thin wrappers over pipeline functions.""" from __future__ import annotations import uuid from celery.utils.log import get_task_logger from app.workers.celery_app import celery_app logger = get_task_logger(__name__) @celery_app.task(name="legacyhub.process_document", bind=True, max_retries=2, default_retry_delay=30) def process_document(self, document_id: str, run_id: str | None = None) -> dict: from app.ingestion.pipeline import process_document_id try: return process_document_id(uuid.UUID(document_id), uuid.UUID(run_id) if run_id else None) except Exception as exc: # noqa: BLE001 logger.exception("worker.process_failed", extra={"document_id": document_id}) raise self.retry(exc=exc) from exc