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

Check language_info key in kernel info received message content #96

Merged
merged 1 commit into from
Aug 17, 2020
Merged

Check language_info key in kernel info received message content #96

merged 1 commit into from
Aug 17, 2020

Conversation

davidbrochart
Copy link
Member

Fixes #95

if 'language_info' in info_msg['content']:
self.nb.metadata['language_info'] = info_msg['content']['language_info']
else:
raise RuntimeError(
Copy link
Contributor

@chrisjsewell chrisjsewell Aug 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of interest, should this raise an error or a warning, i.e. is language_info a strictly required component of the final notebook and/or does the kernel "guarantee" to reply with it given a successful execution?
e.g. in the specification https://nbformat.readthedocs.io/en/latest/format_description.html#notebook-metadata it is not present

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have limited knowledge of what this is actually doing lol,
but from:

https://github.com/chrisjsewell/jupyter_client/blob/778fa85c8ce7cd1a8ffe2fec2c1b8522d6c314ba/jupyter_client/adapter.py#L140
and
https://github.com/chrisjsewell/jupyter_client/blob/778fa85c8ce7cd1a8ffe2fec2c1b8522d6c314ba/jupyter_client/adapter.py#L251

it looks like if you are using the version 4 msg spec, it is not guaranteed, but if you use the version 5 msg spec it is (because of the setdefault)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to be optional in the notebook, but mandatory in the Jupyter protocol from version 5.0:

Changed in version 5.0: language_info, implementation, implementation_version, banner and help_links keys are added.

So I guess we should handle it differently depending on the version? Good catch by the way!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no problem 😄

So I guess we should handle it differently depending on the version?

I guess so, although note the protocol did change many years ago I think, so this should be an edge case?

just baffled by why there is even an error on RTD, the only difference between these runs is that in the second I tried using your fork, which passes 🤷 (jupyter-client is the same version in both)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, can you try with nbclient master?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeh I tried and its the same for master and 0.4.1 tag.
I think I've spotted the difference though: readthedocs/readthedocs.org#7360

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any reason to be backwards compatible to 4.x msg spec, so I think this is safe to make strict. 5 has been the defacto for a long time and I don't think there's many tools that work with 4 anymore.

@MSeal
Copy link
Contributor

MSeal commented Aug 6, 2020

Feel free to merge whenever -- we could add a test for this but I don't see it adding much benefit to capturing expected behavior in this error state.

@davidbrochart davidbrochart merged commit 2a07f91 into jupyter:master Aug 17, 2020
@davidbrochart davidbrochart deleted the kernel_info branch August 17, 2020 14:17
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

Successfully merging this pull request may close these issues.

info_msg contains no language_info
3 participants