runs.py 712 B

1234567891011121314151617181920212223
  1. """Formal pipeline run API routes."""
  2. from __future__ import annotations
  3. from typing import Any
  4. from uuid import UUID
  5. from fastapi import APIRouter, Depends, HTTPException
  6. from app.dependencies import get_pipeline_repository
  7. router = APIRouter(prefix="/api/pipeline", tags=["pipeline"])
  8. @router.get("/runs/{run_id}")
  9. def pipeline_run(
  10. run_id: UUID,
  11. repo: Any = Depends(get_pipeline_repository),
  12. ) -> dict[str, Any]:
  13. getter = getattr(repo, "get_pipeline_run", None)
  14. if getter is None:
  15. raise HTTPException(status_code=501, detail="pipeline run reader is not implemented")
  16. run = getter(run_id)
  17. return {"run": run.model_dump(mode="json") if hasattr(run, "model_dump") else run}