-
Notifications
You must be signed in to change notification settings - Fork 325
Using the jupyterlab services API
This page describes how the Jupyter extension uses the @jupyterlab/services npm module to connect and control Jupyter kernels.
Jupyter kernels are processes that handle a set of messages called the Jupyter Messaging Protocol (or JMP for short).
In this diagram below, those messages are sent over the 0MQ portion.

We (the Jupyter Extension) need to send these messages to and from a Jupyter kernel.
The Jupyter org has provided the @jupyterlab/services npm module to help us do just that.

This npm module:
- Opens a websocket to the notebook server (see raw zmq for what we do when not using a Jupyter server)
- Creates an IKernelConnection interface for talking to the kernel
- Translates calls on the IKernelConnection to message structures
- Serializes the message structures into a specific wire-protocol that all kernels must implement
- Sends the serialized message over the websocket to the server. The server will multiplex the message to the correct 0MQ socket.
- Deserializes result messages from the wire-protocol back into messages, which in turn get changed into events in javascript.
The npm module essentially handles all communication to and from a kernel so that javascript can treat the kernel like a local object.
We started with the @jupyterlab/services because the first version of the Jupyter extension always talked to a notebook server, either by us starting one or the user providing one.
There were frequent issues with that and we switched to a more direct approach.
The direct (or raw as it's called elsewhere) doesn't talk to a notebook server. Instead it talks directly to the kernels over zmq:

This means
- Contribution
- Source Code Organization
- Coding Standards
- Profiling
- Coding Guidelines
- Component Governance
- Writing tests
- Kernels
- Intellisense
- Debugging
- IPyWidgets
- Extensibility
- Module Dependencies
- Errors thrown
- Jupyter API
- Variable fetching
- Import / Export
- React Webviews: Variable Viewer, Data Viewer, and Plot Viewer
- FAQ
- Kernel Crashes
- Jupyter issues in the Python Interactive Window or Notebook Editor
- Finding the code that is causing high CPU load in production
- How to install extensions from VSIX when using Remote VS Code
- How to connect to a jupyter server for running code in vscode.dev
- Jupyter Kernels and the Jupyter Extension