Can I iterate through the widgets in a databricks notebook? Something like this pseudocode?
# NB - not valid
inputs = {widget.name: widget.value for widget in dbutils.widgets}
Can I iterate through the widgets in a databricks notebook? Something like this pseudocode?
# NB - not valid
inputs = {widget.name: widget.value for widget in dbutils.widgets}
Yes. You can get all of the widgets returned as a JavaMap. Then you can convert that to a Python dictionary.
%python
my_widgets = dbutils.notebook.entry_point.getCurrentBindings()
{key: my_widgets[key] for key in my_widgets}
Note that "entry_point" is not a supported part of the dbutils
API.
Databricks could change or remove it without notice.
i'm not 100% sure but i think so but if not then you might have to manually input the widgets in by them self and not grouped