Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Ensure that cell ids persist after save#5928

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
kevin-bates merged 2 commits intojupyter:masterfrommishaschwartz:persist-cell-id
Jan 12, 2021
Merged

Ensure that cell ids persist after save#5928

kevin-bates merged 2 commits intojupyter:masterfrommishaschwartz:persist-cell-id
Jan 12, 2021

Conversation

@mishaschwartz
Copy link
Contributor

Summary

This PR ensures that if an'id' field exists for a cell when the notebook is loaded, the same'id' value is saved for the given cell when the notebook is saved.

The previous behaviour was that a new random'id' value was generated every time for each cell.

Details

As of nbformat schema 4.5, cells now have a mandatory'id' field for each cell:

If this field does not exist for a given cell, nbformat will generate a new value for that field.

When a cell is loaded by notebook using thefromJson function, this'id' field is ignored and when the cell is saved, nbformat sees there is no'id' and randomly generates a new one.

With this PR, the'id' field is saved to the cell data and then sent back to nbformat when the cell is saved so the cell id remains consistent between saves.

This PR also ensures that when cells are copied, the cell'id' is removed, meaning that nbformat will generate a new id for it when it is saved. This is required because cell ids must be unique within a notebook.

Why this is important

Tools, plugins, etc. that use cell ids will expect the cell ids to remain consistent between saves. Use of ids in plugins is one of the main reasons for adding the id field in the first place:

Copy link
Member

@kevin-bateskevin-bates left a comment

Choose a reason for hiding this comment

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

These changes look good to me - thank you@mishaschwartz.

Since this is more front-end/notebook behavior, I'd prefer someone more familiar with that aspect of things to take a look prior to merging.@jasongrout,@MSeal,@willingc - are any of you (or someone else) able to review this?

mishaschwartz reacted with hooray emoji
@kevin-bates
Copy link
Member

Hi@mishaschwartz - sorry for the delay. Let's give this a couple more days for someone with familiarity with the front-end to chime in. If no response by then, I'll go ahead and merge.

@mishaschwartz
Copy link
ContributorAuthor

@kevin-bates Thanks for the update. That sounds like a good plan to me.

Copy link
Member

@ZsailerZsailer left a comment

Choose a reason for hiding this comment

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

Looks good to me. 👍

@MSeal
Copy link

Awesome! Thoughts on promoting the nbformat package out of alpha once this merges?

willingc and mishaschwartz reacted with thumbs up emoji

Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@ZsailerZsailerZsailer approved these changes

+1 more reviewer

@kevin-bateskevin-bateskevin-bates approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

6.2

Development

Successfully merging this pull request may close these issues.

5 participants

@mishaschwartz@kevin-bates@MSeal@Zsailer@blink1073

[8]ページ先頭

©2009-2025 Movatter.jp