From dd09e765b596bb44d88c3f3b2f531fe6e68feb70 Mon Sep 17 00:00:00 2001 From: selmanozleyen Date: Mon, 30 Jun 2025 18:05:40 +0200 Subject: [PATCH 01/25] init --- .run_notebooks.sh | 61 ++++++++++++++++++ tox.ini | 159 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 220 insertions(+) create mode 100644 .run_notebooks.sh diff --git a/.run_notebooks.sh b/.run_notebooks.sh new file mode 100644 index 000000000..e87133484 --- /dev/null +++ b/.run_notebooks.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +# Check if the base directory is provided as an argument +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + 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" +) + +# 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." \ No newline at end of file diff --git a/tox.ini b/tox.ini index 41aafd937..9c9080ecb 100644 --- a/tox.ini +++ b/tox.ini @@ -140,3 +140,162 @@ description = Download and cache data. skip_install = false deps = commands = python ./.scripts/ci/download_data.py {posargs} +[pytest] +python_files = test_*.py +testpaths = tests/ +xfail_strict = true +; qt_api=pyqt5 +addopts = + --ignore=tests/plotting/test_interactive.py + +filterwarnings = + ignore::UserWarning + ignore::anndata.OldFormatWarning + ignore:.*pkg_resources:DeprecationWarning + +[coverage:run] +branch = true +parallel = true +source = squidpy +omit = + */__init__.py + */_version.py + squidpy/pl/_interactive/* + +[coverage:paths] +source = + squidpy + */site-packages/squidpy + +[coverage:report] +exclude_lines = + \#.*pragma:\s*no.?cover + + ^if __name__ == .__main__.:$ + + ^\s*raise AssertionError\b + ^\s*raise NotImplementedError\b + ^\s*return NotImplemented\b +show_missing = true +precision = 2 +skip_empty = True +sort = Miss + +[gh-actions] +python = + 3.10: py3.10 + 3.11: py3.11 + 3.12: py3.12 + +[gh-actions:env] +PLATFORM = + ubuntu-latest: linux + macos-latest: macos + +[tox] +isolated_build = True +envlist = + covclean + py3.10-linux + py3.11-linux + py3.12-linux + py3.12-macos + coverage + readme + check-docs + docs +skip_missing_interpreters = true + +[testenv] +platform = + linux: linux + macos: (osx|darwin) +deps = + pytest + pytest-xdist + pytest-cov + ; pytest-qt + pytest-mock + pytest-timeout +# see: https://github.com/numba/llvmlite/issues/669 +extras = + interactive + test +setenv = linux: PYTEST_FLAGS=--test-napari +passenv = TOXENV,CI,CODECOV_*,GITHUB_ACTIONS,PYTEST_FLAGS,DISPLAY,XAUTHORITY,MPLBACKEND,PYTEST_ADDOPTS +usedevelop = true +commands = + python -m pytest --color=yes --cov --cov-append --cov-report=xml --cov-config={toxinidir}/tox.ini --ignore docs/ {posargs:-vv} {env:PYTEST_FLAGS:} + +[testenv:covclean] +description = Clean coverage files. +deps = coverage +skip_install = True +commands = coverage erase + +[testenv:coverage] +description = Report the coverage difference. +deps = + coverage + diff_cover +skip_install = true +depends = py3.10-linux, py3.11-linux, py3.12-linux, py3.12-macos +parallel_show_output = True +commands = + coverage report --omit="tox/*" + coverage xml --omit="tox/*" -o {toxinidir}/coverage.xml + diff-cover --compare-branch origin/main {toxinidir}/coverage.xml + +[testenv:clean-docs] +description = Clean the documentation artifacts. +deps = +skip_install = true +changedir = {toxinidir}/docs +allowlist_externals = make +commands = make clean + +[testenv:check-docs] +description = Lint the documentation. +deps = +extras = docs +ignore_errors = true +allowlist_externals = make +pass_env = PYENCHANT_LIBRARY_PATH +set_env = SPHINXOPTS = -W -q --keep-going +changedir = {tox_root}{/}docs +commands = + make linkcheck {posargs} + +[testenv:docs] +description = Build the documentation. +deps = +extras = docs +allowlist_externals = make +changedir = {tox_root}{/}docs +commands = + make html {posargs} +commands_post = + python -c 'import pathlib; print("Documentation is under:", pathlib.Path("{tox_root}") / "docs" / "_build" / "html" / "index.html")' + +[testenv:download-data] +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 +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 \ No newline at end of file From 40a92e2a09d645f614de011862b53d3c443eef4c Mon Sep 17 00:00:00 2001 From: selmanozleyen Date: Mon, 30 Jun 2025 18:08:40 +0200 Subject: [PATCH 02/25] add yaml file --- .github/workflows/test-notebooks.yml | 41 ++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/test-notebooks.yml diff --git a/.github/workflows/test-notebooks.yml b/.github/workflows/test-notebooks.yml new file mode 100644 index 000000000..55595fe4a --- /dev/null +++ b/.github/workflows/test-notebooks.yml @@ -0,0 +1,41 @@ +name: Test notebooks + +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 \ No newline at end of file From ee40db681028c521d56074cfe9214c0aa67ebc56 Mon Sep 17 00:00:00 2001 From: selmanozleyen Date: Mon, 30 Jun 2025 18:11:05 +0200 Subject: [PATCH 03/25] fix tox ini file --- tox.ini | 142 -------------------------------------------------------- 1 file changed, 142 deletions(-) diff --git a/tox.ini b/tox.ini index 9c9080ecb..669d6ff95 100644 --- a/tox.ini +++ b/tox.ini @@ -140,148 +140,6 @@ description = Download and cache data. skip_install = false deps = commands = python ./.scripts/ci/download_data.py {posargs} -[pytest] -python_files = test_*.py -testpaths = tests/ -xfail_strict = true -; qt_api=pyqt5 -addopts = - --ignore=tests/plotting/test_interactive.py - -filterwarnings = - ignore::UserWarning - ignore::anndata.OldFormatWarning - ignore:.*pkg_resources:DeprecationWarning - -[coverage:run] -branch = true -parallel = true -source = squidpy -omit = - */__init__.py - */_version.py - squidpy/pl/_interactive/* - -[coverage:paths] -source = - squidpy - */site-packages/squidpy - -[coverage:report] -exclude_lines = - \#.*pragma:\s*no.?cover - - ^if __name__ == .__main__.:$ - - ^\s*raise AssertionError\b - ^\s*raise NotImplementedError\b - ^\s*return NotImplemented\b -show_missing = true -precision = 2 -skip_empty = True -sort = Miss - -[gh-actions] -python = - 3.10: py3.10 - 3.11: py3.11 - 3.12: py3.12 - -[gh-actions:env] -PLATFORM = - ubuntu-latest: linux - macos-latest: macos - -[tox] -isolated_build = True -envlist = - covclean - py3.10-linux - py3.11-linux - py3.12-linux - py3.12-macos - coverage - readme - check-docs - docs -skip_missing_interpreters = true - -[testenv] -platform = - linux: linux - macos: (osx|darwin) -deps = - pytest - pytest-xdist - pytest-cov - ; pytest-qt - pytest-mock - pytest-timeout -# see: https://github.com/numba/llvmlite/issues/669 -extras = - interactive - test -setenv = linux: PYTEST_FLAGS=--test-napari -passenv = TOXENV,CI,CODECOV_*,GITHUB_ACTIONS,PYTEST_FLAGS,DISPLAY,XAUTHORITY,MPLBACKEND,PYTEST_ADDOPTS -usedevelop = true -commands = - python -m pytest --color=yes --cov --cov-append --cov-report=xml --cov-config={toxinidir}/tox.ini --ignore docs/ {posargs:-vv} {env:PYTEST_FLAGS:} - -[testenv:covclean] -description = Clean coverage files. -deps = coverage -skip_install = True -commands = coverage erase - -[testenv:coverage] -description = Report the coverage difference. -deps = - coverage - diff_cover -skip_install = true -depends = py3.10-linux, py3.11-linux, py3.12-linux, py3.12-macos -parallel_show_output = True -commands = - coverage report --omit="tox/*" - coverage xml --omit="tox/*" -o {toxinidir}/coverage.xml - diff-cover --compare-branch origin/main {toxinidir}/coverage.xml - -[testenv:clean-docs] -description = Clean the documentation artifacts. -deps = -skip_install = true -changedir = {toxinidir}/docs -allowlist_externals = make -commands = make clean - -[testenv:check-docs] -description = Lint the documentation. -deps = -extras = docs -ignore_errors = true -allowlist_externals = make -pass_env = PYENCHANT_LIBRARY_PATH -set_env = SPHINXOPTS = -W -q --keep-going -changedir = {tox_root}{/}docs -commands = - make linkcheck {posargs} - -[testenv:docs] -description = Build the documentation. -deps = -extras = docs -allowlist_externals = make -changedir = {tox_root}{/}docs -commands = - make html {posargs} -commands_post = - python -c 'import pathlib; print("Documentation is under:", pathlib.Path("{tox_root}") / "docs" / "_build" / "html" / "index.html")' - -[testenv:download-data] -description = Download and cache data. -skip_install = false -deps = -commands = python ./.scripts/ci/download_data.py {posargs} From 460d659346f99dbaa1b9216000974bbdfe92a7f6 Mon Sep 17 00:00:00 2001 From: selmanozleyen Date: Mon, 30 Jun 2025 19:41:27 +0200 Subject: [PATCH 04/25] update tox deps --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 669d6ff95..09363eb61 100644 --- a/tox.ini +++ b/tox.ini @@ -152,6 +152,7 @@ deps = jupytext nbconvert leidenalg + watermark extras = docs,neural changedir = {tox_root}{/}docs commands = From dd1d60a596a118991e7a62363fed7a3f4ca380a6 Mon Sep 17 00:00:00 2001 From: selmanozleyen Date: Mon, 30 Jun 2025 19:50:55 +0200 Subject: [PATCH 05/25] since the notebooks work add others to test --- .run_notebooks.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.run_notebooks.sh b/.run_notebooks.sh index e87133484..fb3694211 100644 --- a/.run_notebooks.sh +++ b/.run_notebooks.sh @@ -13,6 +13,9 @@ base_dir=$1 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" ) # Initialize an array to hold valid notebook paths From 77c7ecad92341114b78694aa807fa24edc699e8f Mon Sep 17 00:00:00 2001 From: selmanozleyen Date: Tue, 1 Jul 2025 00:50:19 +0200 Subject: [PATCH 06/25] remove the tutorials folder as it has too much dependencies --- .run_notebooks.sh | 2 +- tox.ini | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.run_notebooks.sh b/.run_notebooks.sh index fb3694211..0ea18185e 100644 --- a/.run_notebooks.sh +++ b/.run_notebooks.sh @@ -15,7 +15,7 @@ declare -a notebooks=( "$base_dir/examples/plotting/*.ipynb" "$base_dir/examples/image/*.ipynb" "$base_dir/examples/graph/*.ipynb" - "$base_dir/tutorials/*.ipynb" + # "$base_dir/tutorials/*.ipynb" don't include because it contains many external modules ) # Initialize an array to hold valid notebook paths diff --git a/tox.ini b/tox.ini index 09363eb61..0504945f0 100644 --- a/tox.ini +++ b/tox.ini @@ -153,6 +153,7 @@ deps = nbconvert leidenalg watermark + napari-spatialdata extras = docs,neural changedir = {tox_root}{/}docs commands = From 8da3ed9543f8f9449c9cde118d1b02f7ff6e6756 Mon Sep 17 00:00:00 2001 From: "selman.ozleyen" Date: Thu, 21 Aug 2025 13:17:09 +0200 Subject: [PATCH 07/25] convert to python --- .run_notebooks.py | 95 +++++++++++++++++++++++++++++++++++++++++++++++ .run_notebooks.sh | 64 ------------------------------- tox.ini | 2 +- 3 files changed, 96 insertions(+), 65 deletions(-) create mode 100644 .run_notebooks.py delete mode 100644 .run_notebooks.sh diff --git a/.run_notebooks.py b/.run_notebooks.py new file mode 100644 index 000000000..3e32b15d5 --- /dev/null +++ b/.run_notebooks.py @@ -0,0 +1,95 @@ +#!/usr/bin/env python3 + +import argparse +import glob +import os +import subprocess +import sys + +EPILOG = """ +Examples: + python .run_notebooks.py docs/notebooks + python .run_notebooks.py /path/to/notebooks --kernel my-kernel +""" + + +def main(): + # Set up argument parser + parser = argparse.ArgumentParser( + description="Run Jupyter notebooks in specified directories using jupytext", + formatter_class=argparse.RawDescriptionHelpFormatter, + epilog=EPILOG, + ) + + parser.add_argument("base_directory", help="Base directory containing notebook subdirectories") + + parser.add_argument( + "-k", "--kernel", default="squidpy", help="Jupyter kernel to use for execution (default: squidpy)" + ) + + parser.add_argument( + "--dry-run", action="store_true", help="Show which notebooks would be run without executing them" + ) + + args = parser.parse_args() + + # Base directory for notebooks + base_dir = args.base_directory + + # Define notebook directories or patterns + notebook_patterns = [ + f"{base_dir}/examples/tools/*.ipynb", + f"{base_dir}/examples/plotting/*.ipynb", + f"{base_dir}/examples/image/*.ipynb", + f"{base_dir}/examples/graph/*.ipynb", + # f"{base_dir}/tutorials/*.ipynb" # don't include because it contains many external modules + ] + + # Initialize a list to hold valid notebook paths + valid_notebooks = [] + + # Gather all valid notebook files from the patterns + print("Gathering notebooks...") + for pattern in notebook_patterns: + for nb_path in glob.glob(pattern): + if os.path.isfile(nb_path): # Check if the file exists + valid_notebooks.append(nb_path) # Add to the list of valid notebooks + + # Check if we have any notebooks to run + if len(valid_notebooks) == 0: + print("No notebooks found to run.") + sys.exit(1) + + # Echo the notebooks that will be run for clarity + print("Preparing to run the following notebooks:") + for nb in valid_notebooks: + print(f" {nb}") + + # If dry run, exit here + if args.dry_run: + print(f"\nDry run complete. Would execute {len(valid_notebooks)} notebooks with kernel '{args.kernel}'.") + return + + # Initialize a flag to track the success of all commands + all_success = True + + # Execute all valid notebooks + print(f"\nExecuting notebooks with kernel '{args.kernel}'...") + for nb in valid_notebooks: + print(f"Running {nb}") + try: + subprocess.run(["jupytext", "-k", args.kernel, "--execute", nb], check=True) + except subprocess.CalledProcessError: + print(f"Failed to run {nb}") + all_success = False + + # Check if any executions failed + if not all_success: + print("One or more notebooks failed to execute.") + sys.exit(1) + + print("All notebooks executed successfully.") + + +if __name__ == "__main__": + main() diff --git a/.run_notebooks.sh b/.run_notebooks.sh deleted file mode 100644 index 0ea18185e..000000000 --- a/.run_notebooks.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash - -# Check if the base directory is provided as an argument -if [ "$#" -ne 1 ]; then - echo "Usage: $0 " - 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." \ No newline at end of file diff --git a/tox.ini b/tox.ini index 0504945f0..ed017ad08 100644 --- a/tox.ini +++ b/tox.ini @@ -158,4 +158,4 @@ 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 \ No newline at end of file + python {tox_root}/.run_notebooks.py {tox_root}{/}docs/notebooks \ No newline at end of file From 41bff5eedc323505d84714047f81b9883a36cfbf Mon Sep 17 00:00:00 2001 From: "selman.ozleyen" Date: Thu, 21 Aug 2025 13:55:38 +0200 Subject: [PATCH 08/25] use uv and hatch for notebooks only --- .github/workflows/test-notebooks.yml | 14 ++++++++------ .run_notebooks.py | 3 ++- pyproject.toml | 19 +++++++++++++++++++ tox.ini | 18 ------------------ 4 files changed, 29 insertions(+), 25 deletions(-) diff --git a/.github/workflows/test-notebooks.yml b/.github/workflows/test-notebooks.yml index 55595fe4a..eb789f38d 100644 --- a/.github/workflows/test-notebooks.yml +++ b/.github/workflows/test-notebooks.yml @@ -28,14 +28,16 @@ jobs: with: python-version: ${{ matrix.python }} - - name: Install pip dependencies - run: | - python -m pip install --upgrade pip - pip install tox + - uses: astral-sh/setup-uv@v5 + with: + enable-cache: true + python-version: ${{ matrix.python }} + cache-dependency-glob: pyproject.toml + - name: Create notebooks environment + run: uvx hatch -v env create notebooks - name: Test notebooks env: MPLBACKEND: agg PLATFORM: ${{ matrix.os }} DISPLAY: :42 - run: | - tox -e examples-docs \ No newline at end of file + run: uvx hatch run notebooks:run diff --git a/.run_notebooks.py b/.run_notebooks.py index 3e32b15d5..51998a548 100644 --- a/.run_notebooks.py +++ b/.run_notebooks.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +from __future__ import annotations import argparse import glob @@ -13,7 +14,7 @@ """ -def main(): +def main() -> None: # Set up argument parser parser = argparse.ArgumentParser( description="Run Jupyter notebooks in specified directories using jupytext", diff --git a/pyproject.toml b/pyproject.toml index f7de064f7..d6ef76805 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -239,3 +239,22 @@ ban-relative-imports = "all" filterwarnings = [ "error::numba.NumbaPerformanceWarning" ] + +[tool.hatch.envs.notebooks] +installer = "uv" +extra-dependencies = [ + "ipykernel", + "jupytext", + "nbconvert", + "leidenalg", + "watermark", + "napari-spatialdata", +] +extras = ["docs"] + +[tool.hatch.envs.notebooks.scripts] +install-kernel = "python -m ipykernel install --user --name=squidpy" +run = [ + "install-kernel", + "python {root}/.run_notebooks.py {root}/docs/notebooks" +] \ No newline at end of file diff --git a/tox.ini b/tox.ini index ed017ad08..1f2e63e06 100644 --- a/tox.ini +++ b/tox.ini @@ -141,21 +141,3 @@ 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 - python {tox_root}/.run_notebooks.py {tox_root}{/}docs/notebooks \ No newline at end of file From fd5461f2ff65724caea3f49a5fdcbf3af4cf7c61 Mon Sep 17 00:00:00 2001 From: selmanozleyen Date: Mon, 30 Jun 2025 18:05:40 +0200 Subject: [PATCH 09/25] need to add notebook dependencies now --- .run_notebooks.sh | 61 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .run_notebooks.sh diff --git a/.run_notebooks.sh b/.run_notebooks.sh new file mode 100644 index 000000000..e87133484 --- /dev/null +++ b/.run_notebooks.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +# Check if the base directory is provided as an argument +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + 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" +) + +# 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." \ No newline at end of file From 88b32c66a9fe660358a786f408a29b973cc40e86 Mon Sep 17 00:00:00 2001 From: selmanozleyen Date: Mon, 30 Jun 2025 18:08:40 +0200 Subject: [PATCH 10/25] add yaml file --- .github/workflows/test-notebooks.yml | 41 ++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/test-notebooks.yml diff --git a/.github/workflows/test-notebooks.yml b/.github/workflows/test-notebooks.yml new file mode 100644 index 000000000..55595fe4a --- /dev/null +++ b/.github/workflows/test-notebooks.yml @@ -0,0 +1,41 @@ +name: Test notebooks + +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 \ No newline at end of file From 250c0c96ff9955f6048592af4ac33fdfb83b663f Mon Sep 17 00:00:00 2001 From: selmanozleyen Date: Mon, 30 Jun 2025 18:11:05 +0200 Subject: [PATCH 11/25] fix tox ini file --- tox.ini | 159 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 tox.ini diff --git a/tox.ini b/tox.ini new file mode 100644 index 000000000..669d6ff95 --- /dev/null +++ b/tox.ini @@ -0,0 +1,159 @@ +[pytest] +python_files = test_*.py +testpaths = tests/ +xfail_strict = true +; qt_api=pyqt5 +addopts = + --ignore=tests/plotting/test_interactive.py + +filterwarnings = + ignore::UserWarning + ignore::anndata.OldFormatWarning + ignore:.*pkg_resources:DeprecationWarning + +[coverage:run] +branch = true +parallel = true +source = squidpy +omit = + */__init__.py + */_version.py + squidpy/pl/_interactive/* + +[coverage:paths] +source = + squidpy + */site-packages/squidpy + +[coverage:report] +exclude_lines = + \#.*pragma:\s*no.?cover + + ^if __name__ == .__main__.:$ + + ^\s*raise AssertionError\b + ^\s*raise NotImplementedError\b + ^\s*return NotImplemented\b +show_missing = true +precision = 2 +skip_empty = True +sort = Miss + +[gh-actions] +python = + 3.10: py3.10 + 3.11: py3.11 + 3.12: py3.12 + +[gh-actions:env] +PLATFORM = + ubuntu-latest: linux + macos-latest: macos + +[tox] +isolated_build = True +envlist = + covclean + py3.10-linux + py3.11-linux + py3.12-linux + py3.12-macos + coverage + readme + check-docs + docs +skip_missing_interpreters = true + +[testenv] +platform = + linux: linux + macos: (osx|darwin) +deps = + pytest + pytest-xdist + pytest-cov + ; pytest-qt + pytest-mock + pytest-timeout +# see: https://github.com/numba/llvmlite/issues/669 +extras = + interactive + test +setenv = linux: PYTEST_FLAGS=--test-napari +passenv = TOXENV,CI,CODECOV_*,GITHUB_ACTIONS,PYTEST_FLAGS,DISPLAY,XAUTHORITY,MPLBACKEND,PYTEST_ADDOPTS +usedevelop = true +commands = + python -m pytest --color=yes --cov --cov-append --cov-report=xml --cov-config={toxinidir}/tox.ini --ignore docs/ {posargs:-vv} {env:PYTEST_FLAGS:} + +[testenv:covclean] +description = Clean coverage files. +deps = coverage +skip_install = True +commands = coverage erase + +[testenv:coverage] +description = Report the coverage difference. +deps = + coverage + diff_cover +skip_install = true +depends = py3.10-linux, py3.11-linux, py3.12-linux, py3.12-macos +parallel_show_output = True +commands = + coverage report --omit="tox/*" + coverage xml --omit="tox/*" -o {toxinidir}/coverage.xml + diff-cover --compare-branch origin/main {toxinidir}/coverage.xml + +[testenv:clean-docs] +description = Clean the documentation artifacts. +deps = +skip_install = true +changedir = {toxinidir}/docs +allowlist_externals = make +commands = make clean + +[testenv:check-docs] +description = Lint the documentation. +deps = +extras = docs +ignore_errors = true +allowlist_externals = make +pass_env = PYENCHANT_LIBRARY_PATH +set_env = SPHINXOPTS = -W -q --keep-going +changedir = {tox_root}{/}docs +commands = + make linkcheck {posargs} + +[testenv:docs] +description = Build the documentation. +deps = +extras = docs +allowlist_externals = make +changedir = {tox_root}{/}docs +commands = + make html {posargs} +commands_post = + python -c 'import pathlib; print("Documentation is under:", pathlib.Path("{tox_root}") / "docs" / "_build" / "html" / "index.html")' + +[testenv:download-data] +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 +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 \ No newline at end of file From bb01800b078d60e291cd680f54be08f1b6a83d7d Mon Sep 17 00:00:00 2001 From: selmanozleyen Date: Mon, 30 Jun 2025 19:41:27 +0200 Subject: [PATCH 12/25] update tox deps --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 669d6ff95..09363eb61 100644 --- a/tox.ini +++ b/tox.ini @@ -152,6 +152,7 @@ deps = jupytext nbconvert leidenalg + watermark extras = docs,neural changedir = {tox_root}{/}docs commands = From f46277bb5e06803186e03ec32f04c5e02ec1878a Mon Sep 17 00:00:00 2001 From: selmanozleyen Date: Mon, 30 Jun 2025 19:50:55 +0200 Subject: [PATCH 13/25] since the notebooks work add others to test --- .run_notebooks.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.run_notebooks.sh b/.run_notebooks.sh index e87133484..fb3694211 100644 --- a/.run_notebooks.sh +++ b/.run_notebooks.sh @@ -13,6 +13,9 @@ base_dir=$1 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" ) # Initialize an array to hold valid notebook paths From b5450679b1542e8ba4efac9ebd013bba1d846cc9 Mon Sep 17 00:00:00 2001 From: selmanozleyen Date: Tue, 1 Jul 2025 00:50:19 +0200 Subject: [PATCH 14/25] remove the tutorials folder as it has too much dependencies --- .run_notebooks.sh | 2 +- tox.ini | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.run_notebooks.sh b/.run_notebooks.sh index fb3694211..0ea18185e 100644 --- a/.run_notebooks.sh +++ b/.run_notebooks.sh @@ -15,7 +15,7 @@ declare -a notebooks=( "$base_dir/examples/plotting/*.ipynb" "$base_dir/examples/image/*.ipynb" "$base_dir/examples/graph/*.ipynb" - "$base_dir/tutorials/*.ipynb" + # "$base_dir/tutorials/*.ipynb" don't include because it contains many external modules ) # Initialize an array to hold valid notebook paths diff --git a/tox.ini b/tox.ini index 09363eb61..0504945f0 100644 --- a/tox.ini +++ b/tox.ini @@ -153,6 +153,7 @@ deps = nbconvert leidenalg watermark + napari-spatialdata extras = docs,neural changedir = {tox_root}{/}docs commands = From 7e49bd590f9b1087b69814a997c9eac0840b8c2d Mon Sep 17 00:00:00 2001 From: "selman.ozleyen" Date: Thu, 21 Aug 2025 13:17:09 +0200 Subject: [PATCH 15/25] convert to python --- .run_notebooks.py | 95 +++++++++++++++++++++++++++++++++++++++++++++++ .run_notebooks.sh | 64 ------------------------------- tox.ini | 2 +- 3 files changed, 96 insertions(+), 65 deletions(-) create mode 100644 .run_notebooks.py delete mode 100644 .run_notebooks.sh diff --git a/.run_notebooks.py b/.run_notebooks.py new file mode 100644 index 000000000..3e32b15d5 --- /dev/null +++ b/.run_notebooks.py @@ -0,0 +1,95 @@ +#!/usr/bin/env python3 + +import argparse +import glob +import os +import subprocess +import sys + +EPILOG = """ +Examples: + python .run_notebooks.py docs/notebooks + python .run_notebooks.py /path/to/notebooks --kernel my-kernel +""" + + +def main(): + # Set up argument parser + parser = argparse.ArgumentParser( + description="Run Jupyter notebooks in specified directories using jupytext", + formatter_class=argparse.RawDescriptionHelpFormatter, + epilog=EPILOG, + ) + + parser.add_argument("base_directory", help="Base directory containing notebook subdirectories") + + parser.add_argument( + "-k", "--kernel", default="squidpy", help="Jupyter kernel to use for execution (default: squidpy)" + ) + + parser.add_argument( + "--dry-run", action="store_true", help="Show which notebooks would be run without executing them" + ) + + args = parser.parse_args() + + # Base directory for notebooks + base_dir = args.base_directory + + # Define notebook directories or patterns + notebook_patterns = [ + f"{base_dir}/examples/tools/*.ipynb", + f"{base_dir}/examples/plotting/*.ipynb", + f"{base_dir}/examples/image/*.ipynb", + f"{base_dir}/examples/graph/*.ipynb", + # f"{base_dir}/tutorials/*.ipynb" # don't include because it contains many external modules + ] + + # Initialize a list to hold valid notebook paths + valid_notebooks = [] + + # Gather all valid notebook files from the patterns + print("Gathering notebooks...") + for pattern in notebook_patterns: + for nb_path in glob.glob(pattern): + if os.path.isfile(nb_path): # Check if the file exists + valid_notebooks.append(nb_path) # Add to the list of valid notebooks + + # Check if we have any notebooks to run + if len(valid_notebooks) == 0: + print("No notebooks found to run.") + sys.exit(1) + + # Echo the notebooks that will be run for clarity + print("Preparing to run the following notebooks:") + for nb in valid_notebooks: + print(f" {nb}") + + # If dry run, exit here + if args.dry_run: + print(f"\nDry run complete. Would execute {len(valid_notebooks)} notebooks with kernel '{args.kernel}'.") + return + + # Initialize a flag to track the success of all commands + all_success = True + + # Execute all valid notebooks + print(f"\nExecuting notebooks with kernel '{args.kernel}'...") + for nb in valid_notebooks: + print(f"Running {nb}") + try: + subprocess.run(["jupytext", "-k", args.kernel, "--execute", nb], check=True) + except subprocess.CalledProcessError: + print(f"Failed to run {nb}") + all_success = False + + # Check if any executions failed + if not all_success: + print("One or more notebooks failed to execute.") + sys.exit(1) + + print("All notebooks executed successfully.") + + +if __name__ == "__main__": + main() diff --git a/.run_notebooks.sh b/.run_notebooks.sh deleted file mode 100644 index 0ea18185e..000000000 --- a/.run_notebooks.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash - -# Check if the base directory is provided as an argument -if [ "$#" -ne 1 ]; then - echo "Usage: $0 " - 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." \ No newline at end of file diff --git a/tox.ini b/tox.ini index 0504945f0..ed017ad08 100644 --- a/tox.ini +++ b/tox.ini @@ -158,4 +158,4 @@ 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 \ No newline at end of file + python {tox_root}/.run_notebooks.py {tox_root}{/}docs/notebooks \ No newline at end of file From 9ce411ccac83838789ded041055fec9726f9b386 Mon Sep 17 00:00:00 2001 From: "selman.ozleyen" Date: Thu, 4 Sep 2025 15:50:50 +0200 Subject: [PATCH 16/25] update with new rebase --- .github/workflows/test-notebooks.yml | 14 ++++++++------ .../ci/run_notebooks.py | 7 ++++--- hatch.toml | 19 ++++++++++++++++++- pyproject.toml | 2 +- tox.ini | 18 ------------------ 5 files changed, 31 insertions(+), 29 deletions(-) rename .run_notebooks.py => .scripts/ci/run_notebooks.py (94%) diff --git a/.github/workflows/test-notebooks.yml b/.github/workflows/test-notebooks.yml index 55595fe4a..eb789f38d 100644 --- a/.github/workflows/test-notebooks.yml +++ b/.github/workflows/test-notebooks.yml @@ -28,14 +28,16 @@ jobs: with: python-version: ${{ matrix.python }} - - name: Install pip dependencies - run: | - python -m pip install --upgrade pip - pip install tox + - uses: astral-sh/setup-uv@v5 + with: + enable-cache: true + python-version: ${{ matrix.python }} + cache-dependency-glob: pyproject.toml + - name: Create notebooks environment + run: uvx hatch -v env create notebooks - name: Test notebooks env: MPLBACKEND: agg PLATFORM: ${{ matrix.os }} DISPLAY: :42 - run: | - tox -e examples-docs \ No newline at end of file + run: uvx hatch run notebooks:run diff --git a/.run_notebooks.py b/.scripts/ci/run_notebooks.py similarity index 94% rename from .run_notebooks.py rename to .scripts/ci/run_notebooks.py index 3e32b15d5..8ab221a32 100644 --- a/.run_notebooks.py +++ b/.scripts/ci/run_notebooks.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +from __future__ import annotations import argparse import glob @@ -8,12 +9,12 @@ EPILOG = """ Examples: - python .run_notebooks.py docs/notebooks - python .run_notebooks.py /path/to/notebooks --kernel my-kernel + python run_notebooks.py docs/notebooks + python run_notebooks.py /path/to/notebooks --kernel my-kernel """ -def main(): +def main() -> None: # Set up argument parser parser = argparse.ArgumentParser( description="Run Jupyter notebooks in specified directories using jupytext", diff --git a/hatch.toml b/hatch.toml index e9a942f9a..1d2633e5a 100644 --- a/hatch.toml +++ b/hatch.toml @@ -56,4 +56,21 @@ python = [ "3.13" ] # set the environment variable `UV_PRERELEASE` to "allow". matrix.deps.env-vars = [ { key = "UV_PRERELEASE", value = "allow", if = [ "pre" ] }, -] \ No newline at end of file +] + +[envs.notebooks] +installer = "uv" +extra-dependencies = [ + "ipykernel", + "jupytext", + "nbconvert", + "leidenalg", + "watermark", + "napari-spatialdata", +] +extras = ["docs"] + +[envs.notebooks.scripts] + +setup-squidpy-kernel = "python -m ipykernel install --user --name=squidpy" +run-notebooks = "python ./.scripts/ci/run_notebooks.py {args}" \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index eeb9ffbf1..5d4333bee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -281,4 +281,4 @@ exclude_lines = [ show_missing = true precision = 2 skip_empty = true -sort = "Miss" \ No newline at end of file +sort = "Miss" diff --git a/tox.ini b/tox.ini index ed017ad08..1f2e63e06 100644 --- a/tox.ini +++ b/tox.ini @@ -141,21 +141,3 @@ 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 - python {tox_root}/.run_notebooks.py {tox_root}{/}docs/notebooks \ No newline at end of file From 2ce1318f9fe2f04f9d62ea1066640da6f2d610a9 Mon Sep 17 00:00:00 2001 From: "selman.ozleyen" Date: Thu, 4 Sep 2025 15:55:37 +0200 Subject: [PATCH 17/25] specify path --- .github/workflows/test-notebooks.yml | 2 +- hatch.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-notebooks.yml b/.github/workflows/test-notebooks.yml index eb789f38d..160394180 100644 --- a/.github/workflows/test-notebooks.yml +++ b/.github/workflows/test-notebooks.yml @@ -40,4 +40,4 @@ jobs: MPLBACKEND: agg PLATFORM: ${{ matrix.os }} DISPLAY: :42 - run: uvx hatch run notebooks:run + run: uvx hatch run notebooks:run-notebooks diff --git a/hatch.toml b/hatch.toml index 1d2633e5a..706d0f764 100644 --- a/hatch.toml +++ b/hatch.toml @@ -73,4 +73,4 @@ extras = ["docs"] [envs.notebooks.scripts] setup-squidpy-kernel = "python -m ipykernel install --user --name=squidpy" -run-notebooks = "python ./.scripts/ci/run_notebooks.py {args}" \ No newline at end of file +run-notebooks = "python ./.scripts/ci/run_notebooks.py docs/notebooks" \ No newline at end of file From 8236ab51dd780dd7e22b2c7c29fd0b138b74bd09 Mon Sep 17 00:00:00 2001 From: "selman.ozleyen" Date: Thu, 4 Sep 2025 16:02:13 +0200 Subject: [PATCH 18/25] remove .run_notebooks --- .run_notebooks.py | 96 ----------------------------------------------- 1 file changed, 96 deletions(-) delete mode 100644 .run_notebooks.py diff --git a/.run_notebooks.py b/.run_notebooks.py deleted file mode 100644 index 51998a548..000000000 --- a/.run_notebooks.py +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env python3 -from __future__ import annotations - -import argparse -import glob -import os -import subprocess -import sys - -EPILOG = """ -Examples: - python .run_notebooks.py docs/notebooks - python .run_notebooks.py /path/to/notebooks --kernel my-kernel -""" - - -def main() -> None: - # Set up argument parser - parser = argparse.ArgumentParser( - description="Run Jupyter notebooks in specified directories using jupytext", - formatter_class=argparse.RawDescriptionHelpFormatter, - epilog=EPILOG, - ) - - parser.add_argument("base_directory", help="Base directory containing notebook subdirectories") - - parser.add_argument( - "-k", "--kernel", default="squidpy", help="Jupyter kernel to use for execution (default: squidpy)" - ) - - parser.add_argument( - "--dry-run", action="store_true", help="Show which notebooks would be run without executing them" - ) - - args = parser.parse_args() - - # Base directory for notebooks - base_dir = args.base_directory - - # Define notebook directories or patterns - notebook_patterns = [ - f"{base_dir}/examples/tools/*.ipynb", - f"{base_dir}/examples/plotting/*.ipynb", - f"{base_dir}/examples/image/*.ipynb", - f"{base_dir}/examples/graph/*.ipynb", - # f"{base_dir}/tutorials/*.ipynb" # don't include because it contains many external modules - ] - - # Initialize a list to hold valid notebook paths - valid_notebooks = [] - - # Gather all valid notebook files from the patterns - print("Gathering notebooks...") - for pattern in notebook_patterns: - for nb_path in glob.glob(pattern): - if os.path.isfile(nb_path): # Check if the file exists - valid_notebooks.append(nb_path) # Add to the list of valid notebooks - - # Check if we have any notebooks to run - if len(valid_notebooks) == 0: - print("No notebooks found to run.") - sys.exit(1) - - # Echo the notebooks that will be run for clarity - print("Preparing to run the following notebooks:") - for nb in valid_notebooks: - print(f" {nb}") - - # If dry run, exit here - if args.dry_run: - print(f"\nDry run complete. Would execute {len(valid_notebooks)} notebooks with kernel '{args.kernel}'.") - return - - # Initialize a flag to track the success of all commands - all_success = True - - # Execute all valid notebooks - print(f"\nExecuting notebooks with kernel '{args.kernel}'...") - for nb in valid_notebooks: - print(f"Running {nb}") - try: - subprocess.run(["jupytext", "-k", args.kernel, "--execute", nb], check=True) - except subprocess.CalledProcessError: - print(f"Failed to run {nb}") - all_success = False - - # Check if any executions failed - if not all_success: - print("One or more notebooks failed to execute.") - sys.exit(1) - - print("All notebooks executed successfully.") - - -if __name__ == "__main__": - main() From 46f0ef4deb5a4f20698623b2e0a079d037c84249 Mon Sep 17 00:00:00 2001 From: "selman.ozleyen" Date: Thu, 4 Sep 2025 16:04:28 +0200 Subject: [PATCH 19/25] no need to specify uv anymore --- hatch.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/hatch.toml b/hatch.toml index 706d0f764..388594bf6 100644 --- a/hatch.toml +++ b/hatch.toml @@ -59,7 +59,6 @@ matrix.deps.env-vars = [ ] [envs.notebooks] -installer = "uv" extra-dependencies = [ "ipykernel", "jupytext", From 1afa96b3130df43bf04b996467b140f8477ba750 Mon Sep 17 00:00:00 2001 From: "selman.ozleyen" Date: Thu, 4 Sep 2025 16:06:13 +0200 Subject: [PATCH 20/25] remove toxini and make sure pyproject is same as main --- pyproject.toml | 1 - tox.ini | 143 ------------------------------------------------- 2 files changed, 144 deletions(-) delete mode 100644 tox.ini diff --git a/pyproject.toml b/pyproject.toml index be5241356..d65304b4f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -281,4 +281,3 @@ exclude_lines = [ show_missing = true precision = 2 skip_empty = true -sort = "Miss" diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 1f2e63e06..000000000 --- a/tox.ini +++ /dev/null @@ -1,143 +0,0 @@ -[pytest] -python_files = test_*.py -testpaths = tests/ -xfail_strict = true -; qt_api=pyqt5 -addopts = - --ignore=tests/plotting/test_interactive.py - -filterwarnings = - ignore::UserWarning - ignore::anndata.OldFormatWarning - ignore:.*pkg_resources:DeprecationWarning - -[coverage:run] -branch = true -parallel = true -source = squidpy -omit = - */__init__.py - */_version.py - squidpy/pl/_interactive/* - -[coverage:paths] -source = - squidpy - */site-packages/squidpy - -[coverage:report] -exclude_lines = - \#.*pragma:\s*no.?cover - - ^if __name__ == .__main__.:$ - - ^\s*raise AssertionError\b - ^\s*raise NotImplementedError\b - ^\s*return NotImplemented\b -show_missing = true -precision = 2 -skip_empty = True -sort = Miss - -[gh-actions] -python = - 3.10: py3.10 - 3.11: py3.11 - 3.12: py3.12 - -[gh-actions:env] -PLATFORM = - ubuntu-latest: linux - macos-latest: macos - -[tox] -isolated_build = True -envlist = - covclean - py3.10-linux - py3.11-linux - py3.12-linux - py3.12-macos - coverage - readme - check-docs - docs -skip_missing_interpreters = true - -[testenv] -platform = - linux: linux - macos: (osx|darwin) -deps = - pytest - pytest-xdist - pytest-cov - ; pytest-qt - pytest-mock - pytest-timeout -# see: https://github.com/numba/llvmlite/issues/669 -extras = - interactive - test -setenv = linux: PYTEST_FLAGS=--test-napari -passenv = TOXENV,CI,CODECOV_*,GITHUB_ACTIONS,PYTEST_FLAGS,DISPLAY,XAUTHORITY,MPLBACKEND,PYTEST_ADDOPTS -usedevelop = true -commands = - python -m pytest --color=yes --cov --cov-append --cov-report=xml --cov-config={toxinidir}/tox.ini --ignore docs/ {posargs:-vv} {env:PYTEST_FLAGS:} - -[testenv:covclean] -description = Clean coverage files. -deps = coverage -skip_install = True -commands = coverage erase - -[testenv:coverage] -description = Report the coverage difference. -deps = - coverage - diff_cover -skip_install = true -depends = py3.10-linux, py3.11-linux, py3.12-linux, py3.12-macos -parallel_show_output = True -commands = - coverage report --omit="tox/*" - coverage xml --omit="tox/*" -o {toxinidir}/coverage.xml - diff-cover --compare-branch origin/main {toxinidir}/coverage.xml - -[testenv:clean-docs] -description = Clean the documentation artifacts. -deps = -skip_install = true -changedir = {toxinidir}/docs -allowlist_externals = make -commands = make clean - -[testenv:check-docs] -description = Lint the documentation. -deps = -extras = docs -ignore_errors = true -allowlist_externals = make -pass_env = PYENCHANT_LIBRARY_PATH -set_env = SPHINXOPTS = -W -q --keep-going -changedir = {tox_root}{/}docs -commands = - make linkcheck {posargs} - -[testenv:docs] -description = Build the documentation. -deps = -extras = docs -allowlist_externals = make -changedir = {tox_root}{/}docs -commands = - make html {posargs} -commands_post = - python -c 'import pathlib; print("Documentation is under:", pathlib.Path("{tox_root}") / "docs" / "_build" / "html" / "index.html")' - -[testenv:download-data] -description = Download and cache data. -skip_install = false -deps = -commands = python ./.scripts/ci/download_data.py {posargs} - From 1ca5718866f615d9aefba48f1eff3f7bfdcd3b42 Mon Sep 17 00:00:00 2001 From: "selman.ozleyen" Date: Thu, 4 Sep 2025 16:11:54 +0200 Subject: [PATCH 21/25] add step to setup squidpy kernel --- .github/workflows/test-notebooks.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-notebooks.yml b/.github/workflows/test-notebooks.yml index 160394180..a95ab4729 100644 --- a/.github/workflows/test-notebooks.yml +++ b/.github/workflows/test-notebooks.yml @@ -40,4 +40,7 @@ jobs: MPLBACKEND: agg PLATFORM: ${{ matrix.os }} DISPLAY: :42 - run: uvx hatch run notebooks:run-notebooks + + run: + uvx hatch run notebooks:setup-squidpy-kernel + uvx hatch run notebooks:run-notebooks From 6ecab08772b9b2e82fbc7c28d5faaec7a34437c5 Mon Sep 17 00:00:00 2001 From: "selman.ozleyen" Date: Thu, 4 Sep 2025 16:17:24 +0200 Subject: [PATCH 22/25] fix syntax err --- .github/workflows/test-notebooks.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-notebooks.yml b/.github/workflows/test-notebooks.yml index a95ab4729..e18ded7c8 100644 --- a/.github/workflows/test-notebooks.yml +++ b/.github/workflows/test-notebooks.yml @@ -40,7 +40,7 @@ jobs: MPLBACKEND: agg PLATFORM: ${{ matrix.os }} DISPLAY: :42 - - run: - uvx hatch run notebooks:setup-squidpy-kernel - uvx hatch run notebooks:run-notebooks + + run: | + uvx hatch run notebooks:setup-squidpy-kernel + uvx hatch run notebooks:run-notebooks From bef64d3f49fc917711f91ef13a6ca5a4096c53ce Mon Sep 17 00:00:00 2001 From: "selman.ozleyen" Date: Wed, 1 Oct 2025 14:16:27 +0200 Subject: [PATCH 23/25] update the notebook commit --- docs/notebooks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/notebooks b/docs/notebooks index 4f47e47bf..9684edbf8 160000 --- a/docs/notebooks +++ b/docs/notebooks @@ -1 +1 @@ -Subproject commit 4f47e47bf66da170963a2252c5c699b77bb050d9 +Subproject commit 9684edbf847be14b749fa5d31c5732fd1c66a87f From 3a9a0049b38494dd11440d954f157e2ff3bf0de7 Mon Sep 17 00:00:00 2001 From: "selman.ozleyen" Date: Wed, 1 Oct 2025 15:42:35 +0200 Subject: [PATCH 24/25] update the nb commit for rendering --- docs/notebooks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/notebooks b/docs/notebooks index 9684edbf8..98d97da49 160000 --- a/docs/notebooks +++ b/docs/notebooks @@ -1 +1 @@ -Subproject commit 9684edbf847be14b749fa5d31c5732fd1c66a87f +Subproject commit 98d97da49528e4229548a315a88569ebfc618942 From f47405863defdeaa3a6ee2accd44132df6f00744 Mon Sep 17 00:00:00 2001 From: "selman.ozleyen" Date: Wed, 1 Oct 2025 15:50:19 +0200 Subject: [PATCH 25/25] update the home page to add new section --- docs/index.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/index.rst b/docs/index.rst index ebc70d665..8f97ee5f9 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -77,6 +77,7 @@ We are happy about any contributions! Before you start, check out our `contribut notebooks/tutorials/index notebooks/examples/index + notebooks/deprecated_features/index .. |PyPI| image:: https://img.shields.io/pypi/v/squidpy.svg :target: https://pypi.org/project/squidpy/