cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Dynamic value input to a job

Hritik_Moon
New Contributor

How do I pass dynamic value to a databricks job?

I created a notebook which will extract the names of files in the catalog, I want to pass these names as parameter to another notebook task in a job.

What are the ways I can do this?

6 REPLIES 6

szymon_dybczak
Esteemed Contributor III

Hi @Hritik_Moon ,

Define widgets in notebook, so you your notebooks are prepare for passing parameters. Then you can use task values to pass information between tasks. Check below documentation entry for more information and examples:

Use task values to pass information between tasks | Databricks on AWS

Hritik_Moon
New Contributor

Hello  I tried this,

Notebook 1 :

dbutils.jobs.taskValues.set(key = "my_key", value = "hi From Notebook1")

Notebook2:

X = dbutils.jobs.taskValues.get(taskKey="01", key="my_key", debugValue = "Fail")

print(X)

 Here I get "Fail" as output, its not fetching my_key

@szymon_dybczak

szymon_dybczak
Esteemed Contributor III

Your task in the workflow is name 01?

szymon_dybczak_0-1759737210612.png

 

Databricks widgets | Databricks on AWS

szymon_dybczak
Esteemed Contributor III

Hi @Hritik_Moon  ,

Folllow my steps. I created 2 notebooks:

- first one called Notebook1 with followign content

szymon_dybczak_3-1759738090797.png

- second one called Notebook2 with following content that will read value defined in Notebook1

szymon_dybczak_4-1759738096570.png

Here's my definiton of workflow that is using those 2 notebooks:

szymon_dybczak_2-1759738044356.png

Pay attention to my taskKey in get method is named the same as the task in a workflow (Notebook1):

 

szymon_dybczak_0-1759738390077.png

 

 

Hritik_Moon
New Contributor

Hello, I think you have posted wrong picture for notebook1. Could you please verify once.

I made some changes and its working now. ๐Ÿ™‚

Thanks a lot.

szymon_dybczak
Esteemed Contributor III

Hi @Hritik_Moon ,

Good catch, I've pasted wrong screenshot. Here's the correct one:

szymon_dybczak_0-1759744411639.png

 

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local communityโ€”sign up today to get started!

Sign Up Now