-
Notifications
You must be signed in to change notification settings - Fork 294
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
Notebook change events are not firing when changing a kernel #15965
Comments
I tried this same thing with just a plain folder and a plain notebook and I can't reproduce it there. It only reproduces with this bokeh example for me. |
I can do this with a simple notebook now if I'm using anaconda, although maybe that's just a coincidence. Not sure how anaconda could change the timing. |
Facing the same issue, it seems to work again if I downgrade to |
My understanding is the reason we emit content change event on kernel change is the kernel spec metadata is modified. If the kernel spec metadata is not changed (e.g., switching from one python 3.12 to another 3.12), there is no document metadata change so it will not emit any content change either. IIRC Pylance gets the python interpreter path from Jupyter extension, I wonder if this can be an event from Jupyter itself. |
This works too. We'd have to send a custom message, although we'd probably just send the notebook did change message |
It may not be relevant but if we had a custom message, wouldn't that mess up other extensions that might be relying on tracking kernel changes? |
I can confirm this is still an issue on all latest releases, as I reported here microsoft/pylance-release#6285 Every time I want to open a Jupyter notebook for which I haven't already chosen a kernel, I have to
Only then does the language server update. Fairly workflow disruptive. |
Easiest reproduction for me:
No messages sent about kernel change |
@rchiodo registerJupyterPythonPathFunction(func: (uri: Uri) => Promise<string | undefined>): void; & from my understanding, pylance will call the registered function If thats the case, then I'm proposing we create a new API as follows (or a new one): registerJupyterPythonPathProvider(provider: JupyterPythonPathProvider);
interface JupyterPythonPathProvider {
onDidChange: Event<Uri>;
getPythonPath(uri: Uri): Promise<string | undefined>;
} |
@karthiknadig This way, other LS will benefit from this as well, & any tool wanting the Python env used in a Jupyter notebook will be able to get it via a unifieid API. I think that will make it simpler, and more accessible to other extensions as well. |
Moving this issue to VS Code-Jupyter extension, as this is not generic to VS Code. |
This should be possible with the new API I am working on. This will have an API that can pass any Uri and get a python for it. We can discuss if that can fit here. |
I disagree about putting this in the python extension (tracking kernel changes). Other extensions likely need to know when a kernel changes, regardless of whether or not the kernel is in a jupyter notebook, or in a different kind of notebook. Additionally, the python extension would only track changes to 'python' kernels. What if the user switches to a C# kernel? (and the C# kernel has the same issue with multiple kernels not causing a did change event). The root cause of the problem is that onDidChangeNotebookDocument event doesn't fire unless the underlying text model changes. But jupyter notebooks are backed by more than one model - the file on disk, and the current kernel stored somewhere else (I assume in memento storage). I think the correct fix here is to fire the event when either changes. |
I think we can make this a lot better with the fix I just proposed.
|
Closing as this PR was merged #15967 |
Does this issue occur when all extensions are disabled?: No, requires the Jupyter extension
Steps to Reproduce:
Expected result:
Kernel change notification happens
Actual result:
No changes detected.
This seems to be causing this issue here:
microsoft/pylance-release#5172
The text was updated successfully, but these errors were encountered: