Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Debugger] Adding debupgy as the ray debugger #42311

Merged

Conversation

brycehuang30
Copy link
Contributor

@brycehuang30 brycehuang30 commented Jan 10, 2024

Why are these changes needed?

  • enabled debugpy as the ray debugger for breakpoint and post_mortem debugging
  • added flag RAY_DEBUG=1 to enable debugpy. If RAY_DEBUG is not set and RAY_PDB is set, then rpdb will be used.
  • used state api to save worker debugging port.

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    I manually tested that the task can be paused and it awaits connection from debugger client. Tested tasks running on worker nodes and head node. I also tested post-mortem debugging is working.

@sofianhnaide
Copy link
Contributor

The files do matches the diff based on my review, please verify end to end working before merging.

@brycehuang30 brycehuang30 marked this pull request as ready for review January 11, 2024 08:07
@brycehuang30 brycehuang30 changed the title [WIP][Debugger] Adding debupgy as the ray debugger [Debugger] Adding debupgy as the ray debugger Jan 11, 2024
@brycehuang30
Copy link
Contributor Author

brycehuang30 commented Jan 11, 2024

I manually tested that the task can be paused and it awaits connection from debugger client. Tested tasks running on worker nodes and head node. I also tested post-mortem debugging is working

Manually verified it's e2e working

python/setup.py Outdated
@@ -342,6 +342,7 @@ def get_packages(self):
"aiosignal",
"frozenlist",
"requests",
"debugpy",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably shouldn't install this by default; can we instead do a soft-import and raise a warning/exception if this is not installed?

Copy link
Contributor Author

@brycehuang30 brycehuang30 Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure! will do

@brycehuang30
Copy link
Contributor Author

I updated the PR to soft import debugpy

Belowing are the manual tests after adding the soft import for debugpy
breakpoint without debugpy installed
image

breakpoint with debugpy installed
image

Post mortem without debugpy installed
image

post mortem with debugpy installed
image

Comment on lines 19 to 23
log.error(
f"Module '{module}' cannot be loaded. "
f"Ray Debugger will not work without '{module}'. "
f"Install this module using 'pip install {module}' "
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried throwing an exception when import error occurred, but it doesn't work well. The exception will be captured by Ray and drop the program into post-mortem mode, which will try to import debugpy again and throw another import error again... And end up with multiple levels of exception all saying there is an import error. So I choose to just log the error message and skip debugger logic if the module is not available.

Comment on lines 15 to 22
def _try_import(module):
try:
return importlib.import_module(module)
except ModuleNotFoundError:
log.error(
f"Module '{module}' cannot be loaded. "
f"Ray Debugger will not work without '{module}'. "
f"Install this module using 'pip install {module}' "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make this specific, look for debugpy >= 1.8.0, and then raise warning if not found (and suggest to user to install debugpy==1.8.0)

except ModuleNotFoundError:
log.error(
f"Module '{module}' cannot be loaded. "
f"Ray Debugger will not work without '{module}'. "
Copy link
Contributor

@richardliaw richardliaw Jan 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ray Debugpy Debugger

@can-anyscale can-anyscale merged commit 943490a into ray-project:master Jan 12, 2024
7 of 9 checks passed
brycehuang30 added a commit to brycehuang30/ray that referenced this pull request Jan 12, 2024
- enabled debugpy as the ray debugger for breakpoint and post_mortem debugging
- added flag RAY_DEBUG=1 to enable debugpy. If RAY_DEBUG is not set and RAY_PDB is set, then rpdb will be used.
- used state api to save worker debugging port.
can-anyscale pushed a commit that referenced this pull request Jan 12, 2024
- enabled debugpy as the ray debugger for breakpoint and post_mortem debugging
- added flag RAY_DEBUG=1 to enable debugpy. If RAY_DEBUG is not set and RAY_PDB is set, then rpdb will be used.
- used state api to save worker debugging port.
vickytsang pushed a commit to ROCm/ray that referenced this pull request Jan 12, 2024
- enabled debugpy as the ray debugger for breakpoint and post_mortem debugging
- added flag RAY_DEBUG=1 to enable debugpy. If RAY_DEBUG is not set and RAY_PDB is set, then rpdb will be used.
- used state api to save worker debugging port.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants