Fix invalid JSON in DiCE_getting_started_feasible notebook (#439)#468
Open
jbbqqf wants to merge 1 commit into
Open
Fix invalid JSON in DiCE_getting_started_feasible notebook (#439)#468jbbqqf wants to merge 1 commit into
jbbqqf wants to merge 1 commit into
Conversation
Removes the trailing comma after `"nbformat_minor": 4`, which made the notebook fail to parse as JSON: GitHub's preview refused to render it and JupyterLab raised `NotJSONError` when opening it. Adds a `test_notebook_is_valid_json` parametrized test that loads every shipped notebook with `json.load`, so a malformed notebook can no longer slip into the repo unnoticed (the existing nbconvert test for this notebook is `pytest.mark.skip`-ed). Closes interpretml#439, interpretml#425. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
docs/source/notebooks/DiCE_getting_started_feasible.ipynbshipped with atrailing comma after
\"nbformat_minor\": 4(last lines of the file), whichmade the file invalid JSON. As @rmnldwg reported in #439, this prevents the
notebook from rendering on GitHub and from opening in JupyterLab
(
NotJSONError). #425 reports the same symptom.The notebook is currently
pytest.mark.skip-ed intests/test_notebooks.py("needs changes after latest refactor"), so the malformed JSON has been able
to sit in the repo for >2 years without CI catching it.
Why
Two changes here, the second is the load-bearing one:
test_notebook_is_valid_jsontest thatjson.loads every.ipynbunderdocs/source/notebooks/. Cheap, nonbconvert/jupyter execution required, runs in the default test job. This
means a notebook with malformed JSON can no longer be merged silently
even if its nbconvert test stays skipped.
Reproduce BEFORE/AFTER yourself (copy-paste)
What I ran locally
pytest tests/test_notebooks.py::test_notebook_is_valid_json→ 8 passedjson.loadraises onorigin/mainand parses on this branchEdge cases
docs/source/notebooks/advanced_notebooksskip listAI disclosure
This change was prepared with the assistance of Claude (Anthropic).
The author reviewed every line and is responsible for the final result.