Skip to content

Commit 8a61ef6

Browse files
authored
Merge pull request #35 from nipype/fix/modernize
MNT: Update Python requirements, CI workflows, add Pydra 0.23 compatibility
2 parents 17a95c7 + 21ed472 commit 8a61ef6

File tree

7 files changed

+73
-76
lines changed

7 files changed

+73
-76
lines changed

.github/workflows/publish.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/pythonpackage.yml

Lines changed: 47 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,37 @@ name: Python package
66
# Set once
77
env:
88
SUBPACKAGE: nipype1
9+
FSLCONDA: https://fsl.fmrib.ox.ac.uk/fsldownloads/fslconda/public/
910

1011
on:
1112
push:
12-
branches: [ main ]
13+
branches: [main]
1314
pull_request:
14-
branches: [ main ]
15+
branches: [main]
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
defaults:
22+
run:
23+
shell: bash -el {0}
1524

1625
jobs:
1726
devcheck:
1827
runs-on: ubuntu-latest
1928
strategy:
2029
matrix:
21-
python-version: [ '3.7', '3.11' ] # Check oldest and newest versions
22-
pip-flags: [ '', '--editable' ]
30+
python-version: ["3.8", "3.12"] # Check oldest and newest versions
31+
pip-flags: ["", "--editable"]
2332
pydra:
24-
- 'pydra'
25-
- '--editable git+https://github.com/nipype/pydra.git#egg=pydra'
33+
- "pydra"
34+
- "--editable git+https://github.com/nipype/pydra.git#egg=pydra"
2635

2736
steps:
28-
- uses: actions/checkout@v2
37+
- uses: actions/checkout@v4
2938
- name: Set up Python ${{ matrix.python-version }}
30-
uses: actions/setup-python@v2
39+
uses: actions/setup-python@v5
3140
with:
3241
python-version: ${{ matrix.python-version }}
3342
- name: Install build dependencies
@@ -47,19 +56,24 @@ jobs:
4756
runs-on: ubuntu-latest
4857
strategy:
4958
matrix:
50-
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ]
59+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
5160

