cancel
Showing results for 
Search instead for 
Did you mean: 
Community Platform Discussions
Connect with fellow community members to discuss general topics related to the Databricks platform, industry trends, and best practices. Share experiences, ask questions, and foster collaboration within the community.
cancel
Showing results for 
Search instead for 
Did you mean: 

Why is the ipynb format recommended?

Yuki
New Contributor III

In this document, https://docs.databricks.com/aws/en/notebooks/notebook-format,
Jupyter (.ipynb) format is recommended.

> Select File from the workspace menu, select Notebook format, and choose the format you want. You can choose either Jupyter (.ipynb) (Recommended) or Source (.scala, .py, .sql, .r). The notebook’s current format is greyed out and has a checkmark next to it.

However, I prefer the .py format due to the simplicity it offers for code reviews.

What are the benefits or risks of using .ipynb compared to .py?

4 REPLIES 4

Advika_
Databricks Employee
Databricks Employee

Hello @Yuki!

Your preference for .py is valid, as it simplifies code reviews with cleaner diffs. On the other hand, .ipynb is better suited for interactive workflows since its cell-based execution allows incremental testing and supports inline graphs, tables, and Markdown for better visualization. The main risks with .ipynb include its dependency on Jupyter or Databricks to run and the possibility of state errors if cells are executed out of order.

For structured and code-centric projects, .py is the better choice, while .ipynb proves to be more effective for exploratory analysis.

Yuki
New Contributor III

Hi @Advika_ ,

Thank you for the clear answer.
It made perfect sense to me, and I found that my understanding was correct as well.
Knowing that there are clear cases where the .py format is better is reassuring for me.

 

Thank you so much for your prompt reply.

Nivethan_Venkat
New Contributor III

Hi @Yuki,

One other risk that we foresee / encountered recently is how the notebooks will look in your pull requests of external repos (Azure Devops or GitHub). It will be very hard for a pull request reviewer to understand on the code / notebook readability.

I've run up against this recently too, it's worth mentioning that saving serverless environment settings isn't supported on Python file backed Notebooks, so for some customers it may be a choice between ease of code reviews or using serverless as a product. I'm hoping the likes of Azure DevOps support diffs in with ipynb files in the future!

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