Satya Azure
Satya Azure

Reputation: 479

Databricks Notebook with %run - Not working

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 ,{})

Upvotes: 4

Views: 9548

Answers (2)

tatigo
tatigo

Reputation: 2264

You can do it with %run, pass param notebook_paramname

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

Magic cell:
    %run $notebook_paramname = notebook

Upvotes: 2

simon_dmorias
simon_dmorias

Reputation: 2483

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.

Upvotes: 2

Related Questions