I have noticed strange behaviour where the cell IDs of Jupyter notebooks (c.f. JEP 62 ) will change when a notebook is restarted and run but only in JupyterLab (this doesn’t happen if using a Jupyter Notebook server).
Here’s a Gist that demos the problem with large thanks to @choldgraf for giving me a hint :
.gitignore
.ipynb_checkpoints/
README.md
# Versioning problem example
With the addition of cell IDs to Jupyter notebooks (c.f. [JEP 62](https://jupyter.org/enhancement-proposals/62-cell-id/cell-id.html)) the ability to cleanly version them, even with all output cleaned from them, has become even harder given that subsequent runs of the notebooks change the cell ID and create a non-empty diff.
Note that this **only** seems to be a problem in JupyterLab. :?
Also reproducible in [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gist/matthewfeickert/20815c415adc891c015053cbd4bcc3e5/HEAD?urlpath=lab/tree/example.ipynb)
## Environment setup
This file has been truncated. show original
clean_run.diff
diff --git a/example.ipynb b/example.ipynb
index 66713cf..89cc325 100644
--- a/example.ipynb
+++ b/example.ipynb
@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
- "id": "expanded-samoa",
+ "id": "satisfied-forth",
This file has been truncated. show original
There are more than three files. show original
This behavior makes it very difficult / unreasonable to cleanly version notebooks, even with all output cleaned from them without using jupytext
.
Can someone explain to me why this behavior is happening only in JupyterLab and if there is a work around to avoid it?
1 Like
Seem like a bug to be:
Would cell ID be changed if the cell content changes, or just created one time when the cell is created? As an extreme example: What if the content of the cell is cut out entirely and pasted into a new cell? My assumption is the ID would remain the same, right?
Correct. It stays the same once created.
LIkely clearing the cell output remove the ID, which it should not.
2 Likes
Thanks very much for the speedy feedback, @carreau !
Seem like a bug
Cool. Looking around on JupyterLab’s GitHub it seems this has already been brought up 5 days ago on Issue #9729
opened 06:30PM - 03 Feb 21 UTC
closed 08:21AM - 08 Apr 21 UTC
enhancement
status:resolved-locked
We currently support notebook format 4.4. Notebook format 4.5 adds a new `id` fi… eld to cells. This issue is about supporting this newest version of the notebook format.
* [JEP](https://jupyter.org/enhancement-proposals/62-cell-id/cell-id.html)
* [nbformat PR](https://github.com/jupyter/nbformat/pull/189)
* [nbformat documentation](https://nbformat.readthedocs.io/en/latest/format_description.html#cell-ids)
### Related issues:
* Some conversation in https://github.com/jupyterlab/jupyterlab/issues/9064 is related to implementing this.
* https://github.com/jupyterlab/jupyterlab/issues/9645 details unexpected behavior with format 4.5 files
* https://github.com/jupyter/nbformat/issues/209 also discussed jlab support
So I’ll mark this topic as resolved and then follow up on the Issue.