Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
dd09e76
init
selmanozleyen Jun 30, 2025
40a92e2
add yaml file
selmanozleyen Jun 30, 2025
ee40db6
fix tox ini file
selmanozleyen Jun 30, 2025
460d659
update tox deps
selmanozleyen Jun 30, 2025
dd1d60a
since the notebooks work add others to test
selmanozleyen Jun 30, 2025
77c7eca
remove the tutorials folder as it has too much dependencies
selmanozleyen Jun 30, 2025
3ada541
Merge branch 'main' into feature/test-notebooks-ci
selmanozleyen Aug 20, 2025
8da3ed9
convert to python
selmanozleyen Aug 21, 2025
41bff5e
use uv and hatch for notebooks only
selmanozleyen Aug 21, 2025
fd5461f
need to add notebook dependencies now
selmanozleyen Jun 30, 2025
88b32c6
add yaml file
selmanozleyen Jun 30, 2025
250c0c9
fix tox ini file
selmanozleyen Jun 30, 2025
bb01800
update tox deps
selmanozleyen Jun 30, 2025
f46277b
since the notebooks work add others to test
selmanozleyen Jun 30, 2025
b545067
remove the tutorials folder as it has too much dependencies
selmanozleyen Jun 30, 2025
7e49bd5
convert to python
selmanozleyen Aug 21, 2025
9ce411c
update with new rebase
selmanozleyen Sep 4, 2025
4f53eb6
Merge branch 'feature/test-notebooks-ci' of https://github.com/selman…
selmanozleyen Sep 4, 2025
2ce1318
specify path
selmanozleyen Sep 4, 2025
8ad34c5
Merge branch 'main' into feature/test-notebooks-ci
selmanozleyen Sep 4, 2025
8236ab5
remove .run_notebooks
selmanozleyen Sep 4, 2025
496efb1
Merge branch 'feature/test-notebooks-ci' of https://github.com/selman…
selmanozleyen Sep 4, 2025
46f0ef4
no need to specify uv anymore
selmanozleyen Sep 4, 2025
1afa96b
remove toxini and make sure pyproject is same as main
selmanozleyen Sep 4, 2025
1ca5718
add step to setup squidpy kernel
selmanozleyen Sep 4, 2025
6ecab08
fix syntax err
selmanozleyen Sep 4, 2025
bef64d3
update the notebook commit
selmanozleyen Oct 1, 2025
3a9a004
update the nb commit for rendering
selmanozleyen Oct 1, 2025
494e38b
Merge branch 'main' into feature/test-notebooks-ci
selmanozleyen Oct 1, 2025
f474058
update the home page to add new section
selmanozleyen Oct 1, 2025
fd6f9a4
Merge branch 'feature/test-notebooks-ci' of https://github.com/selman…
selmanozleyen Oct 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/test-notebooks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Test notebooks
Copy link
Contributor

Choose a reason for hiding this comment

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

For reproducibility, should we have a check for whether the notebooks change? This would basically turn the notebooks into tests-for-stability, but could be a nice check. @timtreis or @LucaMarconato have you guys ever received feedback about stability?

Copy link
Member Author

Choose a reason for hiding this comment

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

we could have expected and output folders to compare but we'd have to update expected when we expect/want the output to change. Similar to plot unit tests. I think this is doable but would fit better as a separate issue imo


on:
push:
branches: [main]
pull_request:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.11"]

steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: Install pip dependencies
run: |
python -m pip install --upgrade pip
pip install tox
- name: Test notebooks
env:
MPLBACKEND: agg
PLATFORM: ${{ matrix.os }}
DISPLAY: :42
run: |
tox -e examples-docs
64 changes: 64 additions & 0 deletions .run_notebooks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash

# Check if the base directory is provided as an argument
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <base_notebook_directory>"
exit 1
fi

# Base directory for notebooks
base_dir=$1

# Define notebook directories or patterns
declare -a notebooks=(
"$base_dir/examples/tools/*.ipynb"
"$base_dir/examples/plotting/*.ipynb"
"$base_dir/examples/image/*.ipynb"
"$base_dir/examples/graph/*.ipynb"
# "$base_dir/tutorials/*.ipynb" don't include because it contains many external modules
)

# Initialize an array to hold valid notebook paths
declare -a valid_notebooks

# Gather all valid notebook files from the patterns
echo "Gathering notebooks..."
for pattern in "${notebooks[@]}"; do
for nb in $pattern; do
if [[ -f "$nb" ]]; then # Check if the file exists
valid_notebooks+=("$nb") # Add to the list of valid notebooks
fi
done
done

# Check if we have any notebooks to run
if [ ${#valid_notebooks[@]} -eq 0 ]; then
echo "No notebooks found to run."
exit 1
fi

# Echo the notebooks that will be run for clarity
echo "Preparing to run the following notebooks:"
for nb in "${valid_notebooks[@]}"; do
echo "$nb"
done

# Initialize a flag to track the success of all commands
all_success=true

# Execute all valid notebooks
for nb in "${valid_notebooks[@]}"; do
echo "Running $nb"
jupytext -k squidpy --execute "$nb" || {
echo "Failed to run $nb"
all_success=false
}
done

# Check if any executions failed
if [ "$all_success" = false ]; then
echo "One or more notebooks failed to execute."
exit 1
fi

echo "All notebooks executed successfully."
19 changes: 19 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,22 @@ description = Download and cache data.
skip_install = false
deps =
commands = python ./.scripts/ci/download_data.py {posargs}



[testenv:examples-docs]
allowlist_externals = bash
description = Run the notebooks.
use_develop = true
deps =
ipykernel
jupytext
nbconvert
leidenalg
watermark
napari-spatialdata
extras = docs,neural
changedir = {tox_root}{/}docs
commands =
python -m ipykernel install --user --name=squidpy
bash {tox_root}/.run_notebooks.sh {tox_root}{/}docs/notebooks
Loading