-
Notifications
You must be signed in to change notification settings - Fork 299
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
Persist Cell Language in Notebook Cell Metadata #4757
Comments
Thanks for reporting this issue, this is a known issue. Does the Ruby kernel allow you to run Python code as well? |
Related issues:
|
In the samples provided above, the cells had been saved after executing. It did persist when closing the notebook and reopening -- provided you never close the editor. Once you close VS Code, start it, and then open the notebook, the cells appeared as depicted in the second screenshot. When the ruby kernel is selected, I can run both Ruby and Python in the same notebook as shown. I will say that I can't pass output to the next cell if the languages are different, but other than that, I can run both languages in one notebook. |
Check with John Lam about state of polyglot notebook investigation. |
Moving back to triage, as Johns spec doesn't address this, that's a whole different spec (related to execution, not persisting information in cells). |
I think this should be addressed. It's a pity that every time I re-open VsCode I lose all my previous settings for each cells. Only the markdown seems to be persisted. As the duplicated #4934 mentionned, cells always reset back to python while they were shell script, json, html, etc. I understand that Jupyter Notebook, by default keep all as "python" then we have to add the %%bash, but it would be very nice to keep track in the metadata of such details. |
I also used to have this issue, but for me it is fixed. |
The original bug still repro's in vscode insiders 1.61 and an associated jupyter extension. |
Concerns:
|
I think that I am having this issue right now. I create a blank notebook with a powershell cell. I don't select a language kernel. I save the notebook, close it, and open it again. The language of the cell is changed to python. I can't get the language of a cell to save in the notebook editor. |
mostly fixed in vs code insiders, though a blank cell will still lose language selection when closing and re-opening the .ipynb file or selecting a different kernel. So more of an edge case now |
Hey @amunger, I am still seeing this in stable when working with .net interactive. If I open up a notebook (I've attached it) that has a C# cell and an F# cell, they both open up as C# despite the correct metadata being saved by our extension but I can't reopen microsoft/vscode#140673 as it's limited to collaborators. |
The notebook you attached only has the language specified in the "dotnet_interactive" metadata, which vscode doesn't seem to use to set the cell language, but if I open that file with the latest .net interactive extension installed, it immediately adds the vscode metadata and seems to have the correct language set in the cell (without the .net extension, the cell language is C# for both).
So I'm not sure how you are managing to save a notebook without that vscode metadata. Is the kernel getting selected correctly? |
Right. The issue is that on first open, the Jupyter extension rather than the .NET Interactive extension opens the notebook, and the cell languages are shown incorrectly. The metadata is set as expected but the wrong extension is opening the notebook. |
ah, I got that to repro once out of around 10 tries. But how was this file created in the first place where it doesn't have vscode.languageId in the metadata? |
It could be an older file from before that metadata was implemented or it could be an .ipynb that was created or edited using an editor other than VS Code. |
@jonsequitur is this still an issue in the latest version of VS Code? |
No, this is no longer an issue. |
Thanks, closing this issue for now. |
This issue appears to have regressed as of VS Code v1.74.2. The attached notebook has the language specified as Matlab everywhere possible, but when I open it in VS Code the language indicator in the bottom right briefly reads MATLAB before switching to Python (along with a tonne of red squiggles, because the code is very clearly Matlab and not Python). Environment info:- Version: 1.74.2 (user setup) Relevant extentions and their versions:- Jupyter v2022.11.1003412109 |
Environment data
Version: 1.54.0-insider
Commit: 93f705ab40b37aade9d3b5165ed09114a8c87ac9
Date: 2021-02-11T05:43:26.672Z (8 hrs ago)
Electron: 11.2.3
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Darwin x64 20.3.0
Expected behaviour
In a notebook, when I select the language for a cell, it should retain that setting whenever the notebook is opened. This should be maintained even if the kernel is changed because the language highlighting in the cell depends on this selection.
The example shows expected behavior when python and ruby cells are included in a notebook.
Actual behaviour
When I close the notebook file, and reopen it in the same session, the selections seem to be maintained; however, when I close the editor completely, reopen the folder, then open the file, the language selections are reset.
The example shows the ruby kernel selected, but all cells are marked as "Python." Also, notice that the ruby cells are marked with syntax errors based on python.
Steps to reproduce:
The example images show a very basic notebook format that will reproduce the problem.
I'm not sure exactly what determines the language automatically chosen. In the example above, the iruby kernel was selected at close, and was selected when I started the editor, yet all cells were marked as Python.
Lastly, to repeat the behavior stated above, as long as I haven't closed the editor itself, I can open and close notebooks, and switch kernels without impacting the cell language selections.
The text was updated successfully, but these errors were encountered: