In a Databricks notebook to get full list of widgets those not overridden.
you can try get_ipython(), globals(), locals()
The above function is used to get all variable names in the notebook.
it fetches all the variable names in the current notebook using the globals() and locals() functions, and combines them into a set.
from IPython.display import display
from dbutils.widgets import Widget
**Get all the variable names in the current notebook namespace**
all_vars = set(globals().keys()).union(set(locals().keys()))
**Filter for variables that are instances of dbutils.widgets.Widget**
widget_vars = [var_name for var_name in all_vars if isinstance(get_ipython().user_ns[var_name], Widget)]
**Get the widget instances from the variable names**
widgets_used = [get_ipython().user_ns[var_name] for var_name in widget_vars]
**Print the list of widgets.**
print(widgets_used)
from the above first imports the necessary libraries for working with widgets.
Using the get_ipython(), globals(), locals() functions and filters this set for any variables that are instances of dbutils.widgets.Widget using the isinstance() function.
The resulting list of variable names is then used to retrieve the widget instances from the notebook with help of get_ipython().user_ns dictionary.
Finally, the code prints the list of widgets to the console. This approach should retrieve all widgets used in the notebook, even those that have not been overridden.
In your case, since you have created two widgets named a and b, you can use the code above to retrieve both widgets, even though you have overridden the value of a in the Databricks Job.

