Skip to content
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

Changing Language modes for cells permanently #140673

Closed
teddywaweru opened this issue Jan 13, 2022 · 8 comments
Closed

Changing Language modes for cells permanently #140673

teddywaweru opened this issue Jan 13, 2022 · 8 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders notebook-serialization verified Verification succeeded
Milestone

Comments

@teddywaweru
Copy link

Not sure if VS Code allows for this, but would it be possible to permanently change a cell's language mode even after the text editor is closed? This is applicable in my case when running SQL scripts in Jupyter cells. Currently, once the text editor is closed, the user has to manually change each cell, which is futile if the editor is to be closed later.

@ghost ghost assigned IanMatthewHuff Jan 13, 2022
@IanMatthewHuff
Copy link
Member

@teddywaweru My apologies, I'm a bit unsure of what you are referring to here. For each cell there is a language selector that should be permanent after you change it. Are you changing the language modes and that is not being persisted somehow?

A screenshot might help here with illustrating what the issue is.

@teddywaweru
Copy link
Author

Yes, that's exactly it. Once you change it, it's only persistent for as long as the editor is open. If it's closed & reopened, the language modes for all cells default back to Python.

@teddywaweru
Copy link
Author

image
Here's a screenshot of a freshly opened editor. All cells were previously set to SQL language mode.
According to the language mode it's set to Auto detect, & I assume VS Code would use the file extension to determine this. could the Auto detect be the causative on my end?

@IanMatthewHuff
Copy link
Member

@teddywaweru Thanks for the info.

I actually do repro this issue. Seems like this might be due to this being a "Python" kernel that can execute SQL or Javascript via magics like %%SQL or %%javascript. I think that when the file is reopened that it might be picking up Python due to the Kernel that is selected, even though python kernels can run SQL or JS code.

When I don't have a kernel selected yet (just after creating a new document) the language selector works fine and does retain the selected language. It's when I pick a python kernel that this issue starts to crop up for me.

I might look at this myself, but I'm actually going to transfer this issue as the language selector is part of the core vs code notebook support versus the Jupyter extension.

@IanMatthewHuff IanMatthewHuff transferred this issue from microsoft/vscode-jupyter Jan 13, 2022
@teddywaweru
Copy link
Author

That would make sense, but I'm unable to reproduce it. I've tried opening a new Jupyter Notebook in a new editor instance without the kernel selected & randomly changing the cell languages. Upon saving the document, all the cells immediately refreshed & defaulted back to Python Language on the open editor. The only other language change that 'sticks' is the markdown, which is also expected for .ipynb files...
I still think it's the extension name that provides VS Code with the languages mode, & why they'd appear as the first ones on the list(also why the kernel suggestions would be Python env.s).
Thank you for your time on this...Hopefully there'll be a breakthrough. 👍

@greazer
Copy link
Member

greazer commented Feb 15, 2022

Doesn't appear that changing the language for a cell is persisted at all, since on opening the ipynb as json language is not stored per cell. I expected to see something in the cell metadata. Even if there is no metadata notebook standard for this, it seems like we should be persisting and setting it ourselves so the user can actually make use of the language selectors as intended.

@rebornix
Copy link
Member

rebornix commented Feb 16, 2022

@roblourens I think we should think about saving the language info in custom cell metadata when users pick a language which is different from the global language (say Python). There is no Jupyter standard for it yet but maybe this can be one JEP from us.

@greazer greazer added this to the March 2022 milestone Mar 4, 2022
@rebornix
Copy link
Member

This particular issue is a duplicate of microsoft/vscode-jupyter#4757. It's related to polyglot and cell magics. I don't think we currently have a story for it yet. @greazer you have put it in the March milestone, do you expect anything in particular for this to be done this month?

@mjbvz mjbvz added the verified Verification succeeded label Mar 24, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Apr 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders notebook-serialization verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

7 participants
@roblourens @IanMatthewHuff @rebornix @greazer @mjbvz @teddywaweru and others