bitter-ability-32190
06/08/2022, 4:50 PMbitter-ability-32190
06/08/2022, 4:55 PMdebugpy : https://github.com/microsoft/debugpy
So essentially there's two halves:
• A debugpy server must be launched with the relevant code running
• Your Editor (like VS Code) connects to it via a client, and sends the breakpoint and other info to it.
So if you wanted to do this today (try it!) Put the following at the top of your code:
import debugpy
debugpy.listen(5678) # Thats the port, localhost by debugpy.wait_for_client()
Running your code (./pants test --debug or ./pants run) then launches the server and waits for connection.
In your editor pick the "remote attach" option using the right port. Then F5 to launch the debugger. This connects to the server and tells it the current debugging info (breakpoints and other settings).
🎉bitter-ability-32190
06/08/2022, 4:57 PMWhat does this have to do with Pants?We can add an option to Pants to launch the relevant DAP when requested, so no code instrumentation is needed.
debugpy comes with a "launched" out of the box for this.
So (and details to be discussed) ./pants debug <spec> would run your code with the DAP server launched and waiting for a connection.bitter-ability-32190
06/08/2022, 4:57 PMwitty-crayon-22786
06/08/2022, 4:59 PMwitty-crayon-22786
06/08/2022, 5:00 PMwitty-crayon-22786
06/08/2022, 5:00 PMbitter-ability-32190
06/08/2022, 5:01 PMwitty-crayon-22786
06/08/2022, 5:01 PMexperimental-bsp … so experimental-dap might be a good parallelbitter-ability-32190
06/08/2022, 5:06 PMrun and test. ./pants dap path/to/test_file.py should probably run the file like the test goal, but with my proposal might be ambiguousbitter-ability-32190
06/08/2022, 5:06 PM--use-dap to run and testwitty-crayon-22786
06/08/2022, 5:07 PMtest has --debug , which supports conditionally adding additional argumentsbitter-ability-32190
06/08/2022, 5:08 PMwitty-crayon-22786
06/08/2022, 5:09 PM--debug, the JVM code adds [jvm] debug_args : https://www.pantsbuild.org/docs/reference-jvm#section-debug-argsbitter-ability-32190
06/08/2022, 5:11 PM--debug-dap (or similar) flags. I think we'd wanna compare Python's "drop-in" ability to maybe Java's or GO's DAPwitty-crayon-22786
06/08/2022, 5:23 PMbitter-ability-32190
06/08/2022, 9:05 PMdebugpy need to be launching the python script/module which makes it conflict a bit with the pytest PEX. I'm gonna have to finagle this onebitter-ability-32190
06/09/2022, 8:39 PMbitter-ability-32190
06/09/2022, 9:05 PMwitty-crayon-22786
06/09/2022, 9:24 PMbitter-ability-32190
06/13/2022, 7:32 PM--runwitty-crayon-22786
06/13/2022, 8:46 PM