cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
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 ?

2 REPLIES 2

Lakshay
Databricks Employee
Databricks Employee

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

feiyun0112
Honored Contributor

 

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 

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group