cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Can I run one notebook from another notebook?

__Databricks_Su
Contributor
 
21 REPLIES 21

__Databricks_Su
Contributor

Sure. Use the %run syntax as follows:

%run /PoundInclude

The target notebook does not need to be attached to a cluster. It will get pulled into the caller's context.

At this time, you can't combine Scala and Python notebooks, but you can combine Scala+SQL and Python+SQL notebooks.

You must specify the fully-qualified notebook from the root of the Workspace. Relative paths are not supported at this time.

If you have spaces in your notebook name, you'll need to surround the target of %run with quotes as follows:

%run "/PoundInclude (Python)"

I'm missing something obvious here, I'm running %run 'notebook2' inside 'notebook1' where both notebooks are in the main Workspace directory and receiving the error:

ERROR: File

u'notebook2.py'
not found.

Is there a path setting I forgot?

Thanks

Try running the %run in a new cell. There can't be any other code in the same cell performing the %run. You can still use the results of the %run in subsequent cells.

I also have the same issue. I don't have any other code in the cell.

Bit late: even comments can cause this issue

You can now use relative paths, e.g. %run "./PoundInclude (Python)"

RogerErens
New Contributor II

@hshteingart @sugreevc

Does including the notebook file extension help you, e.g.

%run my_other_notebook.ipynb

?

jayashree
New Contributor II

I want to run an existing notebook from another R notebook.

VinayakBhardwaj
New Contributor II

dbutils.notebook.run("notebook_name", time(in sec) ,{ " "db_name" : "jmdc_20180731_test"}) @Christian Rodriguez @jayashree @Roger Erens

For example:

dbutils.notebook.run("notebook_1", 600,{ "db_name" : "jmdc_20180731_test"})

Please let me know if you do have any issues.

Mail id : vinayakbhrdwj@gmail.com

How to call function of notebook_name from let say calling notebook.can you give an example for that use case

manishtangudu
New Contributor II

How do I make the notebook run in a different window on calling? @Roger Erens

amanpreetkaur
New Contributor III

Is it possible to import a particular function using %run statement in azure databricks?

PRABHATKUMAR
New Contributor II

Yes we can import all things (functions,variables etc) from one notebook to another notebook...

Just remember to run %run /Users/path/Notebook_Name in a separate cell

and then you can call one notebook functions in another one @amanpreet kaur

Is it possible to do something like this: %run /Users/path/Notebook_Name Function_Name ?

@Prabhu4284

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.