Gym
Gym copied to clipboard
docs: Add debugging instructions for gym servers.
Add VS Code Debugging Support for Server Subprocesses
Summary
Adds support for debugging NeMo Gym server subprocesses in VS Code without modifying application code. This enables developers to set breakpoints and debug server logic during development.
Motivation
Previously, debugging server code was difficult because:
- Servers are spawned as subprocesses by the CLI (
ng_run) - VS Code debugger couldn't attach to child processes
- Required adding temporary debug code to
server_utils.py - No standardized debugging workflow
This PR provides a clean, reproducible debugging setup that works out of the box.
Changes
1. Added debugpy to Dev Dependencies
File: pyproject.toml
- Added
debugpy>=1.8.0to[project.optional-dependencies].dev - Included proper license and version documentation
2. CLI Support for Subprocess Debugging
File: nemo_gym/cli.py
- Added
DEBUG_MODE_KEY_NAMEenvironment variable support - When enabled, spawns servers with
python -m debugpy --listen - Each server gets a sequential debug port (5678, 5679, 5680, etc.)
- Debug mode is opt-in and doesn't affect production usage
3. Documentation
- Complete debugging workflow guide
- VS Code
launch.jsonconfigurations - Step-by-step instructions
- Troubleshooting section
- Quick reference for environment variables
Checklist
- [x] Added
debugpyto dev dependencies - [x] Updated CLI to support subprocess debugging
- [x] Added comprehensive documentation
- [x] Tested debugging workflow
- [x] No breaking changes