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

Language metadata is not updated in .NET notebook #3602

Closed
2 of 17 tasks
stewartadam opened this issue Jul 11, 2024 · 5 comments
Closed
2 of 17 tasks

Language metadata is not updated in .NET notebook #3602

stewartadam opened this issue Jul 11, 2024 · 5 comments

Comments

@stewartadam
Copy link

Describe the bug

Creating a Jupyter notebook in VS Code appears to default to Python, which produces Python language metadata in the notebook:
https://gist.github.com/stewartadam/528689d9bb917715a4c16a6ff9282de3

This metadata is not updated or removed when switching the notebook to .NET Interactive, which causes issues for tools like Ruff which try and parse Python code out of notebooks: astral-sh/ruff#12281

Asks:

  • The notebook language should be updated to C# when the kernel is switched
  • Polyglot metadata on cells should be removed when changing the kernel back to Python

Please complete the following:

Which version of .NET Interactive are you using? (In a notebook, run the #!about magic command. ):
Version: 1.0.522904+cdfa48b2ea1a27dfe0f545c42a34fd3ec7119074
Library version: 1.0.0-beta.24229.4+cdfa48b2ea1a27dfe0f545c42a34fd3ec7119074
Build date: 2024-07-10T18:57:05.9093659Z

  • OS
    • Windows 11
    • Windows 10
    • macOS
    • Linux (Please specify distro)
    • iOS
    • Android
  • Browser
    • Chrome
    • Edge
    • Firefox
    • Safari
  • Frontend
    • Jupyter Notebook
    • Jupyter Lab
    • nteract
    • Visual Studio Code
    • Visual Studio Code Insiders
    • Visual Studio
    • Other (please specify)
@stewartadam stewartadam changed the title Python language metadata is not updated in .NET notebook Language metadata is not updated in .NET notebook Jul 11, 2024
@jonsequitur
Copy link
Contributor

Cell-level language is independent from which kernel is being used. Not all frontends will even look at this metadata. For example, .NET Interactive / Polyglot Notebooks metadata isn't read by JupyterLab, Jupyter Notebook, etc.

@stewartadam
Copy link
Author

Cell-level language is independent from which kernel is being used

This part is expected - but the ask is to remove cell metadata the front-end created when switching kernels to avoid stale data. The current state makes it impossible for tools like Ruff to parse out which language a cell is, since both Python and .NET cell metadata are left hanging around.

@jonsequitur
Copy link
Contributor

Removing cell metadata would mean that the act of switching kernels even accidentally -- or, for example, because the .NET Interactive kernel isn't available on your machine -- would remove important information about which cells target which languages or subkernels.

Do you know why Ruff reads cell-level metadata that's meaningless to Jupyter?

@stewartadam
Copy link
Author

It's parsing notebooks to apply linting rules.

This might be out of scope of the extension, but ideally there would be a canonical way to specify the cell's language that all frontends or tools could share while parsing the notebook.

@jonsequitur
Copy link
Contributor

Jupyter doesn't have the concept of cell-level language. Otherwise, .NET Interactive would have adopted it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants