Enable PyCharm debugger to automatically attach to worker processes by patching startup command using PyDev
See original GitHub issueDescribe your feature request
Currently, Local mode is the only feasible way to debug Ray worker/actor code, but it would be great if debugging worked in non-local mode out of the box when using PyCharm.
PyCharm patches (see e.g. description here) all Python functions that are used to start new processes when launched in Debug mode (using pydev_monkey.monkey_patch_module) - so whenever you launch new subprocesses in Python (including using e.g. multiprocessing
), debugger attaches automatically - and everything works seamlessly.
The reason it doesn’t work with Ray is because worker processes/actors are started by Cython / native code, bypassing PyDev patches. If you were to patch the Python startup command within Cython code whenever PyDev is used (same as how PyCharm does it for respective Python functions) then debugging should just magically start working - and you wouldn’t even need Local mode anymore, if you use PyCharm.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:17
- Comments:5 (1 by maintainers)
This seemingly small change would make a huge difference in my workflow.
The PyCharm debugger is outstanding, but unfortunately useless with Ray actor code. I can debug everything except for the actors which is a huge pain.
@pcmoritz yeah I’ve seen that, but I don’t want to be “dropped into a PDB session”. What I want is an actual interactive debugging in PyCharm where I can step through the code line-by-line in my IDE and use all the debugging abilities that come with IDE. This is infinitely more useful and more user-friendly than pdb. And it generally works perfectly out of the box, including for sub-processes launched from Python - and should work with Ray workers as well if we were to patch python worker launch command accordingly (to invoke PyDev).