ray icon indicating copy to clipboard operation
ray copied to clipboard

[Debugger] Ray debugger interrupts with my normal flow of debugging

Open kouroshHakha opened this issue 2 years ago • 4 comments

What happened + What you expected to happen

When i run the repro code on ray 2.39 I get the message 2024-11-13 12:11:46,137 INFO debugpy.py:92 -- Waiting for debugger to attach (see https://docs.ray.io/en/latest/ray-observability/ray-distributed-debugger.html)...

but in 2.38 this wasn't the case, and I could interactively debug.

Please note that I have put the breakpoint on the driver and not inside the tasks / actors, so I don't really need distributed debugging here.

Versions / Dependencies

ray==2.39 doesn't work ray==2.38 works

Reproduction script


import ray


def main():
    ds = ray.data.from_items(
        [
            {
                "input": "David",
                "expected": "Hi David",
            },
        ]
    )
    breakpoint()
    
    

if __name__ == "__main__":
    main()

Issue Severity

High: It blocks me from completing my task.

kouroshHakha avatar Nov 13 '24 20:11 kouroshHakha

Thanks for reporting, you can restore the previous behavior by setting RAY_DEBUG=legacy

pcmoritz avatar Nov 13 '24 20:11 pcmoritz

I could see people who run a driver in an interactive shell wanting to use PDB directly in it. We could detect that and invoke PDB by default (if stdin is connected, which will be the case e.g. if you run in a shell). I'm not a huge fan of the inconsistency but good UX triumphs consistency sometime, what do you think @kouroshHakha ?

pcmoritz avatar Nov 13 '24 20:11 pcmoritz

yeah I think that's a reasonable. And if there is a flag to control this behavior by selecting pdb vs. debugpy is a good compromise.

kouroshHakha avatar Nov 13 '24 21:11 kouroshHakha

Hi @pcmoritz, I'd like to pick this up based on your suggestion above. Plan: in python/ray/util/rpdb.py _driver_set_trace, when RAY_DEBUG is not set explicitly and sys.stdin.isatty() is true, use the existing legacy _PdbWrap path so breakpoint() in an interactive driver drops into plain pdb. An explicit RAY_DEBUG=1 would still force debugpy, and breakpoints inside tasks and actors stay unchanged. I'll add tests to python/ray/tests/test_ray_debugger.py that mock stdin as TTY and non-TTY and assert which debugger is called. Should the TTY fallback be the new default, or opt-in through a new value such as RAY_DEBUG=auto? Could you assign it to me?

rahulsjha avatar Nov 17 '26 17:11 rahulsjha