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:ย 

Retrieve job-level parameters in spark_python_task (not notebooks)

xiangzhu
Contributor III

Hello,

I would like to use job parameters in spark_python_task (not notebook_task), does anyone know how to retrieve these parameters inside pure Python ?

xiangzhu_0-1718966193180.png

I tried:

1/ dbutils.widgets.get("debug"), got error: 

    com.databricks.dbutils_v1.InputWidgetNotDefined: No input widget named debug is defined

2/ use argparse to define a debug param, but after test, debug is not passed as param:

    parser: (Namespace(debug=None), [])

My job has debug param:

xiangzhu_1-1718966305318.png

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

daniel_sahal
Esteemed Contributor
5 REPLIES 5

daniel_sahal
Esteemed Contributor

xiangzhu
Contributor III

@daniel_sahal 

Thanks for your reply. Yes, I have the same question as the thread you mentioned, but argparse doesn't work for job level parameters; it only works for task level parameters.

The Databricks doc is minimal at this level and only says that job level parameters will be propagated to tasks. Nothing more.

xiangzhu
Contributor III

During this weekend, I found a workaround by leveraging the databaricks jobs api.

It works but I must provide credentials, whereas I'm looking forward to a solution without credentials since I'm already in a job run.

xiangzhu
Contributor III

I rechecked your answner in another thread and sorry I haven't seen `{{job.parameters.[name]}}`, I will try it in the coming days.

xiangzhu
Contributor III

@daniel_sahal just tested {{job.parameters.[name]}}, it works, thanks again !

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group