Skip to content
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

MissingIDFieldWarning warning in SysML jupyter notebooks may cause an issue in the future #88

Open
KlausGPaul opened this issue May 6, 2024 · 0 comments

Comments

@KlausGPaul
Copy link

Description

When creating a new SysML notebook, the console displays the following warning:

/home/.../anaconda3/lib/python3.10/site-packages/notebook/services/contents/manager.py:353: MissingIDFieldWarning: Cell is missing an id field, this will become a hard error in future nbformat versions. You may want to use `normalize()` on your notebooks before validations (available since nbformat 5.1.4). Previous versions of nbformat are fixing this issue transparently, and will stop doing so in the future.
  validate_nb(model['content'])

Environment

Freshly installed ubuntu 24.03 LTS minimal for ARM, running in a virtual UTM machine on a Mac Arm host. Environment

  • Anaconda3-2024.02-1-Linux-aarch64.sh
  • openjdk 11.0.15-internal 2022-04-19

Impact

None at this stage as this is a warning only, but may cause an issue in the future.

Workaround

I found https://stackoverflow.com/questions/75632445/anaconda-jupyter-notebook-and-missingidfieldwarning and used the proposed fix:

import nbformat

with open("problematic_notebook.ipynb", "r") as file:
    nb_corrupted = nbformat.reader.read(file)

nbformat.validator.validate(nb_corrupted)
# <stdin>:1: MissingIDFieldWarning: Code cell is missing an id field, 
# this will become a hard error in future nbformat versions. 
# You may want to use `normalize()` on your notebooks before validations (available since nbformat 5.1.4). 
# Previous versions of nbformat are fixing this issue transparently, and will stop doing so in the future.

nb_fixed = nbformat.validator.normalize(nb_corrupted)
nbformat.validator.validate(nb_fixed[1])
# Produces no warnings or errors.

with open("fixed_notebook.ipynb", "w") as file:
    nbformat.write(nb_fixed[1], file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant