Skip to content

Extensibility for other extensions

Rich Chiodo edited this page May 3, 2022 · 4 revisions

Extensibility Points

The ms-toolsai.jupyter extension has a number of extensibility points for external partners to interface with. The definition of these extensibility points can be found here:

Api.ts

Some of the sub parts of that API are described in more detail below.

Datascience:registerRemoteServerProvider

This api is called by an external extension to register a remote Jupyter server URI provider. This provider has the capability to inject UI into this command here:

azure compute example

(in that example, the Azure Compute entry was added).

When implementing the IJupyterUriQuickPicker, you have a number of responsibilities:

  1. Add a jupyterRemoteServerProvider to your package.json contributes section. Like so:
	"contributes": {
		"jupyterRemoteServerProvider": []
	},

  1. Call registerRemoteServerProvider in your extension's activate function.
  2. Provide an entry point for the dialog above. You do this with the call to getQuickPickEntryItems.
  3. Provide handleQuickPick. This function is called if the user picks one of your entries you provided in getQuickPickEntryItems.
  4. handleQuickPick can put up more UI to ask the user to pick from a number of choices. Its end result should be a handle to a choice or 'back'. That handle is a string value that will be used later to identify the choices the user made in your UI.
  5. getServerUri should be able to take a handle returned from handleNextSteps and provide an authorization header and a URL for final connection to a Jupyter server. At this point you might ask for a user name/password.

An example of implementing IJupyterUriQuickPicker can be found here:

Example extension

Context Keys for keybindings

The jupyter extension defines a number of context keys that can be used in when clauses for keybindings. These include:

Context Key When is it true
jupyter.isnativeactive true if the currently active notebook is a jupyter notebook (as opposed to say a github issues notebook)
jupyter.notebookeditor.canrestartNotebookkernel true when the current kernel for a notebook is active
jupyter.notebookeditor.canInterruptNotebookKernel true when the current kernel for a notebook is not busy
jupyter.interactive.canRestartNotebookKernel true when the current kernel for an interactive window is active
jupyter.interactive.canInterruptNotebookKernel true when the current kernel for an interactive window is not busy
jupyter.isinteractiveactive true when an interactive window is the active editor
jupyter.isinteractiveornativeactive true when the active editor is a notebook or an interactive window
jupyter.ispythonornativeactive true when the active editor is a python file or a notebook
jupyter.ispythonorinteractiveeactive true when the active editor is a python file or an interactive window
jupyter.ispythonorinteractiveornativeeactive true when the active editor is a python file, a notebook, or an interactive window
jupyter.havenativecells true when a notebook has any cells
jupyter.ispythonnotebook true when the kernel for a notebook is python based
jupyter.kernel.isjupyter true when the kernel for a notebook comes from the jupyter extension
jupyter.hasNativeNotebookOrInteractiveWindowOpen true when a notebook or an interactive window is open
jupyter.notebookeditor.debuggingInProgress true when debugging a notebook cell
jupyter.notebookeditor.runByLineInProgress true when running by line is active in a notebook cell
jupyter.dataViewerActive true when the dataviewer panel is open
jupyter.ownsSelection true when the setting jupyter.sendSelectionToInteractiveWindow is true
jupyter.hascodecells true when cell markers are present in the active python editor
jupyter.zmqavailable true when ZMQ support is enabled on the user's machine (determines how kernels are started)
jupyter.replayLogLoaded used for debugging pylance LSP output
jupyter.development true if building extension from command line
jupyter.webExtension true if running in the web version of the extension
jupyter.vscode.channel set to vscode channel (insiders or stable)
Clone this wiki locally