4

I have referenced the topic - How to pass a variable to magic ´run´ function in IPython for triggering a Notebook from another Notebook.

notebook = "/Users/xxx/TestFolder/Notebook1"

In the next cell, I am trying to call %run like this as per the solution suggested in the above article:

%run $notebook 

I get the below error: Notebook not found: $notebook. Notebooks can be specified via a relative path. Is it possible to pass a string variable along with %run?

I could get around with something like this: dbutils.notebook.run(notebook, 300 ,{})

Satya Azure
  • 459
  • 7
  • 22

2 Answers2

2

Magic commands such as %run and %fs do not allow variables to be passed in.

The workaround is to use dbutils as you have seen.

simon_dmorias
  • 2,343
  • 3
  • 19
  • 33
2

You can do it with %run, pass param notebook_paramname

Python/Scala cell:
    notebook = "/Users/xxx/TestFolder/Notebook1"

Magic cell:
    %run $notebook_paramname = notebook
tatigo
  • 2,174
  • 1
  • 26
  • 32