Passing Variables Across Notebooks

When developing pipelines and linked notebooks, it is vital to transmit key values across different notebooks and environments. This approach guarantees consistency of values and reduces repetitive computations within the notebooks. Additionally, it enhances the efficiency of workflow management and simplifies the debugging process.

Input Widgets In Databricks

Creating Widgets Within Notebooks

To create input widgets in Databricks, users can utilize functions within the dbutils library or the notebook user interface. Once a widget is created, it can be passed across multiple notebooks through pipelines or internal notebook executions.

Databricks allows for the creation of four different types of widgets.

  • Text Widgets

  • Dropdown Widgets

  • Combination Widgets

  • Multi-Select Widgets


Parameter Cells In Databricks

Creating Parameter Cells Within Notebooks

To create parameter cells in Synapse, users must first declare the variables to be parameterized in a separate cell. They then need to select the ellipses (...) to access additional cell commands and select the Toggle Parameter Cell option. Once a parameter cell is configured, the values are initialized directly below the designated parameter cell during pipelines or internal notebook executions.


Key Differences

Accessing Widget Values In Databricks

In Synapse, the parameter variables can be accessed just like other regular variables, while in Databricks, values need to be retrieved using the dbutils library before use across notebooks.

# Retrieve Value Of A Single Widget
dbutils.widgets.get("<widget-name>")


# Retrieve Value Of All Widgets
dbutils.widgets.getAll()

References


Last updated