From 7fbabd55e32cd66bf18f6daab64dd4d61f1bf527 Mon Sep 17 00:00:00 2001 From: Thomas Marwitz Date: Fri, 13 Dec 2024 10:25:59 +0100 Subject: [PATCH] Check outputs of example notebooks in CI. Check via execution count in a bash script. --- .github/workflows/ci.yml | 7 +++++-- nb-output-exists.sh => nb-output-check.sh | 3 ++- pixi.toml | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) rename nb-output-exists.sh => nb-output-check.sh (92%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 32a3ee2..aafaf15 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: @@ -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 diff --git a/nb-output-exists.sh b/nb-output-check.sh similarity index 92% rename from nb-output-exists.sh rename to nb-output-check.sh index 02f70d1..b79d81b 100644 --- a/nb-output-exists.sh +++ b/nb-output-check.sh @@ -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 @@ -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 diff --git a/pixi.toml b/pixi.toml index a8e7365..a2353d9 100644 --- a/pixi.toml +++ b/pixi.toml @@ -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 = "*"