From be62b033634e78a6800be4a480372651182aa26e Mon Sep 17 00:00:00 2001 From: Tom Close Date: Sat, 18 May 2024 20:13:08 +1000 Subject: [PATCH 01/23] fixed up fileformats deps --- related-packages/fileformats/pyproject.toml | 34 +++++---------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/related-packages/fileformats/pyproject.toml b/related-packages/fileformats/pyproject.toml index d26d786..d148dc1 100644 --- a/related-packages/fileformats/pyproject.toml +++ b/related-packages/fileformats/pyproject.toml @@ -7,21 +7,11 @@ name = "fileformats-medimage-afni" description = "Classes for representing different file formats in Python classes for use in type hinting in data workflows" readme = "README.rst" requires-python = ">=3.8" -dependencies = [ - "fileformats >= 0.4", - "fileformats-medimage >= 0.2" -] -license = {file = "LICENSE"} -authors = [ - {name = "Thomas G. Close", email = "tom.g.close@gmail.com"}, -] -maintainers = [ - {name = "Thomas G. Close", email = "tom.g.close@gmail.com"}, -] -keywords = [ - "file formats", - "data", -] +dependencies = ["fileformats >= 0.4", "fileformats-medimage >= 0.2"] +license = { file = "LICENSE" } +authors = [{ name = "Thomas G. Close", email = "tom.g.close@gmail.com" }] +maintainers = [{ name = "Thomas G. Close", email = "tom.g.close@gmail.com" }] +keywords = ["file formats", "data"] classifiers = [ "Development Status :: 3 - Alpha", "Environment :: Console", @@ -39,19 +29,13 @@ classifiers = [ dynamic = ["version"] [project.optional-dependencies] -dev = [ - "black", - "pre-commit", - "codespell", - "flake8", - "flake8-pyproject", -] +dev = ["black", "pre-commit", "codespell", "flake8", "flake8-pyproject"] test = [ "pytest >=6.2.5", "pytest-env>=0.6.2", "pytest-cov>=2.12.1", "codecov", - "fileformats-medimage-CHANGME-extras", + "fileformats-medimage-afni-extras", ] [project.urls] @@ -76,9 +60,7 @@ ignore-words = ".codespell-ignorewords" [tool.flake8] doctests = true -per-file-ignores = [ - "__init__.py:F401" -] +per-file-ignores = ["__init__.py:F401"] max-line-length = 88 select = "C,E,F,W,B,B950" extend-ignore = ['E203', 'E501', 'E129'] From a01349510967e73fb27f64635e82747501a7e71a Mon Sep 17 00:00:00 2001 From: Tom Close Date: Sat, 18 May 2024 22:26:36 +1000 Subject: [PATCH 02/23] added version imports to fileformats --- .../fileformats/extras/medimage_afni/__init__.py | 2 ++ .../fileformats/fileformats/medimage_afni/__init__.py | 1 + 2 files changed, 3 insertions(+) diff --git a/related-packages/fileformats-extras/fileformats/extras/medimage_afni/__init__.py b/related-packages/fileformats-extras/fileformats/extras/medimage_afni/__init__.py index 38f073f..1d9732a 100644 --- a/related-packages/fileformats-extras/fileformats/extras/medimage_afni/__init__.py +++ b/related-packages/fileformats-extras/fileformats/extras/medimage_afni/__init__.py @@ -15,6 +15,8 @@ Unit errts+tlrc, Gii, ) +from ._version import __version__ + diff --git a/related-packages/fileformats/fileformats/medimage_afni/__init__.py b/related-packages/fileformats/fileformats/medimage_afni/__init__.py index 87e2dfe..5515d4a 100644 --- a/related-packages/fileformats/fileformats/medimage_afni/__init__.py +++ b/related-packages/fileformats/fileformats/medimage_afni/__init__.py @@ -1,4 +1,5 @@ from fileformats.generic import File +from ._version import __version__ class OneD(File): ext = ".1D" From ee3741c7b327d2f8b77438b47bb00c588f0e85a4 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Sat, 18 May 2024 22:35:25 +1000 Subject: [PATCH 03/23] fixed up fileformats --- .../extras/medimage_afni/__init__.py | 32 ++++--------------- .../fileformats/medimage_afni/__init__.py | 2 +- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/related-packages/fileformats-extras/fileformats/extras/medimage_afni/__init__.py b/related-packages/fileformats-extras/fileformats/extras/medimage_afni/__init__.py index 1d9732a..66c7315 100644 --- a/related-packages/fileformats-extras/fileformats/extras/medimage_afni/__init__.py +++ b/related-packages/fileformats-extras/fileformats/extras/medimage_afni/__init__.py @@ -3,17 +3,13 @@ from random import Random from fileformats.core import FileSet from fileformats.medimage_afni import ( - Oned, + OneD, Dset, - Nii[0], - Threed, + ThreeD, Head, - Ncorr, + NCorr, R1, All1, - Oned, - Unit errts+tlrc, - Gii, ) from ._version import __version__ @@ -21,7 +17,7 @@ @FileSet.generate_sample_data.register -def gen_sample_oned_data(oned: Oned, dest_dir: Path, seed: ty.Union[int, Random], stem: ty.Optional[str]): +def gen_sample_oned_data(oned: OneD, dest_dir: Path, seed: ty.Union[int, Random], stem: ty.Optional[str]): raise NotImplementedError @@ -31,12 +27,7 @@ def gen_sample_dset_data(dset: Dset, dest_dir: Path, seed: ty.Union[int, Random] @FileSet.generate_sample_data.register -def gen_sample_nii[0]_data(nii[0]: Nii[0], dest_dir: Path, seed: ty.Union[int, Random], stem: ty.Optional[str]): - raise NotImplementedError - - -@FileSet.generate_sample_data.register -def gen_sample_threed_data(threed: Threed, dest_dir: Path, seed: ty.Union[int, Random], stem: ty.Optional[str]): +def gen_sample_threed_data(threed: ThreeD, dest_dir: Path, seed: ty.Union[int, Random], stem: ty.Optional[str]): raise NotImplementedError @@ -46,7 +37,7 @@ def gen_sample_head_data(head: Head, dest_dir: Path, seed: ty.Union[int, Random] @FileSet.generate_sample_data.register -def gen_sample_ncorr_data(ncorr: Ncorr, dest_dir: Path, seed: ty.Union[int, Random], stem: ty.Optional[str]): +def gen_sample_ncorr_data(ncorr: NCorr, dest_dir: Path, seed: ty.Union[int, Random], stem: ty.Optional[str]): raise NotImplementedError @@ -61,15 +52,6 @@ def gen_sample_all1_data(all1: All1, dest_dir: Path, seed: ty.Union[int, Random] @FileSet.generate_sample_data.register -def gen_sample_oned_data(oned: Oned, dest_dir: Path, seed: ty.Union[int, Random], stem: ty.Optional[str]): +def gen_sample_oned_data(oned: OneD, dest_dir: Path, seed: ty.Union[int, Random], stem: ty.Optional[str]): raise NotImplementedError - -@FileSet.generate_sample_data.register -def gen_sample_unit errts+tlrc_data(unit errts+tlrc: Unit errts+tlrc, dest_dir: Path, seed: ty.Union[int, Random], stem: ty.Optional[str]): - raise NotImplementedError - - -@FileSet.generate_sample_data.register -def gen_sample_gii_data(gii: Gii, dest_dir: Path, seed: ty.Union[int, Random], stem: ty.Optional[str]): - raise NotImplementedError diff --git a/related-packages/fileformats/fileformats/medimage_afni/__init__.py b/related-packages/fileformats/fileformats/medimage_afni/__init__.py index 5515d4a..cfc3154 100644 --- a/related-packages/fileformats/fileformats/medimage_afni/__init__.py +++ b/related-packages/fileformats/fileformats/medimage_afni/__init__.py @@ -22,7 +22,7 @@ class Head(File): binary = True -class Ncorr(File): +class NCorr(File): ext = ".ncorr" binary = True From abd140e2e73e248f876f22d55275a308ca7216aa Mon Sep 17 00:00:00 2001 From: Tom Close Date: Sat, 18 May 2024 22:40:58 +1000 Subject: [PATCH 04/23] fixed up fileformats again --- nipype-auto-conv/specs/interfaces/net_corr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nipype-auto-conv/specs/interfaces/net_corr.yaml b/nipype-auto-conv/specs/interfaces/net_corr.yaml index 5b04d5e..5cfbbc4 100644 --- a/nipype-auto-conv/specs/interfaces/net_corr.yaml +++ b/nipype-auto-conv/specs/interfaces/net_corr.yaml @@ -49,7 +49,7 @@ inputs: # type=file|default=: can include a whole brain mask within which to calculate correlation. Otherwise, data should be masked already weight_ts: generic/file # type=file|default=: input a 1D file WTS of weights that will be applied multiplicatively to each ROI's average time series. WTS can be a column- or row-file of values, but it must have the same length as the input time series volume. If the initial average time series was A[n] for n=0,..,(N-1) time points, then applying a set of weights W[n] of the same length from WTS would produce a new time series: B[n] = A[n] * W[n] - out_file: medimage-afni/ncorr + out_file: medimage-afni/n-corr # type=file|default=: output file name part metadata: # dict[str, dict[str, any]] - additional metadata to set on any of the input fields (e.g. out_file: position: 1) From 33b60cb0c7fe669143538e295bd73e08870fb7f7 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Sat, 18 May 2024 22:43:43 +1000 Subject: [PATCH 05/23] fixed up fileformats --- .github/workflows/ci-cd.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml index c00af6b..4cfc58b 100644 --- a/.github/workflows/ci-cd.yaml +++ b/.github/workflows/ci-cd.yaml @@ -107,7 +107,7 @@ jobs: python -c "import fileformats.medimage_afni as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')" - name: Test fileformats with pytest run: | - cd ./fileformats + cd ./related-packages/fileformats pytest -sv --cov fileformats.medimage_afni --cov fileformats.extras.medimage_afni --cov-report xml . test: From 1d798badbac0981e1a24fbe4ae37c6a9be3c558b Mon Sep 17 00:00:00 2001 From: Tom Close Date: Sat, 18 May 2024 22:50:21 +1000 Subject: [PATCH 06/23] touched up ci-cd --- .github/workflows/ci-cd.yaml | 52 ++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml index 4cfc58b..1f959a6 100644 --- a/.github/workflows/ci-cd.yaml +++ b/.github/workflows/ci-cd.yaml @@ -84,34 +84,34 @@ jobs: python -c "import fileformats.medimage_afni as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')" python -c "import fileformats.extras.medimage_afni as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')" - fileformats-test: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ['3.8', '3.11'] - steps: - - uses: actions/checkout@v3 - - name: Revert version to most recent tag on upstream update - if: github.event_name == 'repository_dispatch' - run: git checkout $(git tag -l | tail -n 1 | awk -F post '{print $1}') - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install build dependencies - run: | - python -m pip install --upgrade pip - - name: Install task package - run: | - pip install "./related-packages/fileformats[test]" "./related-packages/fileformats-extras[test]" - python -c "import fileformats.medimage_afni as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')" - - name: Test fileformats with pytest - run: | - cd ./related-packages/fileformats - pytest -sv --cov fileformats.medimage_afni --cov fileformats.extras.medimage_afni --cov-report xml . + # fileformats-test: + # runs-on: ubuntu-latest + # strategy: + # matrix: + # python-version: ['3.8', '3.11'] + # steps: + # - uses: actions/checkout@v3 + # - name: Revert version to most recent tag on upstream update + # if: github.event_name == 'repository_dispatch' + # run: git checkout $(git tag -l | tail -n 1 | awk -F post '{print $1}') + # - name: Set up Python ${{ matrix.python-version }} + # uses: actions/setup-python@v4 + # with: + # python-version: ${{ matrix.python-version }} + # - name: Install build dependencies + # run: | + # python -m pip install --upgrade pip + # - name: Install task package + # run: | + # pip install "./related-packages/fileformats[test]" "./related-packages/fileformats-extras[test]" + # python -c "import fileformats.medimage_afni as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')" + # - name: Test fileformats with pytest + # run: | + # cd ./related-packages/fileformats + # pytest -sv --cov fileformats.medimage_afni --cov fileformats.extras.medimage_afni --cov-report xml . test: - needs: [nipype-conv, fileformats-test] + needs: [nipype-conv] runs-on: ubuntu-22.04 strategy: matrix: From 08ff445258caabe30f01e9fb3f032d63756dedc7 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Sat, 18 May 2024 23:17:57 +1000 Subject: [PATCH 07/23] fixed up fileset generators --- .../extras/medimage_afni/__init__.py | 27 ++++++------------- .../fileformats/medimage_afni/__init__.py | 6 ++--- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/related-packages/fileformats-extras/fileformats/extras/medimage_afni/__init__.py b/related-packages/fileformats-extras/fileformats/extras/medimage_afni/__init__.py index 66c7315..204d50e 100644 --- a/related-packages/fileformats-extras/fileformats/extras/medimage_afni/__init__.py +++ b/related-packages/fileformats-extras/fileformats/extras/medimage_afni/__init__.py @@ -1,7 +1,4 @@ -from pathlib import Path -import typing as ty -from random import Random -from fileformats.core import FileSet +from fileformats.core import FileSet, SampleFileGenerator from fileformats.medimage_afni import ( OneD, Dset, @@ -14,44 +11,36 @@ from ._version import __version__ - - @FileSet.generate_sample_data.register -def gen_sample_oned_data(oned: OneD, dest_dir: Path, seed: ty.Union[int, Random], stem: ty.Optional[str]): +def gen_sample_oned_data(oned: OneD, generator: SampleFileGenerator): raise NotImplementedError @FileSet.generate_sample_data.register -def gen_sample_dset_data(dset: Dset, dest_dir: Path, seed: ty.Union[int, Random], stem: ty.Optional[str]): +def gen_sample_dset_data(dset: Dset, generator: SampleFileGenerator): raise NotImplementedError @FileSet.generate_sample_data.register -def gen_sample_threed_data(threed: ThreeD, dest_dir: Path, seed: ty.Union[int, Random], stem: ty.Optional[str]): +def gen_sample_threed_data(threed: ThreeD, generator: SampleFileGenerator): raise NotImplementedError @FileSet.generate_sample_data.register -def gen_sample_head_data(head: Head, dest_dir: Path, seed: ty.Union[int, Random], stem: ty.Optional[str]): +def gen_sample_head_data(head: Head, generator: SampleFileGenerator): raise NotImplementedError @FileSet.generate_sample_data.register -def gen_sample_ncorr_data(ncorr: NCorr, dest_dir: Path, seed: ty.Union[int, Random], stem: ty.Optional[str]): +def gen_sample_ncorr_data(ncorr: NCorr, generator: SampleFileGenerator): raise NotImplementedError @FileSet.generate_sample_data.register -def gen_sample_r1_data(r1: R1, dest_dir: Path, seed: ty.Union[int, Random], stem: ty.Optional[str]): +def gen_sample_r1_data(r1: R1, generator: SampleFileGenerator): raise NotImplementedError @FileSet.generate_sample_data.register -def gen_sample_all1_data(all1: All1, dest_dir: Path, seed: ty.Union[int, Random], stem: ty.Optional[str]): +def gen_sample_all1_data(all1: All1, generator: SampleFileGenerator): raise NotImplementedError - - -@FileSet.generate_sample_data.register -def gen_sample_oned_data(oned: OneD, dest_dir: Path, seed: ty.Union[int, Random], stem: ty.Optional[str]): - raise NotImplementedError - diff --git a/related-packages/fileformats/fileformats/medimage_afni/__init__.py b/related-packages/fileformats/fileformats/medimage_afni/__init__.py index cfc3154..1741f42 100644 --- a/related-packages/fileformats/fileformats/medimage_afni/__init__.py +++ b/related-packages/fileformats/fileformats/medimage_afni/__init__.py @@ -1,5 +1,6 @@ from fileformats.generic import File -from ._version import __version__ +from ._version import __version__ # noqa + class OneD(File): ext = ".1D" @@ -17,6 +18,7 @@ class ThreeD(File): binary = True alternate_exts = (".3d",) + class Head(File): ext = ".HEAD" binary = True @@ -35,5 +37,3 @@ class R1(File): class All1(File): ext = ".all1" binary = True - - From a1d6657fb0ac5d6b175297cdd74de86e88e8a4a2 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Sat, 18 May 2024 23:27:53 +1000 Subject: [PATCH 08/23] deleted freesurfer install from ci-cd --- .github/workflows/ci-cd.yaml | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml index 1f959a6..5b6f90d 100644 --- a/.github/workflows/ci-cd.yaml +++ b/.github/workflows/ci-cd.yaml @@ -121,35 +121,8 @@ jobs: run: | sudo rm -rf /usr/share/dotnet sudo rm -rf "$AGENT_TOOLSDIRECTORY" - - name: Get Download cache Key - id: cache-key - run: echo "::set-output name=key::afni-linux-ubuntu22_amd64-7.4.1" - - name: Cache FreeSurfer - uses: actions/cache@v2 - with: - path: $HOME/downloads/afni - key: ${{ steps.cache-key.outputs.key }} - restore-keys: | - afni-linux-ubuntu22_amd64-7.4.1 - - name: Download FreeSurfer - if: steps.cache-key.outputs.key != steps.cache-hit.outputs.key - run: | - mkdir -p $HOME/downloads/afni - curl -s -o $HOME/downloads/afni/afni-linux-ubuntu22_amd64-7.4.1.tar.gz https://surfer.nmr.mgh.harvard.edu/pub/dist/afni/7.4.1/afni-linux-ubuntu22_amd64-7.4.1.tar.gz - shell: bash - - name: Install Freesurfer - env: - FREESURFER_LICENCE: ${{ secrets.FREESURFER_LICENCE }} - run: | - pushd $HOME/downloads/afni - tar -zxpf afni-linux-ubuntu22_amd64-7.4.1.tar.gz - mv afni $HOME/ - popd - export FREESURFER_HOME=$HOME/afni - source $FREESURFER_HOME/SetUpFreeSurfer.sh - echo $FREESURFER_LICENCE > $FREESURFER_HOME/license.txt - export PATH=$FREESURFER_HOME/bin:$PATH - - uses: actions/checkout@v3 + + - uses: actions/checkout@v4 - name: Revert version to most recent tag on upstream update if: github.event_name == 'repository_dispatch' run: git checkout $(git tag -l | tail -n 1 | awk -F post '{print $1}') From 2bc73d6474434dffd16205f448e5e455b90e5d45 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Sat, 18 May 2024 23:29:42 +1000 Subject: [PATCH 09/23] more touch ups of fileformats --- .../extras/medimage_afni/__init__.py | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/related-packages/fileformats-extras/fileformats/extras/medimage_afni/__init__.py b/related-packages/fileformats-extras/fileformats/extras/medimage_afni/__init__.py index 204d50e..8deca1e 100644 --- a/related-packages/fileformats-extras/fileformats/extras/medimage_afni/__init__.py +++ b/related-packages/fileformats-extras/fileformats/extras/medimage_afni/__init__.py @@ -1,3 +1,5 @@ +import typing as ty +from pathlib import Path from fileformats.core import FileSet, SampleFileGenerator from fileformats.medimage_afni import ( OneD, @@ -12,35 +14,47 @@ @FileSet.generate_sample_data.register -def gen_sample_oned_data(oned: OneD, generator: SampleFileGenerator): +def gen_sample_oned_data( + oned: OneD, generator: SampleFileGenerator +) -> ty.Iterable[Path]: raise NotImplementedError @FileSet.generate_sample_data.register -def gen_sample_dset_data(dset: Dset, generator: SampleFileGenerator): +def gen_sample_dset_data( + dset: Dset, generator: SampleFileGenerator +) -> ty.Iterable[Path]: raise NotImplementedError @FileSet.generate_sample_data.register -def gen_sample_threed_data(threed: ThreeD, generator: SampleFileGenerator): +def gen_sample_threed_data( + threed: ThreeD, generator: SampleFileGenerator +) -> ty.Iterable[Path]: raise NotImplementedError @FileSet.generate_sample_data.register -def gen_sample_head_data(head: Head, generator: SampleFileGenerator): +def gen_sample_head_data( + head: Head, generator: SampleFileGenerator +) -> ty.Iterable[Path]: raise NotImplementedError @FileSet.generate_sample_data.register -def gen_sample_ncorr_data(ncorr: NCorr, generator: SampleFileGenerator): +def gen_sample_ncorr_data( + ncorr: NCorr, generator: SampleFileGenerator +) -> ty.Iterable[Path]: raise NotImplementedError @FileSet.generate_sample_data.register -def gen_sample_r1_data(r1: R1, generator: SampleFileGenerator): +def gen_sample_r1_data(r1: R1, generator: SampleFileGenerator) -> ty.Iterable[Path]: raise NotImplementedError @FileSet.generate_sample_data.register -def gen_sample_all1_data(all1: All1, generator: SampleFileGenerator): +def gen_sample_all1_data( + all1: All1, generator: SampleFileGenerator +) -> ty.Iterable[Path]: raise NotImplementedError From be431c4dd165e2df088d70b6988d16dd7deaef99 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Sat, 18 May 2024 23:50:03 +1000 Subject: [PATCH 10/23] fixed up dependencies --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 4b96265..6f0f3e3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,6 +44,7 @@ doc = [ "sphinxcontrib-versioning", ] test = [ + "nipype2pydra", "pytest >= 4.4.0", "pytest-cov", "pytest-env", From 10289d1a7c5eebc2b890944bc9f22cd7faf0974f Mon Sep 17 00:00:00 2001 From: Tom Close Date: Sat, 18 May 2024 23:50:54 +1000 Subject: [PATCH 11/23] more deps --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6f0f3e3..f42078c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,8 @@ dependencies = [ "fileformats >=0.8.3", "fileformats-datascience >=0.1", "fileformats-medimage >=0.4.1", - "fileformats-medimage-afni" + "fileformats-medimage-afni", + "looseversion" ] license = {file = "LICENSE"} authors = [{name = "Nipype developers", email = "neuroimaging@python.org"}] From 6646979f60b8bc4d1b105f7a670e3302f29afc48 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Mon, 20 May 2024 10:33:35 +1000 Subject: [PATCH 12/23] fixed up version handling in package __init__ --- pydra/tasks/afni/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pydra/tasks/afni/__init__.py b/pydra/tasks/afni/__init__.py index 993f5b2..b209d29 100644 --- a/pydra/tasks/afni/__init__.py +++ b/pydra/tasks/afni/__init__.py @@ -19,15 +19,16 @@ ) if "nipype" not in __version__: try: - from .auto._version import nipype_version, nipype2pydra_version - except ImportError: + from .auto._post_release import src_pkg_version, nipype2pydra_version + except ImportError as e: + raise e warn( "Nipype interfaces haven't been automatically converted from their specs in " f"`nipype-auto-conv`. Please run `{str(pkg_path / 'nipype-auto-conv' / 'generate')}` " "to generated the converted Nipype interfaces in pydra.tasks.afni.auto" ) else: - n_ver = nipype_version.replace(".", "_") + n_ver = src_pkg_version.replace(".", "_") n2p_ver = nipype2pydra_version.replace(".", "_") __version__ += ( "_" if "+" in __version__ else "+" From bbf417508312cca2631cac56e06e777b4f375964 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Mon, 20 May 2024 10:41:56 +1000 Subject: [PATCH 13/23] touching up ci-cd and version handling --- .github/workflows/ci-cd.yaml | 56 +++++++++++++++++++----------------- pydra/tasks/afni/__init__.py | 4 +-- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml index 5b6f90d..c3568ea 100644 --- a/.github/workflows/ci-cd.yaml +++ b/.github/workflows/ci-cd.yaml @@ -43,7 +43,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.8', '3.11'] # Check oldest and newest versions + python-version: ['3.8', '3.12'] # Check oldest and newest versions pip-flags: ['', '--editable'] pydra: - 'pydra' @@ -84,38 +84,38 @@ jobs: python -c "import fileformats.medimage_afni as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')" python -c "import fileformats.extras.medimage_afni as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')" - # fileformats-test: - # runs-on: ubuntu-latest - # strategy: - # matrix: - # python-version: ['3.8', '3.11'] - # steps: - # - uses: actions/checkout@v3 - # - name: Revert version to most recent tag on upstream update - # if: github.event_name == 'repository_dispatch' - # run: git checkout $(git tag -l | tail -n 1 | awk -F post '{print $1}') - # - name: Set up Python ${{ matrix.python-version }} - # uses: actions/setup-python@v4 - # with: - # python-version: ${{ matrix.python-version }} - # - name: Install build dependencies - # run: | - # python -m pip install --upgrade pip - # - name: Install task package - # run: | - # pip install "./related-packages/fileformats[test]" "./related-packages/fileformats-extras[test]" - # python -c "import fileformats.medimage_afni as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')" - # - name: Test fileformats with pytest - # run: | - # cd ./related-packages/fileformats - # pytest -sv --cov fileformats.medimage_afni --cov fileformats.extras.medimage_afni --cov-report xml . + fileformats-test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.8', '3.12'] + steps: + - uses: actions/checkout@v3 + - name: Revert version to most recent tag on upstream update + if: github.event_name == 'repository_dispatch' + run: git checkout $(git tag -l | tail -n 1 | awk -F post '{print $1}') + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install build dependencies + run: | + python -m pip install --upgrade pip + - name: Install task package + run: | + pip install "./related-packages/fileformats[test]" "./related-packages/fileformats-extras[test]" + python -c "import fileformats.medimage_afni as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')" + - name: Test fileformats with pytest + run: >- + pytest ./related-packages/fileformats -sv --cov fileformats.medimage_afni + --cov fileformats.extras.medimage_afni --cov-report xml . test: needs: [nipype-conv] runs-on: ubuntu-22.04 strategy: matrix: - python-version: ['3.8'] # '3.11' + python-version: ['3.8', '3.12'] steps: - name: Removed unnecessary tools to free space run: | @@ -131,6 +131,8 @@ jobs: with: name: converted-nipype path: pydra/tasks/afni/auto + - name: Show package contents + run: tree ./pydra - name: Strip auto package from gitignore so it is included in package run: | sed -i '/\/src\/pydra\/tasks\/afni\/auto/d' .gitignore diff --git a/pydra/tasks/afni/__init__.py b/pydra/tasks/afni/__init__.py index b209d29..89ab108 100644 --- a/pydra/tasks/afni/__init__.py +++ b/pydra/tasks/afni/__init__.py @@ -5,6 +5,7 @@ >>> import pydra.engine >>> import pydra.tasks.afni """ + from warnings import warn from pathlib import Path @@ -20,8 +21,7 @@ if "nipype" not in __version__: try: from .auto._post_release import src_pkg_version, nipype2pydra_version - except ImportError as e: - raise e + except ImportError: warn( "Nipype interfaces haven't been automatically converted from their specs in " f"`nipype-auto-conv`. Please run `{str(pkg_path / 'nipype-auto-conv' / 'generate')}` " From 2be7805718c55c0dcdad2286b8d44665fbf4e2fa Mon Sep 17 00:00:00 2001 From: Tom Close Date: Mon, 20 May 2024 10:47:49 +1000 Subject: [PATCH 14/23] touched up ci-cd --- .github/workflows/ci-cd.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml index c3568ea..728f165 100644 --- a/.github/workflows/ci-cd.yaml +++ b/.github/workflows/ci-cd.yaml @@ -107,7 +107,7 @@ jobs: python -c "import fileformats.medimage_afni as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')" - name: Test fileformats with pytest run: >- - pytest ./related-packages/fileformats -sv --cov fileformats.medimage_afni + pytest ./related-packages -sv --cov fileformats.medimage_afni --cov fileformats.extras.medimage_afni --cov-report xml . test: @@ -150,8 +150,7 @@ jobs: python -c "import pydra as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')" - name: Test with pytest run: | - pytest -sv --doctest-modules ./pydra/tasks/afni \ - --cov pydra.tasks.afni --cov-report xml + pytest -sv ./pydra/tasks/afni --cov pydra.tasks.afni --cov-report xml - uses: codecov/codecov-action@v3 if: ${{ always() }} with: From 62bf0fc10852c8862658026215c6f480c7785568 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Mon, 20 May 2024 10:54:45 +1000 Subject: [PATCH 15/23] added fileformats tests --- .../tests/test_generate_sample_data.py | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 related-packages/fileformats-extras/fileformats/extras/medimage_afni/tests/test_generate_sample_data.py diff --git a/related-packages/fileformats-extras/fileformats/extras/medimage_afni/tests/test_generate_sample_data.py b/related-packages/fileformats-extras/fileformats/extras/medimage_afni/tests/test_generate_sample_data.py new file mode 100644 index 0000000..2264b1f --- /dev/null +++ b/related-packages/fileformats-extras/fileformats/extras/medimage_afni/tests/test_generate_sample_data.py @@ -0,0 +1,45 @@ +import pytest +from fileformats.medimage_anfi import ( + OneD, + Dset, + ThreeD, + Head, + NCorr, + R1, + All1, +) + + +@pytest.mark.xfail(reason="generate_sample_data not implemented") +def test_generate_one_d_data(): + assert isinstance(OneD.sample(), OneD) + + +@pytest.mark.xfail(reason="generate_sample_data not implemented") +def test_generate_three_d_data(): + assert isinstance(ThreeD.sample(), ThreeD) + + +@pytest.mark.xfail(reason="generate_sample_data not implemented") +def test_generate_dset_data(): + assert isinstance(Dset.sample(), Dset) + + +@pytest.mark.xfail(reason="generate_sample_data not implemented") +def test_generate_head_data(): + assert isinstance(Head.sample(), Head) + + +@pytest.mark.xfail(reason="generate_sample_data not implemented") +def test_generate_ncorr_data(): + assert isinstance(NCorr.sample(), NCorr) + + +@pytest.mark.xfail(reason="generate_sample_data not implemented") +def test_generate_r1_data(): + assert isinstance(R1.sample(), R1) + + +@pytest.mark.xfail(reason="generate_sample_data not implemented") +def test_generate_all1_data(): + assert isinstance(All1.sample(), All1) From 198951366ca82303b4689ed06a389b54ba939fba Mon Sep 17 00:00:00 2001 From: Tom Close Date: Mon, 20 May 2024 10:58:55 +1000 Subject: [PATCH 16/23] debugging ci-cd --- .github/workflows/ci-cd.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml index 728f165..c6b5b23 100644 --- a/.github/workflows/ci-cd.yaml +++ b/.github/workflows/ci-cd.yaml @@ -80,6 +80,7 @@ jobs: pip install "./related-packages/fileformats[dev]" "related-packages/fileformats-extras[dev]" pip install ${{ matrix.pip-flags }} ".[dev]" python -c "import pydra.tasks.afni as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')" + python -c "import pydra.tasks.afni.auto as m; print(f'{m.__name__} @ {m.__file__}')" python -c "import pydra as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')" python -c "import fileformats.medimage_afni as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')" python -c "import fileformats.extras.medimage_afni as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')" @@ -147,6 +148,7 @@ jobs: run: | pip install "./related-packages/fileformats" "./related-packages/fileformats-extras" ".[test]" python -c "import pydra.tasks.afni as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')" + python -c "import pydra.tasks.afni.auto as m; print(f'{m.__name__} @ {m.__file__}')" python -c "import pydra as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')" - name: Test with pytest run: | From 0ed9c8311101d1cdc1d1e49312a4ee3ebb0f859e Mon Sep 17 00:00:00 2001 From: Tom Close Date: Mon, 20 May 2024 11:07:53 +1000 Subject: [PATCH 17/23] fixed up fileformats afni import --- .../extras/medimage_afni/tests/test_generate_sample_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/related-packages/fileformats-extras/fileformats/extras/medimage_afni/tests/test_generate_sample_data.py b/related-packages/fileformats-extras/fileformats/extras/medimage_afni/tests/test_generate_sample_data.py index 2264b1f..d436d21 100644 --- a/related-packages/fileformats-extras/fileformats/extras/medimage_afni/tests/test_generate_sample_data.py +++ b/related-packages/fileformats-extras/fileformats/extras/medimage_afni/tests/test_generate_sample_data.py @@ -1,5 +1,5 @@ import pytest -from fileformats.medimage_anfi import ( +from fileformats.medimage_afni import ( OneD, Dset, ThreeD, From c2d05ebca519955e3f78d3977dbc574e52cec293 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Mon, 20 May 2024 11:20:45 +1000 Subject: [PATCH 18/23] copying across some updates to ci-cd from pydra-ants --- .github/workflows/ci-cd.yaml | 62 +++++++++++++++++++++++++----------- .gitignore | 1 - 2 files changed, 43 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml index c6b5b23..6a35b6e 100644 --- a/.github/workflows/ci-cd.yaml +++ b/.github/workflows/ci-cd.yaml @@ -9,31 +9,46 @@ name: CI/CD on: push: branches: [ main, develop ] - tags: [ '*' ] pull_request: branches: [ main, develop ] + release: + types: [published] repository_dispatch: - types: [create-release] + types: [create-post-release] + +permissions: + contents: read + pages: write + id-token: write jobs: nipype-conv: runs-on: ubuntu-latest steps: + - name: Checkout - uses: actions/checkout@v3 - - name: Revert version to most recent tag on upstream update + uses: actions/checkout@v4 + + - name: Revert version to most recent version tag on upstream update if: github.event_name == 'repository_dispatch' - run: git checkout $(git tag -l | tail -n 1 | awk -F post '{print $1}') - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + run: git checkout $(git tag -l | grep 'v.*' | tail -n 1 | awk -F post '{print $1}') + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Install build dependencies run: python -m pip install --upgrade pip + - name: Install requirements - run: python -m pip install ./related-packages/fileformats -r ./nipype-auto-conv/requirements.txt + run: python -m pip install -r ./nipype-auto-conv/requirements.txt + - name: Run automatic Nipype > Pydra conversion run: ./nipype-auto-conv/generate - - uses: actions/upload-artifact@v3 + + - uses: actions/upload-artifact@v4 with: name: converted-nipype path: pydra/tasks/afni/auto @@ -50,31 +65,37 @@ jobs: - '--editable git+https://github.com/nipype/pydra.git#egg=pydra' steps: - name: Checkout - uses: actions/checkout@v3 - - name: Revert version to most recent tag on upstream update + uses: actions/checkout@v4 + + - name: Revert version to most recent version tag on Nipype or Nipype2Pydra update if: github.event_name == 'repository_dispatch' - run: git checkout $(git tag -l | tail -n 1 | awk -F post '{print $1}') - - name: Download tasks converted from Nipype - uses: actions/download-artifact@v3 + run: git checkout $(git tag -l | grep 'v.*' | tail -n 1 | awk -F post '{print $1}') + + - name: Download tasks converted from Nipype + uses: actions/download-artifact@v4 with: name: converted-nipype path: pydra/tasks/afni/auto - name: Strip auto package from gitignore so it is included in package run: | sed -i '/\/pydra\/tasks\/afni\/auto/d' .gitignore + sed -i '/^_version.py/d' .gitignore - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + - name: Install build dependencies run: | python -m pip install --upgrade pip + - name: Install Pydra run: | pushd $HOME pip install ${{ matrix.pydra }} popd python -c "import pydra as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')" + - name: Install task package run: | pip install "./related-packages/fileformats[dev]" "related-packages/fileformats-extras[dev]" @@ -126,9 +147,10 @@ jobs: - uses: actions/checkout@v4 - name: Revert version to most recent tag on upstream update if: github.event_name == 'repository_dispatch' - run: git checkout $(git tag -l | tail -n 1 | awk -F post '{print $1}') - - name: Download tasks converted from Nipype - uses: actions/download-artifact@v3 + run: git checkout $(git tag -l | grep 'v.*' | tail -n 1 | awk -F post '{print $1}') + + - name: Download tasks converted from Nipype + uses: actions/download-artifact@v4 with: name: converted-nipype path: pydra/tasks/afni/auto @@ -138,12 +160,14 @@ jobs: run: | sed -i '/\/src\/pydra\/tasks\/afni\/auto/d' .gitignore - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + - name: Install build dependencies run: | python -m pip install --upgrade pip + - name: Install task package run: | pip install "./related-packages/fileformats" "./related-packages/fileformats-extras" ".[test]" diff --git a/.gitignore b/.gitignore index 36ae412..7f12be7 100644 --- a/.gitignore +++ b/.gitignore @@ -138,6 +138,5 @@ dmypy.json .DS_store /pydra/tasks/afni/auto -/pydra/tasks/afni/nipype_ports /pydra/tasks/afni/_version.py /related-packages/**/_version.py \ No newline at end of file From fe34622a2922498154216ec3b6c81b08691b682a Mon Sep 17 00:00:00 2001 From: Tom Close Date: Mon, 20 May 2024 11:23:37 +1000 Subject: [PATCH 19/23] added fileformats to nipype-conv ci --- .github/workflows/ci-cd.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml index 6a35b6e..8302726 100644 --- a/.github/workflows/ci-cd.yaml +++ b/.github/workflows/ci-cd.yaml @@ -43,7 +43,7 @@ jobs: run: python -m pip install --upgrade pip - name: Install requirements - run: python -m pip install -r ./nipype-auto-conv/requirements.txt + run: python -m pip install -r ./nipype-auto-conv/requirements.txt ./related-packages/fileformats - name: Run automatic Nipype > Pydra conversion run: ./nipype-auto-conv/generate From 5423234f023d1714d3a7fafcf3212e5c2638ca28 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Mon, 20 May 2024 12:15:52 +1000 Subject: [PATCH 20/23] fixed up sed in ci-cd to unignore auto directory --- .github/workflows/ci-cd.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml index 8302726..c7da5f9 100644 --- a/.github/workflows/ci-cd.yaml +++ b/.github/workflows/ci-cd.yaml @@ -158,7 +158,7 @@ jobs: run: tree ./pydra - name: Strip auto package from gitignore so it is included in package run: | - sed -i '/\/src\/pydra\/tasks\/afni\/auto/d' .gitignore + sed -i '/\/pydra\/tasks\/afni\/auto/d' .gitignore - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: From 02d9242a55980abf4765aec603f6f87aff4666d9 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Mon, 20 May 2024 12:40:20 +1000 Subject: [PATCH 21/23] fixed up deploy download of artefacts --- .github/workflows/ci-cd.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml index c7da5f9..111ca21 100644 --- a/.github/workflows/ci-cd.yaml +++ b/.github/workflows/ci-cd.yaml @@ -256,7 +256,7 @@ jobs: submodules: recursive fetch-depth: 0 - name: Download tasks converted from Nipype - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: converted-nipype path: pydra/tasks/afni/auto @@ -282,7 +282,7 @@ jobs: run: python -m build . - name: Check distributions run: twine check dist/* - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: distributions path: dist/ From 6c104bfd291e6f64807edbfde07cfa20142a5903 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Mon, 20 May 2024 12:53:58 +1000 Subject: [PATCH 22/23] cleaned up readme --- README.md | 48 ------------------------------------------------ README.rst | 4 ++-- 2 files changed, 2 insertions(+), 50 deletions(-) delete mode 100644 README.md diff --git a/README.md b/README.md deleted file mode 100644 index 5e96855..0000000 --- a/README.md +++ /dev/null @@ -1,48 +0,0 @@ -# Pydra task package for afni - -This package contains a collection of Pydra task interfaces for afni. The basis for -which have been semi-automatically -boo - -## Tests - -This package comes with a default set of test modules, and we encourage users to use pytest. -Tests can be discovered and run using: - -``` -pytest --doctest-modules pydra/tasks/* -``` - -## Continuous integration - -This template uses [GitHub Actions](https://docs.github.com/en/actions/) to run tests. To simulate -several plausible development or installation environments, we test over all Python versions -supported by Pydra, and install Pydra and the current package in both standard and -[editable](https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs) modes. - -The combination of standard/editable is in particular designed to ensure that namespace packaging -does not break. We strongly recommend keeping these tests in place for this reason, as one -non-compliant package can potentially affect Pydra or other task packages. - -In addition to verifying installations do not break or conflict, pytest is run on the package, -including all tests found in `test/` directories and [doctests]. - -Finally, packages are built and uploaded as artifacts for inspection. When a tag is pushed, -the packages are uploaded to PyPI if a valid [API token](https://pypi.org/help/#apitoken) is placed -in the [repository secrets](https://docs.github.com/en/actions/reference/encrypted-secrets). - -[doctests]: https://docs.python.org/3/library/doctest.html - -# Contributing to this package - -## For developers - -Install repo in developer mode from the source directory. It is also useful to -install pre-commit to take care of styling via [black](https://black.readthedocs.io/): - -``` -pip install -e .[dev] -pre-commit install -``` - - diff --git a/README.rst b/README.rst index f1d5683..90b9765 100644 --- a/README.rst +++ b/README.rst @@ -1,6 +1,6 @@ -=============================== +=========================== Pydra task package for afni -=============================== +=========================== .. image:: https://github.com/nipype/pydra-afni/actions/workflows/pythonpackage.yaml/badge.svg :target: https://github.com/nipype/pydra-afni/actions/workflows/pythonpackage.yaml From 5c231489ec766e5bf3bfa66bae10650b28a71bc7 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Mon, 20 May 2024 13:08:35 +1000 Subject: [PATCH 23/23] touched up readme --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 90b9765..7c8288c 100644 --- a/README.rst +++ b/README.rst @@ -78,7 +78,7 @@ ensure consistent code-style and quality. .. code-block:: $ pip install -e .[test,dev] -$ pre-commit install + $ pre-commit install Next install the requirements for running the auto-conversion script and generate the Pydra task interfaces from their Nipype counterparts