Skip to content

Supporting the Debug Adapter Protocol #446

@JohanMabille

Description

@JohanMabille

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 and Control channels should accept different messages; AFAIK this is somehow the current implementation, where most of the messages are sent on the Shell, while shutdown_request and interrupt_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 and debug_event. debug_request wraps a request described in the Debug Adapter Protocol and is sent on the Control channel exclusively. It expects a debug_reply wrapping a response described in the Debug Adapter Protocol. debug_event is sent by the kernel on the IOPub 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, handle debug_reply and debug_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 as shutdown_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 whose channel attribute is control 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 into debug_reply messages, and events into debug_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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions