Why my calling notebook is not receiving the value of a variable in called notebook?

Saf4Databricks
Contributor

 Remarks: I though you can use %run command to make variables defined in one notebook available in another. The %run command executes the specified notebook inline within the current notebook's session, so all functions, variables, and DataFrames defined in the called notebook become accessible in the calling notebook.

PLEASE NOTE: Question is NOT about achieving the same using alternatives such as dbutils.notebook.exit() etc. It's rather what is the reason for this code is not working.

Notebook_A:

my_variable = "Hello from Notebook A"

Notebook_B:

cell_1

%run "./Notebook_A"

cell_2

# Now you can use the variable defined in Notebook_A
print(my_variable)

Output of cell_2:

my_variable

Expected output of cell_2:

Hello from Notebook_A