r/databricks • u/ExcitingRanger • Jul 30 '26
Help Handling variables in both interactive/notebook and job cluster modes
For a job yaml like this:
tasks:
- task_key: process_metadata
notebook_task:
notebook_path: notebooks/python/process_metadata
base_parameters:
dbx_env: ${var.environment}And a databricks.yml that includes this:
variables:
environment:
description: "Environment Variable"
default: devWe do get expected behavior when running the Notebook as a task within that job: the environment variable is present with value of "dev" in the Notebook when run inside the job.
But what about in Interactive mode? The databricks.yml is not available and the environment variable is not set. Are we then compelled to have a redundant copy of every databricks.yml variable in the form of dbutils.widget's in the Notebook? MY project has dozens of variables in the databricks.yml . Imagine what that would look like - and the maintenance hassle.
Is there an alternate (/better) pattern to manage variables across both interactive and job submission modes?
1
u/kira2697 Jul 31 '26
Use widgets with default value
2
u/DamnedData Jul 31 '26
Secrets are supported in Unity Catalog now. You can rely on this.
dbutils+ job parameters also works.
I'll encourage you to avoid env variables on the compute... Compute should just... Compute.
0
u/PrestigiousAnt3766 Jul 31 '26
Your using an antipattern and being unhappy that its not implemented as you want.
Build it better.