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

Fix part of the problem with notebook losing trust. #6240

Closed
wants to merge 1 commit into from

Conversation

Carreau
Copy link
Member

@Carreau Carreau commented Nov 23, 2021

See jupyter/nbformat#236 and
https://github.com/jupyter/nbformat/issue/235.

This mostly affects frontends that do not always add ids to cells,
like classic notebook, and that issue is not limited to cells ids, but
also to empty cells, that may not have/need a trusted field.

But that is another issue.

See jupyter/nbformat#236 and
https://github.com/jupyter/nbformat/issue/235.

This mostly affects frontends that do not always add ids to cells,
like classic notebook, and that issue is not limited to cells ids, but
also to empty cells, that may not have/need a trusted field.

But that is another issue.
Copy link
Member

@kevin-bates kevin-bates left a comment

Choose a reason for hiding this comment

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

Thanks @Carreau, just had a couple of comments/suggestions.

@@ -473,6 +496,8 @@ def save(self, model, path=''):
try:
if model['type'] == 'notebook':
nb = nbformat.from_dict(model['content'])

nb = normalize(nb, nb.get("nbformat"), nb.get("nbformat_minor"))
Copy link
Member

Choose a reason for hiding this comment

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

Is there a use case where we would NOT want to pull the version info from the notebook? If not, I think it would be cleaner to access the version info within normalize().

from copy import deepcopy

def normalize(nbdict, version, version_minor):
nbdict = deepcopy(nbdict)
Copy link
Member

Choose a reason for hiding this comment

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

Could we make the deepcopy conditional on version? Not sure how many pre-cell-id notebooks are out there but this would save some time/space for them.

def normalize(nbdict, version, version_minor):
nbdict = deepcopy(nbdict)

if version >= 4 and version_minor >= 5:
Copy link
Member

Choose a reason for hiding this comment

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

This needs a minor adjustment so lower minor versions are included for future major versions.

Suggested change
if version >= 4 and version_minor >= 5:
if (version == 4 and version_minor >= 5) or version >= 5:

@Zsailer Zsailer changed the base branch from main to 6.4.x March 7, 2022 18:20
@echarles echarles added this to the 6.4 milestone Mar 20, 2022
@jtpio
Copy link
Member

jtpio commented Jul 19, 2023

Closing as this would be something to implement in Jupyter Server, if still applicable: https://github.com/jupyter-server/jupyter_server

Also the Notebook 7 trust mechanism follows what JupyterLab and Jupyter Server implement.

@jtpio jtpio closed this Jul 19, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants