Skip to content

Commit a8b4dd5

Browse files
authored
Merge pull request #35 from jhlegarreta/RunNotebooksInTox
MAINT: Add additional environment to ``tox`` to run notebooks
2 parents 856a00e + 56f6b2c commit a8b4dd5

File tree

5 files changed

+77
-3
lines changed

5 files changed

+77
-3
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ jobs:
7070
with:
7171
path: /home/runner/nifreeze-tests/
7272
key: data-v0
73+
- name: Install TeX Live
74+
run: |
75+
sudo apt-get update
76+
sudo apt install texlive texlive-latex-extra texlive-fonts-recommended cm-super dvipng
7377
- name: Install tox
7478
run: |
7579
python -m pip install --upgrade pip

docs/notebooks/bold_realignment.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"WORKDIR = Path.home() / \"tmp\" / \"nifreezedev\" / \"ismrm25\"\n",
3535
"WORKDIR.mkdir(parents=True, exist_ok=True)\n",
3636
"\n",
37-
"OUTPUT_DIR = Path(\"/data/derivatives\") / \"nifreeze-ismrm25-exp2\"\n",
37+
"OUTPUT_DIR = Path.home() / \"tmp\" / \"nifreezedev\" / \"ismrm25\" / \"nifreeze-ismrm25-exp2\"\n",
3838
"OUTPUT_DIR.mkdir(exist_ok=True, parents=True)"
3939
]
4040
},

pyproject.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ test = [
7676
"pytest-xdist >= 1.28"
7777
]
7878

79+
notebooks = [
80+
"jupyter",
81+
"nbclient",
82+
"nbmake",
83+
"mriqc_learn",
84+
"nipreps-synthstrip",
85+
]
86+
7987
antsopt = [
8088
"ConfigSpace",
8189
"nipreps",

tools/run_notebooks.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
2+
# vi: set ft=python sts=4 ts=4 sw=4 et:
3+
#
4+
# Copyright The NiPreps Developers <[email protected]>
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
# We support and encourage derived works from this project, please read
19+
# about our expectations at
20+
#
21+
# https://www.nipreps.org/community/licensing/
22+
#
23+
24+
import glob
25+
import subprocess
26+
import sys
27+
28+
notebooks = glob.glob("docs/notebooks/*.ipynb")
29+
# Make bold_realignment.ipynb Jupyter notebook an exception as it involves running a realignment
30+
# process for several DataLad datasets, which requires long running times.
31+
notebooks.remove("docs/notebooks/bold_realignment.ipynb")
32+
33+
sys.exit(subprocess.call(["pytest", "--nbmake"] + notebooks))

tox.ini

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
requires =
33
tox>=4
44
envlist =
5-
py312
5+
py312, notebooks
66
skip_missing_interpreters = true
77

88
# Configuration that allows us to split tests across GitHub runners effectively
99
[gh-actions]
1010
python =
11-
3.12: py312
11+
3.12: py312, notebooks
1212

1313
[testenv]
1414
description = Pytest with coverage
@@ -39,6 +39,35 @@ commands =
3939
pytest --doctest-modules --cov nifreeze -n auto --cov-report xml \
4040
--junitxml=test-results.xml -v src test {posargs}
4141

42+
[testenv:notebooks]
43+
description = Run notebooks
44+
labels = notebooks
45+
pass_env =
46+
# getpass.getuser() sources for Windows:
47+
LOGNAME
48+
USER
49+
LNAME
50+
USERNAME
51+
# Pass user color preferences through
52+
PY_COLORS
53+
FORCE_COLOR
54+
NO_COLOR
55+
CLICOLOR
56+
CLICOLOR_FORCE
57+
CURBRANCH
58+
GITHUB_ACTIONS
59+
TEST_DATA_HOME
60+
TEST_OUTPUT_DIR
61+
TEST_WORK_DIR
62+
PYTHONHASHSEED
63+
ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS
64+
PATH
65+
extras = notebooks
66+
commands =
67+
# pytest --nbmake docs/notebooks/*.ipynb
68+
# not working due to https://github.com/tox-dev/tox/issues/1571
69+
python {toxinidir}/tools/run_notebooks.py
70+
4271
[testenv:docs]
4372
description = Build documentation site
4473
labels = docs

0 commit comments

Comments
 (0)