-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Notebook validation failed: Non-unique cell id #6001
Comments
This message is related to some fairly recent changes to I'm cc-ing @MSeal for comment as to what might be going on and how best to proceed (as I'd rather not recommend downgrading). |
Sorry I accidentally hit the close button. 👀 on this now |
I also am struggling to reproduce the event with a very similar dependency list. Even if I manually force cell ids to be invalid / equal the notebook server corrects it with version 6.2.0 before it ever get to the validation error reported here. @kohlerjl could you post a notebook exhibiting the behavior? I am wondering if something in the file structure will lend a clue as to why the replaced cell-id is not being fixed. |
Thanks for the quick follow up. I spent some time trying to isolate a simple notebook that would reproduce the event. What I've found is that this behavior does not persist between closing and reopening the notebook, or even just refreshing the browser tab (leaving the kernel still running). However, I've been able to consistently reproduce this behavior by following these steps:
It appears that this behavior does not occur if you duplicate a cell created in the same 'session' (i.e. while the notebook is open in the tab). But If I copy and paste a cell created prior to opening/refreshing the notebook, either from the same notebook or a different notebook, then I get errors about duplicate ids. But the notebook changes do save, and I can simply refresh the tab to mitigate the errors. I have attached a notebook I produced this way, which gave me the errors prior to reloading it. However, I can't see any difference in the file structure. test.ipynb.txt I also cannot reproduce this behavior on another system, running Python 3.9.2 and: |
Thanks @kohlerjl. I'm still unable to reproduce this (sorry). Are you using the Notebook classic or Juptyer Lab interface? (Neither reproduces the issue for me however.)
This would be because that version of nbformat doesn't contain this consistency check. I'm using nbformat Btw, we started displaying the notebook server version in the console when the server is started in the 6.x timeframe. Could you please confirm the displayed value? The log entry should look similar to the following:
|
I can confirm that the notebook server reports "Jupyter Notebook 6.2.0 is running at:" on startup. I've been using Notebook classic. I installed Jupyter Lab and tried the same procedure, but cannot reproduce the behavior there. I might just transition to using Jupyter Lab going forward, since that seems to be more actively developed now. |
Thank you. I'll have to defer to @MSeal on this one.
Just a point of clarity, Jupyter Lab >= 3 uses a different server (jupyter_server) whereas Lab < 3 still uses notebook as its server - although I believe the issue here lies in the front-end where cells are manipulated. As a result, it might be helpful to know which version of Lab did not reproduce this behavior and whether you've tried this with Lab < 3.
Yes, that is absolutely the case. |
I get a similar error saying cell ID was corrected to 'domestic-communist'. From comments above it seems cell-id names are randomly generated. Maybe that randomization algorithm should be changed a bit. In this case I thought I was dealing with a virus... Title: Notebook validation failed I am running: |
@njohnsson make sure you have the latest package versions in your environment. We changed the id algorithm to use hashes and invalidated some of the older packages with name based id generation because it was creating problematic ids and marked the older nbformat packages as deprecated. Similar to @kevin-bates I've struggled to reproduce the issue in classic. That being said classic is not being actively developed. If you're looking for the same simple look-n-feel I'd suggest using Retrolab or NBClassic with lab instead as new package capabilities will slowly be less supported in classic over time. |
@MSeal: OK, I will update package versions, but just FYI: I the latest message I got ended with "....Non-unique cell id 'civil-spring' detected. Corrected to 'lesbian-voluntary'." |
I have been getting this as I do a lot of multi-cell It seems to go away when I close/reopen the nb. |
@njohnsson You can see why we revoked the nbformat packages. It was horribly problematic and attempts to correct the lexicon where still showing problematic combinations. The new version (5.1.3) just uses hashes. @EricThomson FYI the change needed is around nbformat and notebook server. The jupyter_client package is mostly unrelated. |
This worked for me as a temporary fix: import nbformat as nbf
from glob import glob
import uuid
def get_cell_id(id_length=8):
return uuid.uuid4().hex[:id_length]
# your notebook name/keyword
nb_name = 'my_notebook'
notebooks = list(filter(lambda x: nb_name in x, glob("./*.ipynb", recursive=True)))
# iterate over notebooks
for ipath in sorted(notebooks):
# load notebook
ntbk = nbf.read(ipath, nbf.NO_CONVERT)
cell_ids = []
for cell in ntbk.cells:
cell_ids.append(cell['id'])
# reset cell ids if there are duplicates
if not len(cell_ids) == len(set(cell_ids)):
for cell in ntbk.cells:
cell['id'] = get_cell_id()
nbf.write(ntbk, ipath) |
Also for me! Thank you very much for sharing. |
I appear to have the same issue after copying / pasting cells (pop_os! 20.10, python 3.9.5, jupyter 1.0.0). Thanks for the fix everybody. |
Workaround I've been using: cut in command mode (blue margin) but paste in edit mode (green margin). No more errors. Downside: when you paste in edit mode it all gets thrown into one cell, and it is put in code mode, so if you have a ton of formatted cells with lots of markdown, you will have to redo that). For my use case it is not that big of a deal so I'm pretty happy with this workaround. |
@MSeal I am still seeing name-based cell ids, even on nbformat 5.1.3. Background:
Since around March of this year, the "cell id" has been causing problems with this approach, since when I use "Reset kernal and Clear Outputs" to clear my outputs before checking in, all the ids change. This makes it really hard to identify the real changes. I found this PR today, so I upgraded to nbformat 5.1.3
I then ran "Kernel -> Restart and Clear Output". The new ids generated are still name-based and don't appear to be hashes - e.g.
Is this expected? My project is open source, so I have an environment and notebooks that I can share with you. But it seems like what you really need are logs. Happy to send you as many as you like if you let me know where to get them. This is currently 100% reproducible for me. |
Good news: I created a new notebook instead of editing an existing one, and now the IDs do seem to be hashes! See e-mission/e-mission-eval-private-data@d81a234 for an example. There are no changes in the several of the cells, but the hashes have changed. |
I am having similar issues ... |
any solution yet? |
Similar issues, the only action I was performing was copying a horizontal line and pasting it else where, It has something to do with what ET mentioned... first time I copied the horizontal line in command (blue) mode, and then pasted without creating a new cell, so it was pasted in command mode when a cell was highlighted (existing empty cell), the second time I copied it but pasted the markdown into a cell in edit more (green). Wasn't able to replicate it in a new page. Whats also interesting (not sure if intentional), when I paste the horizontal like in command mode, vs the markdown code into a cell in edit mode, the colour of the lines are two different shades. |
I used download as, saved file as a .ipynb, reopened with no errors. One method I was thinking of if the error persists is import the raw format which is a dict of dict and write some code to get all "id" and get the duplicate id, count the index position of the duplicate "id", then delete that cell in either the nb or the dict of dicts. |
I just updated my notebook packages yesterday and started getting this error when I copy paste anything (perhaps because I am working with notebooks made on older versions on jupyter notebook). It is pretty crippling to workflow. Any copy-paste of a cell means you have to close and reopen the notebook to stop the save warnings popping up every few mins. Not ideal. |
@kevin-bates @MSeal Is this issue extant and does it have a path to solution? @hadivafaii posted a solution that could be a fallback in the save routine to stop this problem ever reaching the end user. |
+1 also still having this problem |
The solution has to be done in the frontend here of Jupyter. I don't maintain any of the JS code here but the path @hadivafaii makes should be how the save operation need to change in JS side of things. |
FYI, here is the issue and pull request we made in jlab for supporting cell ids. |
Is this related to #5928? It should be clearing the ID before putting the item on the clipboard but appears that something is going wrong there. I'm having trouble repro'ing, but would it make sense to revert #5928? Being unable to save is worse than unstable cell IDs. Though there may just be an edge case which was missed in the PR and can be cleaned up. |
I not positive reverting cell id awareness would resolve the issue. Also it causes every notebook save to replace ids if we revert it which caused a lot of personal DMs to me about git diffs generated from other projects 😂 . @blois I can reproduce but I sometimes had to refresh the page twice or restart the server to get it to have the duplicate cell id. I'm not sure why local state was affecting it. Is there a second path for copy where it wouldn't clear the cell id in the buffer? |
@MSeal can nbformat's constraints be relaxed to resolve the conflict by re-generating conflicting keys? I think that's what users want in the end- for the tools to make a best effort but continue working. |
@blois it's actually doing that already. It's just complaining about it the in the UI as a warning on each save once in this state:
is the message sent back and the save isn't halted. |
@blois To be clear, The problem isn't that saving is prevented (it actually saves fine). The problem is that once the error occurs, it will pop up that warning EVERY. TIME. IT. SAVES. And the popup steals focus from whatever cell you were typing in at the time. And the popup needs a mouse interaction to get rid of it. All of which is, to put it mildly, a bit annoying and not conducive to a good workflow. I had to make the resave code an importable function because I have to use it so frequently to fix continually breaking notebooks. |
That is entirely possibly I posted my experience, can’t remember what it was. I do no that I wasn’t able to continue working.
…Sent from my iPhone
On Oct 13, 2021, at 4:31 PM, JMBurley ***@***.***> wrote:
@blois To be clear, The problem isn't that saving is prevent (it actually saves fine).
The problem is that once the error occurs, it will pop up that error EVERY. TIME. IT. SAVES. And the popup needs a mouse interaction to get rid of it.
All of which is, to put it mildly, a bit annoying and not conducive to a good workflow. I had to make the resave code an importable function because I have to use it so frequently to fix continually breaking notebooks.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
|
This solution worked for me. https://stackoverflow.com/a/69291092/17288157. I created a new folder. I put the code from the link in a notebook in the folder, and put the problematic notebook in the same folder. I then changed 'my_notebook' (that was assigned to After running the code from the link, the problematic notebook could save with no issues. The code was as follows:
|
Same thing happened to me and I found the solution. First select all the cells in the Jupyter Notebook, then press the "cut/scissors" button (don't panic, at this point your Notebook will be empty), and finally press the "paste" button. This worked for me after a long time !! I hope it helps you. |
@saraafernandeez Wonderful solution, thanks! Tested it. |
@saraafernandeez this is by far the easiest solution, especially if you have a lot of markdown cells. thank you! |
Thanks, worked for me! |
I had the same problem. Thank you for the temporary fix! In any case, I hope it will be properly fixed in newer versions :) |
Thanks @saraafernandeez!!! |
For me the problem was actually duplicate cells -- cells with exact same input and output. Once I deleted those Github was able to render the notebook! |
Thanks, running this code in the notebook and reloading the notebook solved the issue for me. |
I've had the same problem for over a year using different computers |
@vivianamarquez Maybe, this way could help u? |
I had the same issue. I don't understand why it happened, as nothing changed in my environment. I have many files in a folder and this error occurs in all of them. PARTIAL SOLUTION: I just copied the files into a different folder and all worked fine. :0 |
I just had the same error when copy-pasting cells, on Jupyter. Duplicating the nb worked for me and have not received the error message "Notebook validation failed: Non-unique cell id '########' detected. Corrected to '########'.: UNKNOWN" again. :) |
My Solution: I upload my .ipynb file to google drive, open it in google colab, save and download it, then I rewrite my old file with the new one from google colab. The error massage disappear. |
A simple solution is to use
|
I have recently started receiving this popup error frequently when saving notebooks:
It does not occur in new notebooks, but seems to be triggered after copying and pasting cells from other notebooks. But it is now occurring frequently on two different systems, editing different sets of notebooks. Once it appears within a notebook, it reappears on every subsequent save, with the same 'non-unique cell id' detected, but a different 'corrected to ' value.
I've attached the full output of
conda list,
but the versions of some particularly relevant packages are:jupyter 1.0.0 py37h03978a9_6 conda-forge
jupyter_client 6.1.11 pyhd8ed1ab_1 conda-forge
jupyter_console 6.2.0 py_0 conda-forge
jupyter_contrib_core 0.3.3 py_2 conda-forge
jupyter_contrib_nbextensions 0.5.1 py37hc8dfbb8_1 conda-forge
jupyter_core 4.7.1 py37h03978a9_0 conda-forge
jupyter_highlight_selected_word 0.2.0 py37h03978a9_1002 conda-forge
jupyter_latex_envs 1.4.6 py37hc8dfbb8_1001 conda-forge
jupyter_nbextensions_configurator 0.4.1 py37h03978a9_2 conda-forge
jupyterlab_widgets 1.0.0 pyhd8ed1ab_1 conda-forge
nbconvert 5.6.1 py37hc8dfbb8_1 conda-forge
nbformat 5.1.2 pyhd8ed1ab_1 conda-forge
notebook 6.2.0 py37h03978a9_0 conda-forge
The text was updated successfully, but these errors were encountered: