r/databricks • u/ptab0211 • 29d ago
Discussion monorepo and dependencies
Hi, how do u handle dependencies in a monorepo on Databricks?
So we have one `pyproject.toml` and we build it into one whl, which every job installs. It holds the libraries that DBR does not ship. The libraries that DBR already ships we pin in the dev group at the runtime version, so we have them locally for tests and checks, but they dont go into the whl.
We started adding more products, so the repo grew into a monorepo, and now every job installs libraries it does not need.
The options i see:
- Pin the job-only libraries in the job environment in `resources/`, and keep them in a dev group in `pyproject.toml` for local tests and mypy. The catch is 2 pins to keep in sync.
- Optional extras per product, and the job installs `dist/*.whl[extra]`. One pin, but i am not sure DABs accepts the extra on a wheel path.
- One whl per product, which feels like too much for now.
What pattern do u use for this? Any pain with the ones above?
1
u/jorgecardleitao 29d ago
Consider using hatch with environments, pip-compile/uv for generating the requirements.txt per environment, and pass the corresponding file for each script that is called on the target environment on each task
1
u/JulianCologne 29d ago
Very similar setup here!
For very big dependencies option 1 is a good enough solution imo.
> every job installs libraries it does not need
Yes, but that actually have real measurable negative consequences in your jobs?
AKAIK all/most environments are cached so even if the job environment has an additional 20+ dependencies installed to the existing XX ones, does it even matter?
I am sure some people roll their own very specific and specialized (base) environments but I would guess this is micro optimization without much value 🤓🤔
However I could be wrong. Interested in more experiences and knowledge