Skip to content

Commit 4cff451

Browse files
authored
Merge pull request #22 from nipype/fileformats-core-refactor
Updates to match refactor of fileformats core
2 parents 22a7603 + 3b86ac9 commit 4cff451

File tree

10 files changed

+81
-126
lines changed

10 files changed

+81
-126
lines changed

.github/workflows/ci-cd.yml

Lines changed: 8 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,18 @@ jobs:
4545
run: |
4646
git config --global user.email "[email protected]"
4747
git config --global user.name "Dummy User"
48-
4948
- name: install dependencies
5049
run: |
5150
sudo apt-get update
5251
sudo apt-get install clang qt6-base-dev libglvnd-dev libeigen3-dev zlib1g-dev libfftw3-dev ninja-build
53-
5452
- name: Run sccache-cache
5553
uses: mozilla-actions/[email protected]
56-
5754
- name: Get CMake
5855
uses: lukka/get-cmake@latest
5956
with:
6057
cmakeVersion: '3.16.3'
61-
6258
- name: Print CMake version
6359
run: cmake --version
64-
6560
- name: Clone latest MRtrix and switch to latest tag
6661
run: |
6762
mkdir $MRTRIX_HOME
@@ -71,10 +66,8 @@ jobs:
7166
git checkout pydra-usage-python-cmd
7267
git tag -a $MRTRIX_VERSION -m"Tag used to create a pydra-mrtrix3 release"
7368
git describe --abbrev=0
74-
7569
# echo "MRTRIX_VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
7670
# git checkout $MRTRIX_VERSION
77-
7871
- name: configure
7972
run: |
8073
cd $MRTRIX_HOME/src
@@ -88,40 +81,31 @@ jobs:
8881
-D CMAKE_C_COMPILER=clang \
8982
-D CMAKE_CXX_COMPILER=clang++ \
9083
-D CMAKE_INSTALL_PREFIX=$MRTRIX_INSTALL
91-
9284
- name: Build Mrtrix
9385
run: |
9486
cd $MRTRIX_HOME/src
9587
cmake --build build
96-
9788
- name: Install Mrtrix
9889
run: |
9990
cd $MRTRIX_HOME/src
10091
cmake --install build
101-
10292
- name: Set PATH Variable
10393
run: echo "PATH=$PATH:$MRTRIX_INSTALL/bin" >> $GITHUB_ENV
104-
10594
- name: Set LD_LIBRARY_PATH Variable
10695
run: echo "LD_LIBRARY_PATH=$MRTRIX_INSTALL/lib" >> $GITHUB_ENV
107-
10896
- name: Change back to the root directory
10997
run: cd ..
110-
11198
- name: Set up Python
11299
uses: actions/setup-python@v2
113-
114100
- name: Install Python build dependencies
115101
run: |
116102
python -m pip install --upgrade pip
117-
118103
- name: Install pydra-auto-gen requirements
119104
run: >
120105
pip install
121106
-e related-packages/fileformats
122107
-e related-packages/fileformats-extras
123108
-e .[dev,test]
124-
125109
- name: Generate task specifications
126110
run: >
127111
./generate.py
@@ -130,22 +114,18 @@ jobs:
130114
$MRTRIX_VERSION
131115
--log-errors
132116
--latest
133-
134117
- name: Upload MRtrix3 install
135118
uses: actions/upload-artifact@v2
136119
with:
137120
name: MRtrix3
138121
path: ${{ env.MRTRIX_INSTALL}}
139-
140122
- name: Upload auto-gen pydra
141123
uses: actions/upload-artifact@v2
142124
with:
143125
name: AutoGen
144126
path: pydra/tasks/mrtrix3/${{ env.SUBPKG_NAME }}
145-
146127
- name: Write version file
147128
run: echo $MRTRIX_VERSION > mrtrix3_version.txt
148-
149129
- name: Upload version file
150130
uses: actions/upload-artifact@v2
151131
with:
@@ -165,40 +145,32 @@ jobs:
165145

