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

Python Databricks how to run all cells in another notebook except the last cell

jerryrard
New Contributor

I have a Python Databricks notebook which I want to call/run another Databricks notebook using dbutils.notebook.run()... but I want to run all the cells in the "called" notebook except the last one.

Is there a way to do a count of cells in the called notebook? And then run the called notebook on all cells until CellCount-1 ?

3 REPLIES 3

Lakshay
Esteemed Contributor
Esteemed Contributor

I don't think this is possible. You can only complete a notebook. 
BTW curious to know what is the use-case here.

feiyun0112
Contributor III

 

In the alternative way, you can use dbutils.notebook.run to pass the parameters, and use dbutils.widgets.get in another notebook to get the parameter values,

and determine the parameter values to decide whether to execute codes in the specified cell

https://docs.databricks.com/en/notebooks/notebook-workflows.html#example 

Kaniz
Community Manager
Community Manager

Hey there! Thanks a bunch for being part of our awesome community! ๐ŸŽ‰ 

We love having you around and appreciate all your questions. Take a moment to check out the responses โ€“ you'll find some great info. Your input is valuable, so pick the best solution for you. And remember, if you ever need more help , we're here for you! 

Keep being awesome! ๐Ÿ˜Š๐Ÿš€

 

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.