Notebook test#20
Merged
Merged
Conversation
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.
Closes #14 by converting notebooks to scripts and running them with pytest.
Proposed changes
Adds automated end-to-end execution tests for the example notebooks (docs/examples/*.ipynb) using nbconvert, so an API change that breaks a documented example is caught in CI rather than by users. The notebook tests are heavy, so they're kept out of the standard test suite and run in their own dedicated workflow — triggered on notebook changes and reused by the release pipeline to gate publishing.
Details
tests/test_notebooks.pyauto-discovers everydocs/examples/*.ipynband re-executes each from a clean state via nbconvert's ExecutePreprocessor (900s timeout, run with the notebook's own dir as cwd). A test fails if any cell raises, surfacing the offending cell's traceback. Test IDs are the notebook filenames, so new examples are picked up automatically.The module is marked
pytest.mark.notebooks;pyproject.tomlregisters the notebooks marker and sets addopts = "-m 'not notebooks'", so a bare pytest (and the existingtests.ymljob) deselects them.Added notebook-execution deps (nbconvert, nbformat, ipykernel, matplotlib) to the [dev] extra.
Dedicated reusable workflow
.github/workflows/notebooks.ymlrunspytest -m notebooks -v. Triggers: pull_request/push to main filtered to paths that affect notebooks (docs/examples/**.ipynb,tests/test_notebooks.py,pyproject.toml, the workflow itself).updated
.github/workflows/release.ymlto call the reusable workflow via a test-notebooks job, and publish-testpypi now needs: [test-install, test-notebooks] so a broken notebook blocks the release.pytest and tests.yml are unchanged in behavior (notebooks deselected).
pytest -m notebooks selects and runs both example notebooks; both pass locally (pulse_smoothing.ipynb ~2.5 min after the fix).