Skip to content

Commit

Permalink
CI: switch to testing example .py files instead of notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
schlegelp committed Sep 4, 2024
1 parent 24d334d commit 20b7ab1
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 63 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Notebooks
name: Tutorials

on: [push]

Expand Down Expand Up @@ -30,13 +30,13 @@ jobs:
python -m pip install --upgrade pip
python -m pip install pathos pygraphviz neuron cloud-volume k3d scikit-image open3d
python -m pip install -e .[test-notebook,all]
- name: Run notebooks
- name: Run tutorials
uses: coactions/setup-xvfb@v1
env:
NEUPRINT_APPLICATION_CREDENTIALS: ${{ secrets.neuprint }}
INSECT_BRAIN_DB_USER: ${{ secrets.insect_brain_db_user }}
INSECT_BRAIN_DB_PASSWORD: ${{ secrets.insect_brain_db_password }}
with:
run: |
export NAVIS_HEADLESS=TRUE
python tests/test_notebooks.py
NAVIS_PLOT3D_BACKEND="plotly"
python tests/test_tutorials.py
59 changes: 0 additions & 59 deletions tests/test_notebooks.py

This file was deleted.

48 changes: 48 additions & 0 deletions tests/test_tutorials.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""
Code to execute code examples notebooks in /docs/examples.
This will not be run through pytest but is meant to be run in a separate CI job.
"""

import subprocess
from pathlib import Path

# If Jupyter is not installed, this will fail.
# We will belay the import error in case the
# user wants to run only the other parts of the
# test suite.
try:
import nbformat
from nbconvert.preprocessors import ExecutePreprocessor
except ImportError:
nbformat = None
pass
except BaseException:
raise

SKIP = [

]

if __name__ == "__main__":
# Recursively search for notebooks
path = Path(__file__).parent.parent / "docs/examples"

files = list(path.rglob("*.py"))
for i, file in enumerate(files):
if not file.is_file():
continue
if file.name in SKIP:
continue

print(f"Executing {file.name} [{i+1}/{len(files)}]... ", end="", flush=True)
try:
p = subprocess.run(["python", str(file)], check=True, capture_output=True, timeout=600)
except subprocess.CalledProcessError as e:
print("Failed.")
print(e.stdout.decode())
print(e.stderr.decode())
raise
print("Done.", flush=True)

print("All done.")

0 comments on commit 20b7ab1

Please sign in to comment.