From 2486681f0cb6578759cd78aa5b7f43dcfb3da6c4 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Mon, 16 Sep 2024 15:34:39 -0400 Subject: [PATCH 1/7] PY39: Support pre-__or__ types --- nitransforms/resampling.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nitransforms/resampling.py b/nitransforms/resampling.py index d7c7f9c..1045cde 100644 --- a/nitransforms/resampling.py +++ b/nitransforms/resampling.py @@ -12,7 +12,7 @@ from os import cpu_count from functools import partial from pathlib import Path -from typing import Callable, TypeVar +from typing import Callable, TypeVar, Union import numpy as np from nibabel.loadsave import load as _nbload @@ -144,8 +144,8 @@ async def _apply_serial( def apply( transform: TransformBase, - spatialimage: str | Path | SpatialImage, - reference: str | Path | SpatialImage = None, + spatialimage: Union[str, Path, SpatialImage], + reference: Union[str, Path, SpatialImage] = None, order: int = 3, mode: str = "constant", cval: float = 0.0, @@ -154,7 +154,7 @@ def apply( dtype_width: int = 8, serialize_nvols: int = SERIALIZE_VOLUME_WINDOW_WIDTH, max_concurrent: int = min(cpu_count(), 12), -) -> SpatialImage | np.ndarray: +) -> Union[SpatialImage, np.ndarray]: """ Apply a transformation to an image, resampling on the reference spatial object. From d7e10df4b43d9e223e73a833bf7d6b9ff889e1f8 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Mon, 16 Sep 2024 16:55:44 -0400 Subject: [PATCH 2/7] CI: Run tests most of the time --- .github/workflows/travis.yml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/travis.yml b/.github/workflows/travis.yml index 7efe2c7..f1076c4 100644 --- a/.github/workflows/travis.yml +++ b/.github/workflows/travis.yml @@ -1,10 +1,25 @@ name: Deps & CI -on: [push] +on: + push: + branches: [ '*' ] + pull_request: + branches: [ master, 'maint/*' ] + schedule: + - cron: '0 0 * * 1' + # Allow job to be triggered manually from GitHub interface + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read jobs: build-linux: - if: "!contains(github.event.head_commit.message, '[skip ci]' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'nipy/nitransforms'))" + if: "!contains(github.event.head_commit.message, '[skip ci]')" runs-on: ubuntu-latest env: TEST_DATA_HOME: /home/runner/testdata/nitransforms-tests From cc630e1132b94216b8963f29fef0d0cf5c9b5077 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Tue, 17 Sep 2024 08:18:38 -0400 Subject: [PATCH 3/7] CI: Cache data separately from tests --- .github/workflows/travis.yml | 44 ++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/.github/workflows/travis.yml b/.github/workflows/travis.yml index f1076c4..96075e3 100644 --- a/.github/workflows/travis.yml +++ b/.github/workflows/travis.yml @@ -18,16 +18,11 @@ permissions: contents: read jobs: - build-linux: + cache-test-data: if: "!contains(github.event.head_commit.message, '[skip ci]')" runs-on: ubuntu-latest env: TEST_DATA_HOME: /home/runner/testdata/nitransforms-tests - strategy: - max-parallel: 5 - matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] - steps: - name: Git settings (pacify DataLad) run: | @@ -48,8 +43,8 @@ jobs: python-${{ matrix.python-version }}- - name: Install DataLad run: | - $CONDA/bin/conda install -c conda-forge git-annex datalad pip pytest - $CONDA/bin/python -m pip install datalad-osf + $CONDA/bin/conda install -c conda-forge git-annex + python -m pip install datalad datalad-next datalad-osf - uses: actions/cache@v3 with: @@ -62,19 +57,40 @@ jobs: run: | export PATH=$CONDA/bin:$PATH mkdir -p /home/runner/testdata - cd /home/runner/testdata - $CONDA/bin/datalad install https://gin.g-node.org/oesteban/nitransforms-tests - $CONDA/bin/datalad update --merge -d nitransforms-tests/ - $CONDA/bin/datalad get -d nitransforms-tests/ + datalad install -s https://gin.g-node.org/oesteban/nitransforms-tests $TEST_DATA_HOME + datalad update --merge -d $TEST_DATA_HOME + datalad get -J 2 -d $TEST_DATA_HOME + + build-linux: + if: "!contains(github.event.head_commit.message, '[skip ci]')" + runs-on: ubuntu-latest + needs: [cache-test-data] + env: + TEST_DATA_HOME: /home/runner/testdata/nitransforms-tests + strategy: + max-parallel: 5 + matrix: + python-version: ['3.8', '3.9', '3.10', '3.11'] + steps: + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - uses: actions/cache@v3 + with: + path: ${{ env.TEST_DATA_HOME }} + key: data-cache-v2 + restore-keys: | + data-cache-v2 - uses: actions/checkout@v3 - name: Install minimal dependencies run: | - $CONDA/bin/pip install .[tests] + pip install .[tests] - name: Run pytest run: | - $CONDA/bin/pytest -v --cov nitransforms --cov-config .coveragerc --cov-report xml:cov.xml --doctest-modules nitransforms/ + pytest -v --cov nitransforms --cov-config .coveragerc --cov-report xml:cov.xml --doctest-modules nitransforms/ - name: Submit code coverage uses: codecov/codecov-action@v3 From e8fe426dad7a641156bb4c6c1f40472269e26bc3 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Tue, 17 Sep 2024 08:36:31 -0400 Subject: [PATCH 4/7] Update cache based on test repo HEAD --- .github/workflows/travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/travis.yml b/.github/workflows/travis.yml index 96075e3..551a986 100644 --- a/.github/workflows/travis.yml +++ b/.github/workflows/travis.yml @@ -45,12 +45,17 @@ jobs: run: | $CONDA/bin/conda install -c conda-forge git-annex python -m pip install datalad datalad-next datalad-osf + - name: Check remote HEAD + run: | + git ls-remote https://gin.g-node.org/oesteban/nitransforms-tests \ + | awk '/HEAD/{ print "HEAD=" $1 }' >> $GITHUB_ENV - uses: actions/cache@v3 with: path: ${{ env.TEST_DATA_HOME }} - key: data-cache-v2 + key: data-cache-v2-${{ env.HEAD }} restore-keys: | + data-cache-v2-${{ env.HEAD }} data-cache-v2 - name: Install test data From 23d73935d8afb2f5306d0121eb30617154a218cb Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Tue, 17 Sep 2024 08:51:10 -0400 Subject: [PATCH 5/7] Pass hash across jobs, restore only in tests --- .github/workflows/travis.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/travis.yml b/.github/workflows/travis.yml index 551a986..6e61f0e 100644 --- a/.github/workflows/travis.yml +++ b/.github/workflows/travis.yml @@ -23,6 +23,8 @@ jobs: runs-on: ubuntu-latest env: TEST_DATA_HOME: /home/runner/testdata/nitransforms-tests + outputs: + SHA: ${{ steps.test-head.outputs.SHA }} steps: - name: Git settings (pacify DataLad) run: | @@ -46,16 +48,17 @@ jobs: $CONDA/bin/conda install -c conda-forge git-annex python -m pip install datalad datalad-next datalad-osf - name: Check remote HEAD + id: test-head run: | git ls-remote https://gin.g-node.org/oesteban/nitransforms-tests \ - | awk '/HEAD/{ print "HEAD=" $1 }' >> $GITHUB_ENV + | awk '/HEAD/{ print "SHA=" $1 }' >> $GITHUB_OUTPUT - uses: actions/cache@v3 with: path: ${{ env.TEST_DATA_HOME }} - key: data-cache-v2-${{ env.HEAD }} + key: data-cache-v2-${{ steps.test-head.outputs.SHA }} restore-keys: | - data-cache-v2-${{ env.HEAD }} + data-cache-v2-${{ steps.test-head.outputs.SHA }} data-cache-v2 - name: Install test data @@ -82,12 +85,10 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - - uses: actions/cache@v3 + - uses: actions/cache/restore@v3 with: path: ${{ env.TEST_DATA_HOME }} - key: data-cache-v2 - restore-keys: | - data-cache-v2 + key: data-cache-v2-${{ needs.cache-test-data.outputs.SHA }} - uses: actions/checkout@v3 - name: Install minimal dependencies From ae5a1452e222fff452f546b10d8291cf4f1a825c Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Tue, 17 Sep 2024 08:56:01 -0400 Subject: [PATCH 6/7] CI: Test on Python 3.12 --- .github/workflows/travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/travis.yml b/.github/workflows/travis.yml index 6e61f0e..88dec91 100644 --- a/.github/workflows/travis.yml +++ b/.github/workflows/travis.yml @@ -79,7 +79,7 @@ jobs: strategy: max-parallel: 5 matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] steps: - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 From 94ec1199602987a14b724ffdd358abc44d5447a3 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Tue, 17 Sep 2024 08:58:13 -0400 Subject: [PATCH 7/7] Drop conda cache --- .github/workflows/travis.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.github/workflows/travis.yml b/.github/workflows/travis.yml index 88dec91..b9e7c3d 100644 --- a/.github/workflows/travis.yml +++ b/.github/workflows/travis.yml @@ -30,19 +30,6 @@ jobs: run: | git config --global user.name 'NiPreps Bot' git config --global user.email 'nipreps@gmail.com' - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - uses: actions/cache@v3 - id: conda - with: - path: | - /usr/share/miniconda/pkgs - /home/runner/.cache/pip - key: python-${{ matrix.python-version }}-v1 - restore-keys: | - python-${{ matrix.python-version }}- - name: Install DataLad run: | $CONDA/bin/conda install -c conda-forge git-annex