How to run same notebook with different parameters using mssparkutils.notebook.run() in parallel?

Dinesh Kumar Perumal (Nallas) 0 Reputation points
2024-12-09T11:28:57.2033333+00:00

I need to run same notebook with different parameters, which should run parallel. Example i have a notebook "NameToPrint", where i need to run this with 5 different parameters ("Ride","Wide","ligth","Special","Look") to reduce run time, i need to run it parallel. How to do it?

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,244 questions
{count} votes

1 answer

Sort by: Most helpful
  1. AnnuKumari-MSFT 34,361 Reputation points Microsoft Employee
    2024-12-10T16:06:57.7766667+00:00

    Hi @Dinesh Kumar Perumal (Nallas) ,

    You can Reference run multiple notebooks in parallel with the help of mssparkutils.notebook.runMultiple() method.

    The method mssparkutils.notebook.runMultiple() allows you to run multiple notebooks in parallel or with a predefined topological structure. The API is using a multi-thread implementation mechanism within a spark session, which means the compute resources are shared by the reference notebook runs.

    With mssparkutils.notebook.runMultiple(), you can:

    • Execute multiple notebooks simultaneously, without waiting for each one to finish.
    • Specify the dependencies and order of execution for your notebooks, using a simple JSON format.
    • Optimize the use of Spark compute resources and reduce the cost of your Synapse projects.
    • View the Snapshots of each notebook run record in the output, and debug/monitor your notebook tasks conveniently.
    • Get the exit value of each executive activity and use them in downstream tasks. Alternatively, you could try to run the notebook from another notebook using %run command 5 times with different parameter values in each run command .

     

    Or else, call the Notebook within synapse pipeline inside foreach activity by passing array of parameters to loop through in each iterations.

    Hope it helps. Kindly let us know how it goes. Thankyou

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.