Skip to content

Commit

Permalink
Check outputs of example notebooks in CI.
Browse files Browse the repository at this point in the history
Check via execution count in a bash script.
  • Loading branch information
thomasmarwitz committed Dec 13, 2024
1 parent 2bf8bd1 commit 7fbabd5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ jobs:
- name: pre-commit
run: pixi run pre-commit-run --color=always --show-diff-on-failure

mypy-example-nbs:
name: Check notebooks mypy
check-example-nbs:
name: Check notebooks mypy and output exists
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
Expand All @@ -48,6 +48,9 @@ jobs:
run: |
pixi run nb-convert
pixi run nb-mypy
- name: Check output exists
run: |
pixi run nb-assert-output
unit-tests:
name: Unit Tests
Expand Down
3 changes: 2 additions & 1 deletion nb-output-exists.sh → nb-output-check.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

for notebook in docs/examples/*.ipynb; do
# Check the notebook for null execution counts
if ! jq -e '.cells | map(select(.cell_type == "code") | .execution_count != null) | all' "$notebook" > /dev/null; then
Expand All @@ -6,6 +8,5 @@ for notebook in docs/examples/*.ipynb; do
fi
done

# If all notebooks are valid
echo "All notebooks have valid execution counts."
exit 0
1 change: 1 addition & 0 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ coverage = "pytest tests --cov=metalearners --cov-report=xml --cov-report term-m
# Note that this task will fail on systems without bash.
nb-convert = "nb-convert.sh"
nb-mypy = "mypy docs/examples/*.py"
nb-assert-output = "sh nb-output-check.sh"

[dependencies]
pre-commit = "*"
Expand Down

0 comments on commit 7fbabd5

Please sign in to comment.