-
Notifications
You must be signed in to change notification settings - Fork 297
Description
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:
- JupyterLab should expose a
sendControlMessage
as well as Interfaces for messages sent on the Control channel in the@jupyterlab/services
package. - JupyterLab should expose specific methods to send
debug_request
messages, handledebug_reply
anddebug_event
messages in the@jupyterlab/services
package. - The Notebook server should publicly expose the control channel
- The Jupyter server should publicly expose the control channel
- The Control channel should be exposed by
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. - Design a UI ;) (for the prototype we will quickly make a UI to test) EDIT: UI is available at https://github.com/jupyterlab/debugger/
Optional:
- The Notebook server should expose the same methods as JupyterLab in
notebook/services/kernels/kernelmanager.py
. Messages whosechannel
attribute iscontrol
should be rerouted to these methods. - The Jupyter server should be updated the same way.
3] Changes in the backends
The required changes are specific to the implementations of the different kernels. However a same approach can be used:
- Having a separate handling of Control and Shell channels
- Choose a debugger and implement The Debug Adapter Protocol to communicate with it
- Unwrap request from received
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.