How to Run a Databricks Notebook from Another Notebook

You can use %run command to run another notebook in your current notebook. In fact, it includes or concatenates another notebook in your notebook. This is generally used when you want to place your common code in one notebook and then simply call/include that notebook in your execution flow e.g.

You need to specify fully qualified path here. Relative paths are not supported. If the notebook you are calling contains spaces in between, you need to include the path in double quotes as shown in the below snapshot –

If you are not sure about the exact path of notebook you need to call, you can simply navigate to the workspace and right click on the notebook. You will find a “Copy File Path” option there to fetch you the accurate path that you can mention in calling the notebook –

Further, the book you are calling doesn’t necessarily need to be attached to a cluster as it’s not executed but just concatenated into your notebook.

If you want to go few steps further, you can use dbutils.notebooks.run command which allows you to specify timeout setting in calling the notebook along with a collection of parameters that you may want to pass to the notebook being called. In addition, this allows you to return values too from the notebook i.e.

However, this option is not supported in the Databricks community edition. To learn more about this, you may visit the Databricks’ official documentation at Notebook Workflows