Gym icon indicating copy to clipboard operation
Gym copied to clipboard

docs: Add debugging instructions for gym servers.

Open ffrujeri opened this issue 1 year ago • 1 comments

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.0 to [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_NAME environment 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.json configurations
  • Step-by-step instructions
  • Troubleshooting section
  • Quick reference for environment variables

Checklist

  • [x] Added debugpy to dev dependencies
  • [x] Updated CLI to support subprocess debugging
  • [x] Added comprehensive documentation
  • [x] Tested debugging workflow
  • [x] No breaking changes

ffrujeri avatar Nov 16 '25 06:11 ffrujeri

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

copy-pr-bot[bot] avatar Nov 16 '25 06:11 copy-pr-bot[bot]