Debugging our pipeline code
This section provides comprehensive guidance on debugging the Matrix pipeline and documentation system. Whether you're troubleshooting pipeline issues, setting up debugging environments, or working with documentation, you'll find the tools and techniques you need here.
Debugging with VS Code
Setup
- Create or modify
.vscode/launch.jsonin your project root:
{
"version": "0.2.0",
"configurations": [
{
"name": "kedro run",
"type": "debugpy",
"request": "launch",
"module": "kedro",
"args": ["run"],
"cwd": "${workspaceFolder}/pipelines/your_pipeline"
}
]
}
Common Debug Configurations
Here are some useful debug configurations for Kedro:
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Full Pipeline",
"type": "debugpy",
"request": "launch",
"module": "kedro",
"args": ["run"],
"cwd": "${workspaceFolder}/pipelines/your_pipeline"
},
{
"name": "Run Specific Nodes",
"type": "debugpy",
"request": "launch",
"module": "kedro",
"args": ["run", "--nodes", "node1,node2"],
"cwd": "${workspaceFolder}/pipelines/your_pipeline"
},
{
"name": "Run with Different Env",
"type": "debugpy",
"request": "launch",
"module": "kedro",
"args": ["run", "-e", "test"],
"cwd": "${workspaceFolder}/pipelines/your_pipeline"
}
]
}
Using the Debugger
- Set breakpoints by clicking to the left of the line numbers in your code
- Select your debug configuration from the dropdown in the Debug view
- Start debugging by pressing F5 or clicking the green play button
Debug Variables and Watch
- Use the Variables pane to inspect local and global variables
- Add expressions to the Watch pane to monitor specific values
- Use the Debug Console to evaluate expressions in the current context
Advanced Debugging
Node-specific Debugging
To debug specific nodes in your pipeline:
{
"name": "Debug Specific Node",
"type": "debugpy",
"request": "launch",
"module": "kedro",
"args": ["run", "--nodes", "target_node"],
"cwd": "${workspaceFolder}/pipelines/your_pipeline"
}
Pipeline Slicing
Debug a slice of your pipeline:
{
"name": "Debug Pipeline Slice",
"type": "debugpy",
"request": "launch",
"module": "kedro",
"args": ["run", "--from-nodes", "start_node", "--to-nodes", "end_node"],
"cwd": "${workspaceFolder}/pipelines/your_pipeline"
}
Additional Resources
Tips and Tricks
- Use conditional breakpoints by right-clicking on a breakpoint
- Enable "Just My Code" to avoid stepping into library code
- Use logpoints for non-breaking debugging messages
- Utilize the "Debug Console" for interactive debugging
Common Issues
- Missing debugpy: Ensure debugpy is installed in your environment
pip install debugpy - Wrong Working Directory: Make sure the
cwdin launch.json points to your pipeline directory - Environment Issues: Verify VS Code is using the correct Python interpreter with your Kedro environment