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?
- Click on the username in the upper-right corner of the workspace and select “User Settings.”
- In the Settings sidebar, navigate to “Developer.”
- 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 :
- To add breakpoints, simply click on the left edge of a cell. If you want to remove a breakpoint, just click on it again.
- 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:
- Set or remove breakpoints to pause execution at specific lines of code.
- Now check out the values of variables at breakpoints using the variable explorer panel on the right side.
- Move through our code one line at a time, with the current line highlighted within the cell.
- 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:
- It works exclusively with Python and does not support Scala or R.
- The debugger doesn’t work on clusters with Shared access mode.
- We cannot step into external files or modules during debugging sessions.
- 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