Cell ID changes when notebook rerun only in JupyterLab

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:

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

So I’ll mark this topic as resolved and then follow up on the Issue. :+1: