When I uncomment the last two lines of Called_Notebook.py and run it manually by itself, it correctly returns the output as:
Status: SUCCESS
Circle area: 50.26544
But when I comment out the last two lines of Called_Notebook.py and run it from the Caller_Notebook.py, it returns the output as "None" from the Exception block of the area_of_circle(r) function defined in the Called_Notebook.py. Question: Why the function is failing when called from Caller_Notebook.py ?
Called_Notebook.py:
dbutils.widgets.text("radius", "4")
r = float(dbutils.widgets.get("radius"))
status=""
try:
def area_of_circle(r):
return 3.14159 * r * r
circle_area = area_of_circle(r)
status = "SUCCESS"
except Exception as e:
circle_area = None
status = "ERROR"
error_message = str(e)
# print(f"Status: {status}")
# print(f"Circle area: {circle_area}")
Caller Notebook:
try:
output = dbutils.notebook.run("./Called_Notebook.py",60,{"radius":"4"})
print(output)
except Exception as e:
print("Child notebook failed:", e)