From 129c77f32c7229592d1d4562072fecc37543ae4f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 12 Dec 2022 17:26:11 +0000 Subject: [PATCH 01/12] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.3.0 → v4.4.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.3.0...v4.4.0) - [github.com/psf/black: 22.10.0 → 22.12.0](https://github.com/psf/black/compare/22.10.0...22.12.0) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1061012..6cc0006 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,13 +2,13 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.4.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - id: check-yaml - id: check-added-large-files - repo: https://github.com/psf/black - rev: 22.10.0 + rev: 22.12.0 hooks: - id: black From 43bc5db554668086f667be08ee5596d01db7f759 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 6 Feb 2023 19:32:07 +0100 Subject: [PATCH 02/12] [pre-commit.ci] pre-commit autoupdate (#32) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 22.12.0 → 23.1.0](https://github.com/psf/black/compare/22.12.0...23.1.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6cc0006..6c0ed16 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,6 +9,6 @@ repos: - id: check-yaml - id: check-added-large-files - repo: https://github.com/psf/black - rev: 22.12.0 + rev: 23.1.0 hooks: - id: black From 8e2aade8783ac8fd7aa90827757ae800ecf42194 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 3 Apr 2023 17:58:24 +0000 Subject: [PATCH 03/12] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 23.1.0 → 23.3.0](https://github.com/psf/black/compare/23.1.0...23.3.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6c0ed16..1336a23 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,6 +9,6 @@ repos: - id: check-yaml - id: check-added-large-files - repo: https://github.com/psf/black - rev: 23.1.0 + rev: 23.3.0 hooks: - id: black From 6dcac6e104f74b0abee6041fabc698e6389a5886 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 22 Mar 2024 20:36:07 -0400 Subject: [PATCH 04/12] PIN: Python >=3.8 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7f97f7b..7fe2461 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "flit_scm:buildapi" name = "pydra-nipype1" description = "Tools for importing nipype 1.x interfaces into Pydra" readme = "README.md" -requires-python = ">=3.7" +requires-python = ">=3.8" dependencies = [ "pydra >=0.6.2", "nipype", From eb23523fed43df72e0581bacfc15924afc262361 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 22 Mar 2024 20:34:51 -0400 Subject: [PATCH 05/12] CI: Rework CI to use conda-installed Python/FSL --- .github/workflows/pythonpackage.yml | 83 ++++++++++++++++------------- 1 file changed, 47 insertions(+), 36 deletions(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 979871c..5d52a1d 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -6,28 +6,37 @@ name: Python package # Set once env: SUBPACKAGE: nipype1 + FSLCONDA: https://fsl.fmrib.ox.ac.uk/fsldownloads/fslconda/public/ on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +defaults: + run: + shell: bash -el {0} jobs: devcheck: runs-on: ubuntu-latest strategy: matrix: - python-version: [ '3.7', '3.11' ] # Check oldest and newest versions - pip-flags: [ '', '--editable' ] + python-version: ["3.8", "3.12"] # Check oldest and newest versions + pip-flags: ["", "--editable"] pydra: - - 'pydra' - - '--editable git+https://github.com/nipype/pydra.git#egg=pydra' + - "pydra" + - "--editable git+https://github.com/nipype/pydra.git#egg=pydra" steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install build dependencies @@ -47,19 +56,24 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: conda-incubator/setup-miniconda@v3 with: python-version: ${{ matrix.python-version }} - - name: Set up NeuroDebian - run: bash <(wget -q -O- http://neuro.debian.net/_files/neurodebian-travis.sh) + mamba-version: "*" + channels: ${{ env.FSLCONDA }},conda-forge,defaults + channel-priority: true - name: Install FSL - run: sudo apt-get install -y fsl - - name: Install build dependencies + run: | + mamba install fsl-avwutils + mamba env config vars set FSLDIR="$CONDA_PREFIX" FSLOUTPUTTYPE="NIFTI_GZ" + # Hack because we're not doing a full FSL install + echo "6.0.7.9" > $CONDA_PREFIX/etc/fslversion + - name: Upgrade pip run: | python -m pip install --upgrade pip - name: Install task package @@ -69,34 +83,31 @@ jobs: python -c "import pydra as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')" - name: Test with pytest run: | - source /etc/fsl/fsl.sh pytest -sv --doctest-modules pydra/tasks/$SUBPACKAGE \ --cov pydra.tasks.$SUBPACKAGE --cov-report xml - - uses: codecov/codecov-action@v1 + - uses: codecov/codecov-action@v4 if: ${{ always() }} + with: + token: ${{ secrets.CODECOV_TOKEN }} - deploy: - needs: [ devcheck, test ] + build: runs-on: ubuntu-latest - strategy: - matrix: - python-version: [ '3.9' ] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: submodules: recursive fetch-depth: 0 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install build tools - run: python -m pip install build twine - - name: Build source and wheel distributions - run: python -m build - - name: Check distributions - run: twine check dist/* - - uses: actions/upload-artifact@v2 + - uses: hynek/build-and-inspect-python-package@v2 + + deploy: + needs: [build, devcheck, test] + runs-on: ubuntu-latest + permissions: + id-token: write + if: github.repository_owner == 'nipype' && github.event.action == 'published' + steps: + - uses: actions/download-artifact@v4 with: - name: distributions - path: dist/ + name: Packages + path: dist + - uses: pypa/gh-action-pypi-publish@release/v1 From ee5c86e3572996176033396ecc73507d6b2fdd59 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 22 Mar 2024 21:07:16 -0400 Subject: [PATCH 06/12] FIX: Annotate type, add environment argument to _run_task --- pydra/tasks/nipype1/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pydra/tasks/nipype1/utils.py b/pydra/tasks/nipype1/utils.py index 0be31c4..5389995 100644 --- a/pydra/tasks/nipype1/utils.py +++ b/pydra/tasks/nipype1/utils.py @@ -11,7 +11,7 @@ def traitedspec_to_specinfo(traitedspec): return pydra.specs.SpecInfo( name="Inputs", fields=[ - (name, attrs.field(metadata={"help_string": trait.desc})) + (name, attrs.field(metadata={"help_string": trait.desc}, type=ty.Any)) for name, trait in traitedspec.traits().items() if name in trait_names ], @@ -68,7 +68,7 @@ def __init__( ) self.output_spec = traitedspec_to_specinfo(interface._outputs()) - def _run_task(self): + def _run_task(self, environment=None): inputs = attrs.asdict(self.inputs, filter=lambda a, v: v is not attrs.NOTHING) node = nipype.Node(self._interface, base_dir=self.output_dir, name=self.name) node.inputs.trait_set(**inputs) From d9905f41de43fc8b2a7abe4e36b09dd93e4c617a Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 22 Mar 2024 21:24:15 -0400 Subject: [PATCH 07/12] MNT: Fix gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ef50f11..4dc2815 100644 --- a/.gitignore +++ b/.gitignore @@ -129,4 +129,4 @@ dmypy.json .pyre/ # Generated by flit_scm -_versions.py +_version.py From 12c7fcbb768f9c7b6a019d54f68ae7498cfa7713 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 22 Mar 2024 21:26:35 -0400 Subject: [PATCH 08/12] CI: Remove redundant publish workflow --- .github/workflows/publish.yml | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index dc05d30..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: publish - -on: - # Trigger this workflow when a release is created. - release: - types: - - published - -permissions: - # Allow checkout of the project. - contents: read - -env: - # Default Python version on which jobs are run. - DEFAULT_PYTHON_VERSION: '3.9' - -jobs: - publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: ${{ env.DEFAULT_PYTHON_VERSION }} - - name: Install build frontend - run: python -m pip install build - - name: Build distribution package - run: python -m build - - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.PYPI_API_TOKEN }} From 21ed4720f8703052255627c13b8d5b2fc16b4a70 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 22 Mar 2024 21:42:32 -0400 Subject: [PATCH 09/12] RF: Remove pkg_resources dependency --- pydra/tasks/nipype1/tests/__init__.py | 18 ++++++++++++++++++ pydra/tasks/nipype1/tests/test_nipype1task.py | 4 ++-- pydra/tasks/nipype1/utils.py | 4 ++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/pydra/tasks/nipype1/tests/__init__.py b/pydra/tasks/nipype1/tests/__init__.py index e69de29..6e98041 100644 --- a/pydra/tasks/nipype1/tests/__init__.py +++ b/pydra/tasks/nipype1/tests/__init__.py @@ -0,0 +1,18 @@ +import sys +from atexit import register +from contextlib import ExitStack +from functools import lru_cache + + +if sys.version_info < (3, 9): + from importlib_resources import as_file, files +else: + from importlib.resources import as_file, files + +_stack = ExitStack() +register(_stack.close) + + +@lru_cache +def load_resource(anchor, *parts) -> str: + return str(_stack.enter_context(as_file(files(anchor).joinpath(*parts)))) diff --git a/pydra/tasks/nipype1/tests/test_nipype1task.py b/pydra/tasks/nipype1/tests/test_nipype1task.py index 9a17c6e..5ceeb16 100644 --- a/pydra/tasks/nipype1/tests/test_nipype1task.py +++ b/pydra/tasks/nipype1/tests/test_nipype1task.py @@ -1,6 +1,6 @@ import pytest import shutil -from pkg_resources import resource_filename +from . import load_resource from nipype.interfaces import fsl import nipype.interfaces.utility as nutil @@ -12,7 +12,7 @@ def test_isolation(tmp_path): in_file = tmp_path / "orig/tpms_msk.nii.gz" in_file.parent.mkdir() - shutil.copyfile(resource_filename("nipype", "testing/data/tpms_msk.nii.gz"), in_file) + shutil.copyfile(load_resource("nipype", "testing/data/tpms_msk.nii.gz"), in_file) out_dir = tmp_path / "output" out_dir.mkdir() diff --git a/pydra/tasks/nipype1/utils.py b/pydra/tasks/nipype1/utils.py index 5389995..913403b 100644 --- a/pydra/tasks/nipype1/utils.py +++ b/pydra/tasks/nipype1/utils.py @@ -27,11 +27,11 @@ class Nipype1Task(pydra.engine.task.TaskBase): in Pydra Task outputs. >>> import pytest - >>> from pkg_resources import resource_filename + >>> from pydra.tasks.nipype1.tests import load_resource >>> from nipype.interfaces import fsl >>> if fsl.Info.version() is None: ... pytest.skip() - >>> img = resource_filename('nipype', 'testing/data/tpms_msk.nii.gz') + >>> img = load_resource('nipype', 'testing/data/tpms_msk.nii.gz') >>> from pydra.tasks.nipype1.utils import Nipype1Task >>> thresh = Nipype1Task(fsl.Threshold()) From 627e48ba248d4dc56c57f76faae81a47d992cd60 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 22 Mar 2024 21:51:08 -0400 Subject: [PATCH 10/12] STY: black --- pydra/tasks/nipype1/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pydra/tasks/nipype1/__init__.py b/pydra/tasks/nipype1/__init__.py index d786431..090acf5 100644 --- a/pydra/tasks/nipype1/__init__.py +++ b/pydra/tasks/nipype1/__init__.py @@ -2,6 +2,7 @@ >>> from pydra import ShellCommandTask >>> import pydra.tasks.nipype1 """ + try: from ._version import __version__ except ImportError: From ac74addcd31978344e825ffd8ed5482394e8b362 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 22 Mar 2024 21:51:33 -0400 Subject: [PATCH 11/12] REL: 0.3.0 --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b507e27..b8e31e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ All notable changes to this project will be documented in this file. +## [0.3.0] - 2024-03-22 + +### Changed + +* Pydra 0.23+ compatibility +* Drop Python 3.7 compatibility, test Python 3.12 +* Updates to CI workflows + ## [0.2.2] – 2022-11-22 ### Changed @@ -37,6 +45,7 @@ All notable changes to this project will be documented in this file. - Initial release for PyPI +[0.3.0]: https://github.com/nipype/pydra-nipype1/compare/0.2.2...0.3.0 [0.2.2]: https://github.com/nipype/pydra-nipype1/compare/0.2.1...0.2.2 [0.2.1]: https://github.com/nipype/pydra-nipype1/compare/0.2.0...0.2.1 [0.2.0]: https://github.com/nipype/pydra-nipype1/compare/0.1.0...0.2.0 From 31fdcf194b3ed5a0f333a108d686d258a713c1a7 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 22 Mar 2024 21:56:05 -0400 Subject: [PATCH 12/12] CI: Trigger on release --- .github/workflows/pythonpackage.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 5d52a1d..b4412ac 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -13,6 +13,9 @@ on: branches: [main] pull_request: branches: [main] + release: + types: + - published concurrency: group: ${{ github.workflow }}-${{ github.ref }}