Skip to content

Issue with jupytext in linter #647

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

Open
gpsaggese opened this issue May 2, 2025 · 0 comments
Open

Issue with jupytext in linter #647

gpsaggese opened this issue May 2, 2025 · 0 comments

Comments

@gpsaggese
Copy link
Contributor

          > @dremdem I have run the linter not sure abt the error. The files are linted

I ran the Linter on this file locally and got:

RuntimeError: /venv/lib/python3.12/site-packages/nbformat/__init__.py:96: 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. [process_jupytext]
Traceback (most recent call last): [process_jupytext]
[jupytext] Reading dev_scripts_helpers/update_devops_packages/notebooks/Master_buildmeister_dashboard.ipynb in format ipynb [process_jupytext]
dev_scripts_helpers/update_devops_packages/notebooks/Master_buildmeister_dashboard.ipynb: Cell content differ on code cell #7: --- expected [process_jupytext]
process_jupytext failed with command `$(find -wholename '*dev_scripts_helpers/notebooks/process_jupytext.py') -f dev_scripts_helpers/update_devops_packages/notebooks/Master_buildmeister_dashboard.ipynb --action test`
 [process_jupytext]

Found some info
https://stackoverflow.com/questions/75632445/anaconda-jupyter-notebook-and-missingidfieldwarning

Tried that approach:

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)

But no luck.

Feel free to file a bug.
FYI @sonniki

Originally posted by @dremdem in #598 (comment)

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