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 ?

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