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: 4 comments 9 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.
-
I can’t remember all the details.
I think that I edited the files of Jupyter in the disk. There’s a json file
that contains all the kernels and then had to reset the kernel. I think
that’s inside the folder of the Jupyter plugin.
Let’s say that it wasn’t pretty 😅
If that’s important for you, I can search for the code and probably give
more info about the solution
…On Sun, 17 Nov 2024 at 20:49 SebSIK ***@***.***> wrote:
My extension provisions a dedicated instance of Jupyter for each
developer. As a result, I have a specific server with a single kernel (by
default). If a certain notebook isn't configured with a kernel, I want to
automatically add this server and select the kernel without asking my user
to do so.
I want my user to have as few clicks as possible.
@nadavy <https://github.com/nadavy> Did you ever figure out how to do
this? I have the same problem.
—
Reply to this email directly, view it on GitHub
<#13548 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB7MUZR7LC4D24Y7CTUS37T2BDQLDAVCNFSM6AAAAABR6GZDZGVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCMRYGQ4DCOI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
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.