Understanding the Databricks New Feature Notebook Debugger

Notebook Debugger helps us to identify and resolve code issues in Python within Databricks notebooks efficiently. With this tool, we can inspect variables and navigate through our code step by step, enhancing debugging and optimizing data processes. This Databricks interactive debugger is a valuable tool for data scientists and analysts.

Enabling the debugger

Before debugging, it’s essential to confirm that our Databricks environment is configured to support the interactive debugger. for that, we should need Databricks Runtime version 13.3 LTS or above, and our notebook must be attached to a cluster with a Single user (Assigned) or No isolation shared access mode.

How to enable the debugger?

  1. Click on the username in the upper-right corner of the workspace and select “User Settings.”
  2. In the Settings sidebar, navigate to “Developer.”
  3. In the “Experimental features” part, switch on the “Python Notebook Interactive Debugger”

How to Start the Debugger?

Once the debugger is enabled, we can now start debugging our Python code right from our notebook.

Follow these simple steps to begin :

  1. To add breakpoints, simply click on the left edge of a cell. If you want to remove a breakpoint, just click on it again.
  2. To start debugging, we have a few options: click on “Run” and then choose “Debug cell,” or use the keyboard shortcut Ctrl + Shift + D, or else select “Debug cell” from the cell run menu.
How to Use the Debugger?

Once when the debugger is activated, we can gain access to code and we can inspect and execute our code. these are the things we can do during a debug session:

  1. Set or remove breakpoints to pause execution at specific lines of code.
  2. Now check out the values of variables at breakpoints using the variable explorer panel on the right side.
  3. Move through our code one line at a time, with the current line highlighted within the cell.
  4. Now click on the enter or exit functions to explore our code’s execution sequence further.

How to Terminate the Debugging Session

Once the debugging task has been completed, it’s essential to know how to end the debug session cleanly. we can do this by clicking the debugger stop button at the upper-left of the cell or the notebook stop button at the top of the notebook.

Limitations

While the Databricks interactive debugger offers us powerful debugging capabilities, it’s essential to be aware of its limitations:

  1. It works exclusively with Python and does not support Scala or R.
  2. The debugger doesn’t work on clusters with Shared access mode.
  3. We cannot step into external files or modules during debugging sessions.
  4. While debugging, we can’t execute additional commands within the notebook.

Conclusion

This Databricks interactive debugger enables Python developers to diagnose code more effectively right within their notebooks. By offering breakpoints, variable examination, and step-by-step execution, these functionalities streamline the debugging experience, ultimately improving code productivity.This Databricks interactive debugger enables Python developers to diagnose code more effectively right within their notebooks. By offering breakpoints, variable examination, and step-by-step execution, these functionalities streamline the debugging experience, ultimately improving code productivity.

Author: Nihalataskeen Inayathulla

Leave a Reply

Your email address will not be published. Required fields are marked *