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: 

How to run code-formating on the notebooks

Erik
Valued Contributor II

Has anyone found a nice way to run code-formating (like black) on the notebooks **in the workspace**? My current workflow is to commit the file, pull it locally, format, repush and pull. It would be nice if it was some relatively easy way to run black on the notebook up in the workspace, is it?

1 ACCEPTED SOLUTION

Accepted Solutions

austin_ford
Databricks Employee
Databricks Employee

Hi @Erik Parmann​  -- We do not currently have auto-formatting capabilities in the Notebook. As @Joseph Kambourakis​ mentioned, we are working on a new IDE support capability that will enable users to re-format inside of their IDE, but that is currently in development.

We are interested in adding auto-formatting to the Notebook via a tool like black in the future, but we have no plans at this time.

View solution in original post

4 REPLIES 4

Anonymous
Not applicable

I don't believe there is a way to do that. We do have something in development called DevBricks that will help with this kind of issue though. It's an IDE tool and it should be in preview soon. If you're interested in it talk to your CSE

Erik
Valued Contributor II

@Kaniz Fatma​  Yes:-)

austin_ford
Databricks Employee
Databricks Employee

Hi @Erik Parmann​  -- We do not currently have auto-formatting capabilities in the Notebook. As @Joseph Kambourakis​ mentioned, we are working on a new IDE support capability that will enable users to re-format inside of their IDE, but that is currently in development.

We are interested in adding auto-formatting to the Notebook via a tool like black in the future, but we have no plans at this time.

MartinPlay01
New Contributor II

Hi Erik,

I don't know if you are aware of this feature, currently there is an option to format the code in your databricks notebooks using the black code style formatter.

Just you need to either have a version of your DBR equal to or greater than 11.2 (the libraries are configured by default) either configure the next libraries in your cluster

%pip install black==22.3.0 tokenize-rt==4.2.1

 https://docs.databricks.com/en/notebooks/notebooks-code.html#format-python-cells 

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