Accessing Jupyter Kernels programmatically from API #13548
-
Hi, We are developing a hybrid notebook that is able to execute cells of 2 types: Python and custom DSL. For this to work, we'll need to grab/wrap a reference to the default python kernel programmatically, then based on the type/content of cell we'll redirect to the appropriate executor. After a lot of research on the topic, I've came across many outdated content and broken links, ex:
It seems to me the API has been reworked in a way it doesn't allow to expose kernel connections anymore, and many code examples I find here and there don't help unfortunately. I see also answers in this discussion stating this is not impossible, but there is no explanation on how to do it. Finally I found a similar discussion on the topic here stating it is possible to have this feature, provided that we give more info about the usage/context and the product we are building. Additionally, this package has no public releases available for install. What's the status of this feature on May 2023 ? How can one get access to the Python ipykernel using API and requestExecute ? Thanks in advance for your help |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
This is now supported via the api here const api = vscode.extensions.get<JupyterAPI>('ms-toolsai.jupyter').exports
const kernelApi = await api.getKernelService();
const jupyterKernel = kernelApi.getKernel(<Notebook URI>).connection.connection;
jupyterKernel.sendControlMessage(....)
jupyterKernel.sendControlMessage(...) As this is a proposed API, we would like to keep track of th extensions using this (so we can notify them of any changes to teh API). |
Beta Was this translation helpful? Give feedback.
-
@DonJayamanne I think that I need this API. I want to play with that but I keep getting |
Beta Was this translation helpful? Give feedback.
-
solution using stable apiplease use the following stable API for executing of coffee against a kernel https://github.com/microsoft/vscode-extension-samples/tree/main/jupyter-kernel-execution-sample |
Beta Was this translation helpful? Give feedback.
This is now supported via the api here
As this is a proposed API, we would like to keep track of th extensions using this (so we can notify them of any changes to teh API).
Hence a message will be displayed if you attempt to use this API.
To get rid of this message we request you file an issue with the details of your extension (extension id) so we can allow it to use this in release mode.