Skip to content

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

@KlausGPaul

Description

@KlausGPaul

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions