diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fbc7060..a1acb0d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -70,6 +70,10 @@ jobs: with: path: /home/runner/nifreeze-tests/ key: data-v0 + - name: Install TeX Live + run: | + sudo apt-get update + sudo apt install texlive texlive-latex-extra texlive-fonts-recommended cm-super dvipng - name: Install tox run: | python -m pip install --upgrade pip diff --git a/docs/notebooks/bold_realignment.ipynb b/docs/notebooks/bold_realignment.ipynb index b9d9647..55bf791 100644 --- a/docs/notebooks/bold_realignment.ipynb +++ b/docs/notebooks/bold_realignment.ipynb @@ -34,7 +34,7 @@ "WORKDIR = Path.home() / \"tmp\" / \"nifreezedev\" / \"ismrm25\"\n", "WORKDIR.mkdir(parents=True, exist_ok=True)\n", "\n", - "OUTPUT_DIR = Path(\"/data/derivatives\") / \"nifreeze-ismrm25-exp2\"\n", + "OUTPUT_DIR = Path.home() / \"tmp\" / \"nifreezedev\" / \"ismrm25\" / \"nifreeze-ismrm25-exp2\"\n", "OUTPUT_DIR.mkdir(exist_ok=True, parents=True)" ] }, diff --git a/pyproject.toml b/pyproject.toml index 7c8de5a..6c6b89a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,6 +76,14 @@ test = [ "pytest-xdist >= 1.28" ] +notebooks = [ + "jupyter", + "nbclient", + "nbmake", + "mriqc_learn", + "nipreps-synthstrip", +] + antsopt = [ "ConfigSpace", "nipreps", diff --git a/tools/run_notebooks.py b/tools/run_notebooks.py new file mode 100644 index 0000000..f9506f4 --- /dev/null +++ b/tools/run_notebooks.py @@ -0,0 +1,33 @@ +# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- +# vi: set ft=python sts=4 ts=4 sw=4 et: +# +# Copyright The NiPreps Developers +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# We support and encourage derived works from this project, please read +# about our expectations at +# +# https://www.nipreps.org/community/licensing/ +# + +import glob +import subprocess +import sys + +notebooks = glob.glob("docs/notebooks/*.ipynb") +# Make bold_realignment.ipynb Jupyter notebook an exception as it involves running a realignment +# process for several DataLad datasets, which requires long running times. +notebooks.remove("docs/notebooks/bold_realignment.ipynb") + +sys.exit(subprocess.call(["pytest", "--nbmake"] + notebooks)) diff --git a/tox.ini b/tox.ini index 8939590..e3672d1 100644 --- a/tox.ini +++ b/tox.ini @@ -2,13 +2,13 @@ requires = tox>=4 envlist = - py312 + py312, notebooks skip_missing_interpreters = true # Configuration that allows us to split tests across GitHub runners effectively [gh-actions] python = - 3.12: py312 + 3.12: py312, notebooks [testenv] description = Pytest with coverage @@ -39,6 +39,35 @@ commands = pytest --doctest-modules --cov nifreeze -n auto --cov-report xml \ --junitxml=test-results.xml -v src test {posargs} +[testenv:notebooks] +description = Run notebooks +labels = notebooks +pass_env = + # getpass.getuser() sources for Windows: + LOGNAME + USER + LNAME + USERNAME + # Pass user color preferences through + PY_COLORS + FORCE_COLOR + NO_COLOR + CLICOLOR + CLICOLOR_FORCE + CURBRANCH + GITHUB_ACTIONS + TEST_DATA_HOME + TEST_OUTPUT_DIR + TEST_WORK_DIR + PYTHONHASHSEED + ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS + PATH +extras = notebooks +commands = + # pytest --nbmake docs/notebooks/*.ipynb + # not working due to https://github.com/tox-dev/tox/issues/1571 + python {toxinidir}/tools/run_notebooks.py + [testenv:docs] description = Build documentation site labels = docs