Preserving Jupyter Notebook v5 Execution Order and Metadata When Restoring Backups
27.6K reputation · 30 Dec 2023, 17:36 UTC
The goal is to confirm that a Jupyter Notebook backed up in format version 5 retains its original cell execution order, output, and custom metadata after being restored on a newer Jupyter environment. Verification involves opening the restored file, inspecting the execution counts, and ensuring that outputs are intact and that extensions’ metadata survive the migration.
However, several documented behaviors complicate this. The nbformat field in a v5 notebook signals that cell ordering should be interpreted by execution_count, which may be lost if the notebook is opened in a Jupyter 7 kernel that defaults to a different ordering logic. Additionally, the kernelspec metadata now includes a version subfield; a mismatch can lead to silent startup failures. The nbconvert preprocessor also strips output cells differently between Jupyter 6.x and 7.x, which can obscure recovered data. Finally, custom metadata keys added by extensions are not guaranteed to survive a major version jump.
Given these constraints, what mechanisms can be used to verify that the restored notebook’s execution order matches the original? Does Jupyter 7’s default ordering logic automatically reconcile execution_count values when opening a v5 notebook, or must a manual re‑ordering step be performed? How can one ensure that custom extension metadata is preserved during the restoration process, especially when migrating across major Jupyter releases?