166146
steps:
167147
- uses: actions/checkout@v2
168-
169148
- name: Download version file
170149
uses: actions/download-artifact@v2
171150
with:
172151
name: VersionFile
173152
path: mrtrix3_version.txt
174-
175153
- name: Extract Mrtrix version
176154
run: echo "MRTRIX_VERSION=$(cat mrtrix3_version.txt)" >> $GITHUB_ENV
177-
178155
- name: Download auto-gen pydra
179156
uses: actions/download-artifact@v2
180157
with:
181158
name: AutoGen
182159
path: pydra/tasks/mrtrix3/${{ env.SUBPKG_NAME }}
183-
184160
- name: Strip auto package from gitignore so it is included in package
185161
run: |
186162
sed -i '/\/pydra\/tasks\/mrtrix3\/${{ env.SUBPKG_NAME }}/d' .gitignore
187-
188163
- name: Set up Python ${{ matrix.python-version }}
189164
uses: actions/setup-python@v2
190165
with:
191166
python-version: ${{ matrix.python-version }}
192-
193167
- name: Install build dependencies
194168
run: |
195169
python -m pip install --upgrade pip
196-
197170
- name: Install Pydra
198171
run: |
199172
pip install ${{ matrix.pydra }}
200173
python -c "import pydra as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')"
201-
202174
- name: Install task package
203175
run: |
204176
pip install ${{ matrix.pip-flags }} "related-packages/fileformats"
@@ -221,66 +193,55 @@ jobs:
221193
run: |
222194
sudo apt-get update
223195
sudo apt-get install clang qt6-base-dev libglvnd-dev libeigen3-dev zlib1g-dev libfftw3-dev ninja-build
224-
225196
- name: Checkout code
226197
uses: actions/checkout@v2
227-
198+
- name: Unset header
199+
# checkout@v2 adds a header that makes branch protection report errors
200+
# because the Github action bot is not a collaborator on the repo
201+
run: git config --local --unset http.https://github.com/.extraheader
202+
- name: Fetch tags
203+
run: git fetch --prune --unshallow
228204
- name: Download version file
229205
uses: actions/download-artifact@v2
230206
with:
231207
name: VersionFile
232208
path: mrtrix3_version.txt
233-
234209
- name: Extract Mrtrix version
235210
run: echo "MRTRIX_VERSION=$(cat mrtrix3_version.txt)" >> $GITHUB_ENV
236-
237211
- name: Download auto-gen pydra
238212
uses: actions/download-artifact@v2
239213
with:
240214
name: AutoGen
241215
path: pydra/tasks/mrtrix3/${{ env.SUBPKG_NAME }}
242-
243216
- name: Strip auto package from gitignore so it is included in package
244217
run: |
245218
sed -i '/\/pydra\/tasks\/mrtrix3\/${{ env.SUBPKG_NAME }}/d' .gitignore
246-
247219
- name: Download MRtrix3 install
248220
uses: actions/download-artifact@v2
249221
with:
250222
name: MRtrix3
251223
path: ${{ env.MRTRIX_INSTALL}}
252-
253224
- name: Make commands executable
254225
run: chmod +x ${{ env.MRTRIX_INSTALL }}/bin/*
255-
256226
- name: Set PATH Variable
257227
run: echo "PATH=$PATH:$MRTRIX_INSTALL/bin" >> $GITHUB_ENV
258-
259228
- name: Set LD_LIBRARY_PATH Variable
260229
run: echo "LD_LIBRARY_PATH=$MRTRIX_INSTALL/lib" >> $GITHUB_ENV
261-
262230
- name: Set up Python ${{ matrix.python-version }}
263231
uses: actions/setup-python@v2
264232
with:
265233
python-version: ${{ matrix.python-version }}
266-
267234
- name: Install build dependencies
268235
run: |
269236
python -m pip install --upgrade pip
270-
271237
- name: Install task package
272238
run: >
273239
pip install
274240
-e ./related-packages/fileformats
275241
-e ./related-packages/fileformats-extras
276242
-e '.[test]'
277-
278-
- name: Install dev branch of pydra until bugfix
279-
run: pip install --upgrade git+https://github.com/nipype/pydra.git@typing-bugfixes
280-
281243
- name: Test with pytest
282244
run: pytest -sv pydra/tasks/mrtrix3 --cov pydra.tasks.mrtrix3 --cov-report xml
283-
284245
- uses: codecov/codecov-action@v1
285246
if: ${{ always() }}
286247

@@ -304,7 +265,7 @@ jobs:
304265
run: twine check ./related-packages/fileformats/dist/*
305266
- name: Check for PyPI token on tag
306267
id: deployable
307-
if: github.event_name == 'release'
268+
if: github.event_name == 'release' || github.event_name == 'repository_dispatch'
308269
env:
309270
PYPI_API_TOKEN: "${{ secrets.PYPI_FILEFORMATS_API_TOKEN }}"
310271
run: if [ -n "$PYPI_API_TOKEN" ]; then echo "DEPLOY=true" >> $GITHUB_OUTPUT; fi
@@ -336,7 +297,7 @@ jobs:
336297
run: twine check ./related-packages/fileformats-extras/dist/*
337298
- name: Check for PyPI token on tag
338299
id: deployable
339-
if: github.event_name == 'release'
300+
if: github.event_name == 'release' || github.event_name == 'repository_dispatch'
340301
env:
341302
PYPI_API_TOKEN: "${{ secrets.PYPI_FILEFORMATS_EXTRAS_API_TOKEN }}"
342303
run: if [ -n "$PYPI_API_TOKEN" ]; then echo "DEPLOY=true" >> $GITHUB_OUTPUT; fi
@@ -353,73 +314,58 @@ jobs:
353314
needs: [devcheck, test, deploy-fileformats, deploy-fileformats-extras]
354315
runs-on: ubuntu-latest
355316
steps:
356-
357317
- name: Checkout repo
358318
uses: actions/checkout@v2
359-
360319
- name: Set up Git user
361320
run: |
362321
git config --local user.email "[email protected]"
363322
git config --local user.name "GitHub Action"
364-
365323
- name: Download version file
366324
uses: actions/download-artifact@v2
367325
with:
368326
name: VersionFile
369327
path: mrtrix3_version.txt
370-
371328
- name: Extract Mrtrix version
372329
run: echo "MRTRIX_VERSION=$(cat mrtrix3_version.txt)" >> $GITHUB_ENV
373-
374330
- name: Download auto-gen pydra
375331
uses: actions/download-artifact@v2
376332
with:
377333
name: AutoGen
378334
path: pydra/tasks/mrtrix3/${{ env.SUBPKG_NAME }}
379-
380335
- name: Strip auto package from gitignore so it is included in package
381336
run: |
382337
sed -i '/\/pydra\/tasks\/mrtrix3\/${{ env.SUBPKG_NAME }}/d' .gitignore
383-
384338
- name: Add auto-generated directory to git repo
385339
if: github.event_name == 'release' || github.event_name == 'repository_dispatch'
386340
run: |
387341
git add pydra/tasks/mrtrix3/$SUBPKG_NAME
388342
git commit -am"added auto-generated version to make new tag for package version"
389343
git status
390-
391344
- name: Get latest version tag
392345
id: latest_tag
393346
run: |
394347
git fetch --tags
395348
echo "TAG=$(git tag -l | grep 'v.*' | tail -n 1 | awk -F post '{print $1}')" >> $GITHUB_OUTPUT
396-
397349
- name: Overwrite the tag of release event with latest commit (i.e. including the auto directory)
398350
if: github.event_name == 'release'
399351
run: |
400352
git tag -d ${{ steps.latest_tag.outputs.TAG }};
401353
git tag -a ${{ steps.latest_tag.outputs.TAG }} -m"Tag used to create a pydra-mrtrix3 $MRTRIX_VERSION release";
402-
403354
- name: Set up Python 3.11
404355
uses: actions/setup-python@v2
405356
with:
406357
python-version: 3.11
407-
408358
- name: Install build tools
409359
run: python -m pip install --upgrade pip twine build
410-
411360
- name: Build source and wheel distributions
412361
run: python -m build
413-
414362
- name: Check distributions
415363
run: twine check dist/*
416-
417364
- name: Upload sdist
418365
uses: actions/upload-artifact@v2
419366
with:
420367
name: SDist
421368
path: dist/*.tar.gz
422-
423369
# Deploy on tags if PYPI_API_TOKEN is defined in the repository secrets.
424370
# Secrets are not accessible in the if: condition [0], so set an output variable [1]
425371
# [0] https://github.community/t/16928
@@ -430,7 +376,6 @@ jobs:
430376
env:
431377
PYPI_API_TOKEN: "${{ secrets.PYPI_API_TOKEN }}"
432378
run: if [ -n "$PYPI_API_TOKEN" ]; then echo ::set-output name=DEPLOY::true; fi
433-
434379
- name: Upload to PyPI
435380
if: steps.deployable.outputs.DEPLOY
436381
uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,7 @@ dmypy.json
137137
# Hatchling
138138
_version.py
139139

140+
# Mac Garbage
141+
.DS_Store
142+
140143
/pydra/tasks/mrtrix3/v3_0

pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description = "pydra-mrtrix3 contains Pydra task specifications for MRtrix3 tool
88
readme = "README.rst"
99
requires-python = ">=3.8"
1010
dependencies = [
11-
"fileformats-medimage_mrtrix3 >=3.0.4a4",
11+
"fileformats-medimage_mrtrix3 >=3.0.4a5",
1212
"numpy",
1313
"pydra >=0.23",
1414
]
@@ -36,8 +36,7 @@ dev = [
3636
"click >=8.1.3",
3737
"tqdm",
3838
"attrs >=23.1.0",
39-
"fileformats >= 0.8",
40-
"fileformats-extras >= 0.2.1",
39+
"fileformats-extras >= 0.12.1",
4140
]
4241
doc = [
4342
"packaging",

related-packages/fileformats-extras/fileformats/extras/medimage_mrtrix3/converters.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from fileformats.core import hook
1+
from fileformats.core import converter
22
from fileformats.medimage.base import MedicalImage
33

44
from fileformats.medimage_mrtrix3 import (
@@ -16,7 +16,7 @@
1616
in_out_file_kwargs = {}
1717

1818

19-
@hook.converter(
19+
@converter(
2020
source_format=MedicalImage,
2121
target_format=MrtrixImage,
2222
out_ext=MrtrixImage.ext,
@@ -40,7 +40,7 @@ def mrconvert(name, out_ext: str, **kwargs):
4040
return MrConvert(name=name, out_file="out" + out_ext, **kwargs)
4141

4242

43-
@hook.converter(
43+
@converter(
4444
source_format=MedicalImage,
4545
target_format=MrtrixImageHeader,
4646
out_ext=MrtrixImageHeader.ext,

related-packages/fileformats-extras/fileformats/extras/medimage_mrtrix3/gradients.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import numpy as np
2+
from fileformats.core import extra_implementation
23
from fileformats.medimage import DwiEncoding
34
from fileformats.medimage_mrtrix3 import BFile
45

56

6-
@DwiEncoding.read_array.register
7+
@extra_implementation(DwiEncoding.read_array)
78
def bfile_read_array(bfile: BFile) -> np.ndarray:
89
return np.asarray(
910
[[float(x) for x in ln.split()] for ln in bfile.read_contents().splitlines()]

0 commit comments

Comments
 (0)