5261
steps:
53-
- uses: actions/checkout@v2
62+
- uses: actions/checkout@v4
5463
- name: Set up Python ${{ matrix.python-version }}
55-
uses: actions/setup-python@v2
64+
uses: conda-incubator/setup-miniconda@v3
5665
with:
5766
python-version: ${{ matrix.python-version }}
58-
- name: Set up NeuroDebian
59-
run: bash <(wget -q -O- http://neuro.debian.net/_files/neurodebian-travis.sh)
67+
mamba-version: "*"
68+
channels: ${{ env.FSLCONDA }},conda-forge,defaults
69+
channel-priority: true
6070
- name: Install FSL
61-
run: sudo apt-get install -y fsl
62-
- name: Install build dependencies
71+
run: |
72+
mamba install fsl-avwutils
73+
mamba env config vars set FSLDIR="$CONDA_PREFIX" FSLOUTPUTTYPE="NIFTI_GZ"
74+
# Hack because we're not doing a full FSL install
75+
echo "6.0.7.9" > $CONDA_PREFIX/etc/fslversion
76+
- name: Upgrade pip
6377
run: |
6478
python -m pip install --upgrade pip
6579
- name: Install task package
@@ -69,34 +83,31 @@ jobs:
6983
python -c "import pydra as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')"
7084
- name: Test with pytest
7185
run: |
72-
source /etc/fsl/fsl.sh
7386
pytest -sv --doctest-modules pydra/tasks/$SUBPACKAGE \
7487
--cov pydra.tasks.$SUBPACKAGE --cov-report xml
75-
- uses: codecov/codecov-action@v1
88+
- uses: codecov/codecov-action@v4
7689
if: ${{ always() }}
90+
with:
91+
token: ${{ secrets.CODECOV_TOKEN }}
7792

78-
deploy:
79-
needs: [ devcheck, test ]
93+
build:
8094
runs-on: ubuntu-latest
81-
strategy:
82-
matrix:
83-
python-version: [ '3.9' ]
8495
steps:
85-
- uses: actions/checkout@v2
96+
- uses: actions/checkout@v4
8697
with:
8798
submodules: recursive
8899
fetch-depth: 0
89-
- name: Set up Python ${{ matrix.python-version }}
90-
uses: actions/setup-python@v2
91-
with:
92-
python-version: ${{ matrix.python-version }}
93-
- name: Install build tools
94-
run: python -m pip install build twine
95-
- name: Build source and wheel distributions
96-
run: python -m build
97-
- name: Check distributions
98-
run: twine check dist/*
99-
- uses: actions/upload-artifact@v2
100+
- uses: hynek/build-and-inspect-python-package@v2
101+
102+
deploy:
103+
needs: [build, devcheck, test]
104+
runs-on: ubuntu-latest
105+
permissions:
106+
id-token: write
107+
if: github.repository_owner == 'nipype' && github.event.action == 'published'
108+
steps:
109+
- uses: actions/download-artifact@v4
100110
with:
101-
name: distributions
102-
path: dist/
111+
name: Packages
112+
path: dist
113+
- uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,4 @@ dmypy.json
129129
.pyre/
130130

131131
# Generated by flit_scm
132-
_versions.py
132+
_version.py

pydra/tasks/nipype1/tests/__init__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import sys
2+
from atexit import register
3+
from contextlib import ExitStack
4+
from functools import lru_cache
5+
6+
7+
if sys.version_info < (3, 9):
8+
from importlib_resources import as_file, files
9+
else:
10+
from importlib.resources import as_file, files
11+
12+
_stack = ExitStack()
13+
register(_stack.close)
14+
15+
16+
@lru_cache
17+
def load_resource(anchor, *parts) -> str:
18+
return str(_stack.enter_context(as_file(files(anchor).joinpath(*parts))))

pydra/tasks/nipype1/tests/test_nipype1task.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22
import shutil
3-
from pkg_resources import resource_filename
3+
from . import load_resource
44

55
from nipype.interfaces import fsl
66
import nipype.interfaces.utility as nutil
@@ -12,7 +12,7 @@
1212
def test_isolation(tmp_path):
1313
in_file = tmp_path / "orig/tpms_msk.nii.gz"
1414
in_file.parent.mkdir()
15-
shutil.copyfile(resource_filename("nipype", "testing/data/tpms_msk.nii.gz"), in_file)
15+
shutil.copyfile(load_resource("nipype", "testing/data/tpms_msk.nii.gz"), in_file)
1616

1717
out_dir = tmp_path / "output"
1818
out_dir.mkdir()

pydra/tasks/nipype1/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def traitedspec_to_specinfo(traitedspec):
1111
return pydra.specs.SpecInfo(
1212
name="Inputs",
1313
fields=[
14-
(name, attrs.field(metadata={"help_string": trait.desc}))
14+
(name, attrs.field(metadata={"help_string": trait.desc}, type=ty.Any))
1515
for name, trait in traitedspec.traits().items()
1616
if name in trait_names
1717
],
@@ -27,11 +27,11 @@ class Nipype1Task(pydra.engine.task.TaskBase):
2727
in Pydra Task outputs.
2828
2929
>>> import pytest
30-
>>> from pkg_resources import resource_filename
30+
>>> from pydra.tasks.nipype1.tests import load_resource
3131
>>> from nipype.interfaces import fsl
3232
>>> if fsl.Info.version() is None:
3333
... pytest.skip()
34-
>>> img = resource_filename('nipype', 'testing/data/tpms_msk.nii.gz')
34+
>>> img = load_resource('nipype', 'testing/data/tpms_msk.nii.gz')
3535
3636
>>> from pydra.tasks.nipype1.utils import Nipype1Task
3737
>>> thresh = Nipype1Task(fsl.Threshold())
@@ -68,7 +68,7 @@ def __init__(
6868
)
6969
self.output_spec = traitedspec_to_specinfo(interface._outputs())
7070

71-
def _run_task(self):
71+
def _run_task(self, environment=None):
7272
inputs = attrs.asdict(self.inputs, filter=lambda a, v: v is not attrs.NOTHING)
7373
node = nipype.Node(self._interface, base_dir=self.output_dir, name=self.name)
7474
node.inputs.trait_set(**inputs)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "flit_scm:buildapi"
66
name = "pydra-nipype1"
77
description = "Tools for importing nipype 1.x interfaces into Pydra"
88
readme = "README.md"
9-
requires-python = ">=3.7"
9+
requires-python = ">=3.8"
1010
dependencies = [
1111
"pydra >=0.6.2",
1212
"nipype",

0 commit comments

Comments
 (0)