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

Missing proper language field #625

Closed
silversillu opened this issue Jul 5, 2019 · 7 comments
Closed

Missing proper language field #625

silversillu opened this issue Jul 5, 2019 · 7 comments

Comments

@silversillu
Copy link

silversillu commented Jul 5, 2019

Bug report for Colab: http://colab.research.google.com/.

When I save a notebook in my local Jupyter Notebooks interface and explore the source, it has the following section:

"kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
}

On the other hand, when I download the .ipynb file from Colaboratory, this sections looks like this:

"kernelspec": { 
    "name": "python3", 
    "display_name": "Python 3" 
}

The problem with the latter is that many tools (such as notebook.js) rely on the language field to properly render the HTML which is needed for code highlighting etc.

For example, when I use nbpreview to preview my notebook saved from Colab,it will look like this:

<code class="lang-undefined" data-language="undefined">

Whereas, one saved from my local Jupyter Notebook will look like this:

<code class=" language-python" data-language="python">
@craigcitro
Copy link
Contributor

Thanks for the report!

I'm a little wary about adding a language field, since it's not part of the notebook format:
https://github.com/jupyter/nbformat/blob/11903688167d21af96c92f7f5bf0634ab51819f1/nbformat/v4/nbformat.v4.schema.json#L13-L27

Do you know if the tools you're looking to use also respect the language_info field? It looks like we're also failing to fill that one in, but I'd be much happier adding the info there.

Also adding @rgbkrk as knower of all things nbformat, in case language in the kernelspec is a de-facto standard.

@silversillu
Copy link
Author

Thank you for your answer @craigcitro

Yes, language_info field would work fine as well. (if it's set as language_info.name)

Just checked notebook.js source code and found this:

var lang = this.cell.raw.language || m.language || (m.kernelspec && m.kernelspec.language) || (m.language_info && m.language_info.name);

@maciejkula
Copy link

To revive this: this field is used for tools like nbconvert to correctly tag code fences: code.

This seems worth supporting.

@MSeal
Copy link

MSeal commented Mar 15, 2021

FYI there have been a couple reported issues trying to use papermill recently with colab notebooks that are missing this field (e.g. nteract/papermill#584). The language_info.name field should be the one to target for 4.x notebooks. You may also want to bump the minor version from 0 to 4 or 5, depending on if you have cell id support yet, to keep the spec versions closer to the more recent minor releases.

@blois
Copy link
Contributor

blois commented Mar 15, 2021

I'll take a look into this.

Cell ID support is in if you upload a notebook w/ v4.5, per jupyter/nbformat#189 (comment). An example if you want to give it a try is https://colab.research.google.com/gist/blois/161ecb9e8bc9ca8e9d1c277a0f6925fb/nbformat-4-5.ipynb - please let us know if there's anything unexpected.

I don't imagine we'll switch to 4.5 until at least JLab and possibly classic gain support (jupyterlab/jupyterlab#9729).

@MSeal
Copy link

MSeal commented Mar 15, 2021

Thanks for taking a look!

Classic and nteract have 4.5 support now, with lab still having partial support (id's save but get replaced on each save). I'll poke on that issue to see if we can get that prioritized.

@blois
Copy link
Contributor

blois commented Mar 18, 2021

The fix for this should be live now.

@blois blois closed this as completed Mar 18, 2021
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

5 participants