How to call notbook cmds in another notebook

Rohit Kulkarni 676 Reputation points
2023-03-21T11:17:07.93+00:00

Hello Team,

The notebook called "abc" and in that notebook there are 2 cmd for example mentioned below

User's image

I need to call this cmd in another notebook cmd. how it can be done.

Please advise

Regards

Rohit

Azure Databricks
Azure Databricks
An Apache Spark-based analytics platform optimized for Azure.
1,947 questions
{count} votes

1 answer

Sort by: Most helpful
  1. MartinJaffer-MSFT 26,036 Reputation points
    2023-03-21T20:08:22.0133333+00:00

    @Rohit Kulkarni Hello and welcome back to Microsoft Q&A.

    I understand you want more information about %run and calling another notebook. I am less clear on your exact ask.

    %run /path/to/notebook is a meta-command which makes another notebook run. Examples and notes.

    Notebooks run by %run share execution context, so it can be used to load libraries, as I suspect your displayed code does.

    %run runs the entire notebook. I don't think you can run only parts of a notebook.

    %run needs an entire cell to itself. It cannot share with others. If you need to add more logic, use dbutils.notebook.run("/path/to/notebook",600) instead.

    So you can either copy-paste the commands from "abc" to your own notebook, or you can run "abc" notebook. You may need to change the path depending upon location of each notebook. If they are in the same folder path is ./abc if subfolder of current folder ./subfolder/abc .

    0 comments No comments