From be31b087b8c15840f63478da0b3af523eb3d0ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Haitz=20Legarreta=20Gorro=C3=B1o?= Date: Fri, 8 Nov 2024 18:16:15 -0500 Subject: [PATCH] ENH: Add additional environment to `tox` to run notebooks Add an additional environment to `tox` to run notebooks. Add a new table to `pyproject.toml` to host the `jupyter`, `nbconvert` and `nbclient` dependencies so that the notebooks can be run. Install `textlive` in the test CI so that LaTeX decoration in plots can be employed. --- .github/workflows/test.yml | 4 ++++ pyproject.toml | 6 ++++++ tox.ini | 31 +++++++++++++++++++++++++++++-- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0293c50..480b2d2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -69,6 +69,10 @@ jobs: with: path: /home/runner/nifreeze-tests/ key: data-v0 + - name: Install TeX Live + run: | + sudo apt-get update + sudo apt install texlive - name: Install tox run: | python -m pip install --upgrade pip diff --git a/pyproject.toml b/pyproject.toml index 70ace46..9059ea7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,6 +74,12 @@ test = [ "pytest-xdist >= 1.28" ] +notebooks = [ + "jupyter", + "nbconvert", + "nbclient", +] + antsopt = [ "ConfigSpace", "nipreps", diff --git a/tox.ini b/tox.ini index 77371e1..1a1655b 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 @@ -38,6 +38,33 @@ 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 = + python -m nbconvert --to notebook --ExecutePreprocessor.kernel_name=python3 --execute docs/notebooks/* + [testenv:docs] description = Build documentation site labels = docs