Skip to content

Conversation

@drbenvincent
Copy link
Collaborator

@drbenvincent drbenvincent commented Dec 20, 2025

Introduces a GitHub Actions workflow to run and validate Jupyter notebooks in CI using a new runner script. Adds scripts to mock PyMC sampling for faster execution, updates test dependencies to include papermill, and documents the notebook runner usage. Also updates the interrogate badge to reflect new coverage.


📚 Documentation preview 📚: https://causalpy--602.org.readthedocs.build/en/602/

Introduces a GitHub Actions workflow to run and validate Jupyter notebooks in CI using a new runner script. Adds scripts to mock PyMC sampling for faster execution, updates test dependencies to include papermill, and documents the notebook runner usage. Also updates the interrogate badge to reflect new coverage.
@drbenvincent drbenvincent added documentation Improvements or additions to documentation devops DevOps related labels Dec 20, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces automated testing for Jupyter notebooks in CI using Papermill. The implementation includes a runner script that mocks PyMC's MCMC sampling with faster prior predictive sampling to validate notebooks execute without errors.

Key changes:

  • New notebook runner script with filtering capabilities for different notebook types
  • Mock PyMC sampling implementation that replaces expensive MCMC with prior predictive sampling (10 draws)
  • GitHub Actions workflow that runs notebooks in parallel across three categories (PyMC, sklearn, and other notebooks)

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
scripts/run_notebooks/runner.py Main script for executing notebooks with Papermill, includes filtering and logging
scripts/run_notebooks/injected.py Mock implementation of pm.sample that uses prior predictive sampling
scripts/run_notebooks/README.md Documentation for the notebook runner usage and CI integration
.github/workflows/test_notebook.yml GitHub Actions workflow for parallel notebook testing
pyproject.toml Adds papermill to test dependencies
docs/source/_static/interrogate_badge.svg Updates documentation coverage badge from 96.3% to 96.0%

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Dec 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.77%. Comparing base (9ddf58c) to head (5e8005c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #602      +/-   ##
==========================================
+ Coverage   93.74%   93.77%   +0.02%     
==========================================
  Files          41       41              
  Lines        6827     6827              
  Branches      458      458              
==========================================
+ Hits         6400     6402       +2     
+ Misses        267      266       -1     
+ Partials      160      159       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

drbenvincent and others added 10 commits December 24, 2025 04:13
Updated the mock for pm.sample() to use 100 draws instead of 50 for prior predictive sampling, as reflected in both the injected script and documentation. This change aims to provide more robust validation during notebook execution.
Updated the mock for pm.sample to use 500 draws instead of 100 to ensure compatibility with notebook code that iterates over posterior samples, such as plot_ate which defaults to 500 draws. Adjusted documentation and injected.py accordingly.
Introduces skip_notebooks.yml to specify notebooks incompatible with prior predictive sampling mock. Updates runner.py to filter out these notebooks and reduces MIN_DRAWS from 500 to 100 for faster execution.
Replaces import of LinearRegression from causalpy.skl_models with sklearn's LinearRegression and removes execution count from the first code cell.
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Replaces hardcoded sample size with dynamic calculation based on the length of 'uncertainty' to prevent errors when fewer than 500 samples are available. Also resets execution count to null for the affected notebook cell.
Expanded the skip_notebooks.yml file to include iv_pymc.ipynb, which requires JAX not available in the CI test environment. Updated comments to clarify reasons for skipping each notebook.
Installs Graphviz as a system dependency in the test_notebook GitHub Actions workflow to support notebooks or tests that require it.
@drbenvincent
Copy link
Collaborator Author

passing!

@NathanielF See skip_notebooks.yaml. I had to bypass testing some of yours for reasons explained in the file. Those reasons are probably fixable in a follow up PR.

@drbenvincent
Copy link
Collaborator Author

bugbot review

@cursor
Copy link

cursor bot commented Dec 24, 2025

PR Summary

Introduces CI to validate docs notebooks execute without errors.

  • Adds .github/workflows/test_notebook.yml to run notebooks in parallel splits on Python 3.12
  • New scripts/run_notebooks/ utilities: runner.py (Papermill execution with temporary notebooks), injected.py (mocks pm.sample with prior draws and minimal sample_stats), skip_notebooks.yml (notebooks excluded from CI), and a brief README.md
  • Updates docs/source/_static/interrogate_badge.svg from 96.3% to 96.0%

Written by Cursor Bugbot for commit c15a229. This will update automatically on new commits. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no bugs!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devops DevOps related documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants