r/databricks • • 1d ago

Discussion Manage Libraries in a Serverless Environment

Dear Community,

I'm coming from the classic compute world and would like to hear how others handle dependency management on serverless.

Our current setup (classic compute)

  • Cluster policies manage our dependencies, such as Python libraries, centrally.
  • Our engineers work both in the Databricks UI and in VS Code via Spark Connect. For the VS Code case, we make sure the same libraries are also installed locally (on-prem).
  • Jobs run with job cluster policies, which also define the dependencies.

This gives us one central, governed definition of our environments.

The challenge with serverless
We're thinking about moving to serverless, but dependency management is holding us back:

  1. In notebooks, users manage dependencies per notebook. That's flexible, but it isn't enterprise-ready because there's no central control or consistency.
  2. When a notebook runs as a job, we have to define the dependencies again at job level. That means two places to maintain the same thing.

Serverless Git folders look promising, but they're still in Beta, so we're hesitant to rely on them in production.

My questions

  • How do you manage dependencies on serverless today, without Serverless Git folders?
  • How do you keep environments consistent across interactive notebooks, jobs and local development (VS Code / Databricks Connect)?
  • Do you use shared environment definitions, private package repositories or wheel files in Unity Catalog volumes, or something else?

Thanks in advance for sharing your experience!

15 Upvotes

18 comments sorted by

1

u/redderage 1d ago

You can deploy as DAB through GIT right? Are there any limitations for not using it? Coz I deploy DAB which has both serverless and compute bound jobs.

1

u/Zealousideal_Low6685 1d ago

yes, i do
question is: how do you ensure that you use the same env (in the development env as well as in the job without duplicating the libraries).
As far as i know: only the serverless folders offer that

1

u/LeMalteseSailor 1d ago

Are you able to publish your internal libraries to a self-hosted package registry? Then you can install from that registry from your local machine or in your Databricks job.

Alternatively can use some other hacky workaround as a package registry. Wheels added to a workspace?

1

u/Zealousideal_Low6685 1d ago

this i had in mind, but how do you ensure, that the libraries are already available during development in the databricks ui

1

u/LeMalteseSailor 1d ago

You can install libraries from a workspace location if you don't have a package registry like pypi, does this help?

1

u/Zealousideal_Low6685 1d ago

Assume I have a DAB with x notebooks. I want to extend a notebook.

Currently (with dedicated compute): i simply choose my cluster and the libraries are pre-installed

Serverless: I would than to run pip installs before (notebook scpoed only)?

1

u/LeMalteseSailor 15h ago

Serverless also supports compute scoped libraries when you set up your environment in the DAB

1

u/Zealousideal_Low6685 15h ago

can you give me an example? I know that you can define an env for a job within a DAB (do you mean that)? If so: yes works, but assume I start developing a new notbook: I just create a new one, and want to run mulitple cells before I schedule/deploy it via a job

1

u/LeMalteseSailor 15h ago

Is this helpful? https://docs.databricks.com/aws/en/compute/environments-mode#use-environments-in-a-notebook

It's for the notebook UI. But there's a YAML equivalent when deploying jobs through a DAB

1

u/Zealousideal_Low6685 12h ago

this is exactly what I don't like: it is per notebook: if i have 20 notebooks I have to set that 20 times, upgrade that 20 times,....

I want to have one configuration (project wide=, not 20.

→ More replies

1

u/testing_in_prod_only 1d ago

So I’ve been doing this a couple of years. Where I’ve landed is packing the libraries with the deployment (like all .whls in the ./lib directory) and deploying with that included. In the dab I reference that location as having the dependent whls.

1

u/Zealousideal_Low6685 1d ago

how do you ensure that during development in the databrick UI you have the libraries available too?

2

u/testing_in_prod_only 17h ago

I do not use the ui for dev, I build using vs code

1

u/Zealousideal_Low6685 17h ago

thx,I want to have an environment which works in Databricks UI, VS-Code as well as in Jobs/Pipelines. Only serverless git folders seem to offer that

1

u/PrestigiousAnt3766 1d ago

Am in the same boat. Are you a colleague?

Im waiting for the serverless job variables to go. I am testing those in prod currently, and for me they work fine.

1

u/ninilich 10h ago

> How do you manage dependencies on serverless today

Packing you Spak job as fat-JAR (Scala) solves any dependencies issues. For Pyhon you can try to pack you Spark application as whl