I have built a simple CI pipeline using Dagger for my Python projects which sets up the Python venv and then executes linting/formatting/type-checking steps (see attached code). Unfortunately, Dagger is unbelievably slow at times and I'm failing to understand why:
- The
load modulestep at the very beginning of adagger call -m . run-pyproject-pipeline --pyproject-dir .always takes >2s, sometimes as much as 17s(!) What is Dagger doing with all that time?! - Extracting the venv folder from the container in
get_venv()took > 8 minutes this morning (│ ✔ .directory(path: ".venv"): Directory! 8m17s), even though the Python project is rather small and only has a handful dependencies (mainly Pulumi & Pydantic). Once the step was cached, everything was fine but IMO it should never take this long. - The typecheck
.with_exec(["uv", "run", "pyright", "."])takes 30-40s on my machine (uncached). Sure, Pyright is not exactly known for being fast but executinguv run pyright .on my command line only takes 3s.
Could anyone help me understand what's going on here and what I could do to optimize my pipeline?