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 

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local community—sign up today to get started!

Sign Up Now