-
Notifications
You must be signed in to change notification settings - Fork 29.3k
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
Kernel and renderer compatibility constraints #119899
Comments
Talked with Kai about this in my 1:1, mostly discussing the latter 'cold open' case. There are a few options to solve it. One question we had is, namely for Jupyter notebooks, does the notebook record what kernel was used for it? It seems like the answer is yes: "metadata": {
"kernelspec": {
"display_name": ".NET (C#)",
"language": "C#",
"name": ".net-csharp"
}, This doesn't quite map us to the "provides", but I wonder if we could add that in the metadata, at least for notebooks saved with VS Code. We could:
The pre-selection of renderer prevents the case of us switching renderers the first time the user runs a cell, which is a bad user experience (especially if it leads to a 'downgraded' output). For renderers that don't provide a hint, we can use the best renderer that doesn't require a specific kernel, and then 'upgrade' on the first execution if there's a new renderer that works with the current kernel. The other thing we talked about was dependency constraints. Maybe tags can also be specified as a path, like |
Talking to @rebornix, one thing we realized is that it's going to be very common to have a renderer that both talks to a kernel and renders the same mimetype as a different renderer that talks a to a different kernel. Notably, ipywidgets have their own special mimetype. So based on this, we can say that:
|
See #119899 Backwards compatible, initially. The implementation should be pretty unsurprising. Some churn from data wiring. This does the bulk of the work. The only remaining item is caching the last renderer used for notebooks in the workspace to avoid running selection again if the user reopens/reloads the window.
Implemented in the linked commits. In this initial version we did not have strong consensus around the range of requirements for constraints. Therefore currently we only do precise string matching. Later on we can add globs if users request it. |
Verifying this is kind of a pain, but possible:
|
In the initial prototype of renderers, we said that kernels would expose an interface in their preloads, and if a renderer loads in and sees that the expected interface is missing, it would be responsible for showing appropriate help to the user. However, this is not a polished experience for a variety of reasons.
In an ideal world both kernel-providing extensions and renderers statically define their compatibility "tags", but Jupyter kernels can be discovered and changed dynamically, so this is not possible. My plan is that:
This means that when we render an output, we can determine what and whether any installed renderers are compatible. With a marketplace integration that would let us search by tags, we also can suggest renderers that could be useful for the output. This is particularly important if the execution produces a mime type for which there is no existing renderer.
Currently kernels have a list of
preload
URIs, but these preloads also define the API(s) that the kernel provides. I suggest introducing a newNotebookKernelPreload
interface that would be used instead:Then in package.jsons, renders could define a list of
dependencies
oroptionalDependencies
.Dependencies is a "one of" list -- the renderer will be considered compatible if at least one of the requested dependencies is provided by the kernel.
optionalDependencies
can be used to hint at compatibility or kernels that can allow for better integration, but aren't required. When picking a renderer to use for some new output, VS Code will prefer renderers that have an available kernel in their dependencies over those which do not.To be discussed: Do we need to 'pattern match' dependencies, e.g. could I optionally depend on any "jupyter dap" kernel with
jupyter/*/dap
versus specificallyjupyter/python/dap
.Updated from discussion: To choose a renderer for an output, VS Code will assume 'richer-is-better' and prefer:
When opening a new notebook with existing output, VS Code will choose the best available renderer assuming that whatever kernel dependency it needs will eventually be available. Therefore, renderers must be able to deal with a kernel loading in after the first render.
If a cell is executed and its output renderer is no longer compatible with the current kernel, the selection algorithm runs again.
cc @vijayupadya @kjcho-msft
The text was updated successfully, but these errors were encountered: