File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Validate notebooks
2+
3+ on :
4+ push :
5+ paths :
6+ - " examples/**/*.ipynb"
7+ - " data/**"
8+ - " requirements.txt"
9+ - " .github/workflows/notebooks.yml"
10+ pull_request :
11+ paths :
12+ - " examples/**/*.ipynb"
13+ - " data/**"
14+ - " requirements.txt"
15+ - " .github/workflows/notebooks.yml"
16+ workflow_dispatch :
17+
18+ jobs :
19+ notebooks :
20+ runs-on : ubuntu-latest
21+ timeout-minutes : 15
22+
23+ steps :
24+ - name : Check out repository
25+ uses : actions/checkout@v4
26+
27+ - name : Set up Python
28+ uses : actions/setup-python@v5
29+ with :
30+ python-version : " 3.11"
31+ cache : " pip"
32+ cache-dependency-path : requirements.txt
33+
34+ - name : Install dependencies
35+ run : |
36+ python -m pip install --upgrade pip
37+ pip install -r requirements.txt
38+
39+ - name : Execute notebooks
40+ run : |
41+ python - <<'PY'
42+ from pathlib import Path
43+ import nbformat
44+ from nbclient import NotebookClient
45+
46+ notebooks = sorted(Path("examples").rglob("*.ipynb"))
47+ if not notebooks:
48+ raise SystemExit("No notebooks found under examples/")
49+
50+ for notebook_path in notebooks:
51+ print(f"Executing {notebook_path}...")
52+ with notebook_path.open(encoding="utf-8") as f:
53+ notebook = nbformat.read(f, as_version=4)
54+
55+ client = NotebookClient(
56+ notebook,
57+ timeout=600,
58+ kernel_name="python3",
59+ resources={"metadata": {"path": str(notebook_path.parent)}},
60+ )
61+ client.execute()
62+
63+ print(f"Validated {len(notebooks)} notebook(s).")
64+ PY
Original file line number Diff line number Diff line change 1+ numpy
2+ pandas
3+ scikit-learn
4+ jupyterlab
5+ nbclient
6+ nbformat
7+ ipykernel
You can’t perform that action at this time.
0 commit comments