-
Notifications
You must be signed in to change notification settings - Fork 283
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
Supporting the Debug Adapter Protocol #446
Comments
Very nice! Long time needed. Thank you all for working on this and contributing to the project! |
The "phase1" of the development in 1] Mapping Notebook cells to filesNow comes the problem of mapping Notebook cells to files. When setting a breakpoint, a path to a file containing the code and a line number must be specified. The file must exist, otherwise Typical usage of the debugger is to set breakpoints before starting the debugging sessions itself. Another use case is when a cell that already contains a breakpoint is modified before being executed again. Considering the constraints on breakpoints previously mentioned, the following sequence should allow to handle all the scenarios:
Since this requires sending additional messages to the kernel, this should be done only when a debug session has started. This means that either the user cannot set breakpoints before he has started the debugger, or that the frontend sends all the cells and the existing breakpoint list upon debugger start. 2] Implementation of the mapping in the kernelAlthough this is kernel specific and should not impact the design of the protocol, I think it might be interesting to dicuss it here. Two approaches are possible:
I am not entirely clear with all the potential limitations we might still encounter with ptvsd, so I will play a bit with it and update this accordingly. 3] Stepping into imported filesThis is specific to the frontend. When stepping into a function that is defined in an imported file, the frontend should open this file in text mode and allow to set breakpoints in it. |
At QuantStack, we are working on a prototype of debugger for the Jupyter ecosystem. This issue tracks the changes we need to make to get it done; some of them might be integrated independently from the debugger if they are considered as a global improvement.
The idea is to reuse the Debug Adaper Protocol from Microsoft. These messages are wrapped in new Jupyter messages that are sent on the Control channel.
1] Changes in the protocol
The
Shell
andControl
channels should accept different messages; AFAIK this is somehow the current implementation, where most of the messages are sent on the Shell, whileshutdown_request
andinterrupt_request
are sent on the Control, however it would be clearer to have it formaly stated in the protocol itself. @jasongrout opened Updates to the kernel messaging spec #388 to update the documentation along these lines.Three new messages are added to the protocol:
debug_request
,debug_reply
anddebug_event
.debug_request
wraps a request described in the Debug Adapter Protocol and is sent on the Control channel exclusively. It expects adebug_reply
wrapping a response described in the Debug Adapter Protocol.debug_event
is sent by the kernel on theIOPub
channel. Having the messages from the Debug Adapter Protocol wrapped in Jupyter Messages avoids copying the full specification from Microsoft and "polluting" the Jupyter specification with a lot of new messages that might be ambiguous (terminate
,configurationDone
, ...). Done in Document debug_[request|reply] and debug_event #464, and [DO NOT MERGE] Specify that the debug messages follow the debug adapter protocol #502.2] Changes in the frontends
Frontends should be able to send messages directly on the Control channel, which is currently not exposed at all:
sendControlMessage
as well as Interfaces for messages sent on the Control channel in the@jupyterlab/services
package.debug_request
messages, handledebug_reply
anddebug_event
messages in the@jupyterlab/services
package.jupyter_client
classes that are used in the implementation of the Notebook Services and the Jupyter Server Services. In the current implementation, the frontend sends all the messages on the Shell channel, and some messages such asshutdown_request
get a special handling to be sent on the Control channel.Optional:
notebook/services/kernels/kernelmanager.py
. Messages whosechannel
attribute iscontrol
should be rerouted to these methods.3] Changes in the backends
The required changes are specific to the implementations of the different kernels. However a same approach can be used:
debug_request
messages and reroute them to the debug adapter. Wrap response intodebug_reply
messages, and events intodebug_event
messages.As an example, we are using xeus and xeus-python to experiment with PTVSD.
cc @jasongrout @SylvainCorlay @afshin @ivanov @martinRenou @wolfv
EDIT: Actually exposing methods to handle debug messages in the Notebook server is not mandatory if we don't plan to add the debugger to the notebook. Exposing the control channel is enough as long as JupyterLab depends on the Notebook server. Exposing the control channel in the Jupyter server is useful if JupyterLab switches from the Notebook server to the Jupyter server at some point.
The text was updated successfully, but these errors were encountered: