Skip to content

Add Visium breast-cancer tutorial #3

Add Visium breast-cancer tutorial

Add Visium breast-cancer tutorial #3

Workflow file for this run

name: Execute notebooks
on:
schedule:
# Weekly: Mondays 04:00 UTC — re-executes ALL notebooks against latest releases.
- cron: "0 4 * * 1"
pull_request:
branches: [main]
paths:
- "**/*.ipynb"
- "pyproject.toml"
- ".github/workflows/execute.yaml"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
execute:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
with:
# Need full history so we can diff PR HEAD against the merge base.
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Cache pooch datasets
uses: actions/cache@v4
with:
path: ~/.cache/pooch
key: pooch-${{ runner.os }}-${{ hashFiles('**/*.ipynb') }}
restore-keys: |
pooch-${{ runner.os }}-
- name: Install execution environment
run: |
pip install --upgrade pip
pip install -e ".[exec]" nbdime
- name: Determine notebooks to execute
id: pick
run: |
# On the weekly schedule and manual dispatch, run all notebooks.
# On PR, run only notebooks the PR touched, to keep CI fast as the
# gallery grows. (sklearn does the same.)
if [ "${{ github.event_name }}" = "pull_request" ]; then
base="${{ github.event.pull_request.base.sha }}"
nbs=$(git diff --name-only --diff-filter=AMR "$base"...HEAD -- '*.ipynb' | grep -E '^(tutorials|examples)/' || true)
else
nbs=$(find tutorials examples -name "*.ipynb" -not -path "*/.ipynb_checkpoints/*" 2>/dev/null || true)
fi
if [ -z "$nbs" ]; then
echo "No notebooks to execute."
else
echo "Will execute:"
echo "$nbs"
fi
{
echo 'files<<EOF'
echo "$nbs"
echo 'EOF'
} >> "$GITHUB_OUTPUT"
- name: Re-execute selected notebooks
if: steps.pick.outputs.files != ''
run: |
while IFS= read -r nb; do
[ -z "$nb" ] && continue
echo "Executing $nb"
jupyter nbconvert --to notebook --execute --inplace "$nb"
done <<< "${{ steps.pick.outputs.files }}"
- name: Strip widget metadata
if: steps.pick.outputs.files != ''
# `pooch` and other libs spawn `tqdm.notebook` widgets when running
# in a Jupyter kernel; widget UUIDs regenerate on every execution and
# would cause spurious diff failures below. Same hook runs locally
# via .pre-commit-config.yaml so committed and re-executed notebooks
# stay symmetric.
run: |
while IFS= read -r nb; do
[ -z "$nb" ] && continue
python scripts/strip_widget_metadata.py "$nb" || true
done <<< "${{ steps.pick.outputs.files }}"
- name: Diff outputs against committed
if: steps.pick.outputs.files != ''
run: |
# If outputs drift from what's committed, fail the job. Authors are
# expected to commit re-executed notebooks; CI catches drift between
# commits (e.g., upstream lib changes).
if ! git diff --quiet -- '*.ipynb'; then
echo "Notebook outputs drifted from committed state:"
nbdime diff
exit 1
fi