Skip to content

Commit b401283

Browse files
authored
Merge pull request #3 from nipype/nipype-auto-conv
Added in nipype auto convert specifications
2 parents 8b7ec9c + c48f72f commit b401283

File tree

193 files changed

+41145
-1333
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

193 files changed

+41145
-1333
lines changed

.flake8

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
[flake8]
3+
doctests = True
4+
exclude =
5+
**/__init__.py
6+
*build/
7+
docs/sphinxext/
8+
docs/tools/
9+
docs/conf.py
10+
docs/source/conf.py
11+
max-line-length = 88
12+
select = C,E,F,W,B,B950
13+
extend-ignore = E203,E501,E129,W503
14+
per-file-ignores =
15+
__init__.py:F401,F403

.github/workflows/ci-cd.yaml

Lines changed: 305 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,305 @@
1+
#This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
# For deployment, it will be necessary to create a PyPI API token and store it as a secret
5+
# https://docs.github.com/en/actions/reference/encrypted-secrets
6+
7+
name: CI/CD
8+
9+
on:
10+
push:
11+
branches: [ main, develop ]
12+
tags: [ '*' ]
13+
pull_request:
14+
branches: [ main, develop ]
15+
repository_dispatch:
16+
types: [create-release]
17+
18+
jobs:
19+
20+
nipype-conv:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v3
25+
- name: Revert version to most recent tag on upstream update
26+
if: github.event_name == 'repository_dispatch'
27+
run: git checkout $(git tag -l | tail -n 1 | awk -F post '{print $1}')
28+
- name: Set up Python ${{ matrix.python-version }}
29+
uses: actions/setup-python@v4
30+
- name: Install build dependencies
31+
run: python -m pip install --upgrade pip
32+
- name: Install requirements
33+
run: python -m pip install ./related-packages/fileformats -r ./nipype-auto-conv/requirements.txt
34+
- name: Run automatic Nipype > Pydra conversion
35+
run: ./nipype-auto-conv/generate
36+
- uses: actions/upload-artifact@v3
37+
with:
38+
name: converted-nipype
39+
path: pydra/tasks/afni/auto
40+
41+
devcheck:
42+
needs: [nipype-conv]
43+
runs-on: ubuntu-latest
44+
strategy:
45+
matrix:
46+
python-version: ['3.8', '3.11'] # Check oldest and newest versions
47+
pip-flags: ['', '--editable']
48+
pydra:
49+
- 'pydra'
50+
- '--editable git+https://github.com/nipype/pydra.git#egg=pydra'
51+
steps:
52+
- name: Checkout
53+
uses: actions/checkout@v3
54+
- name: Revert version to most recent tag on upstream update
55+
if: github.event_name == 'repository_dispatch'
56+
run: git checkout $(git tag -l | tail -n 1 | awk -F post '{print $1}')
57+
- name: Download tasks converted from Nipype
58+
uses: actions/download-artifact@v3
59+
with:
60+
name: converted-nipype
61+
path: pydra/tasks/afni/auto
62+
- name: Strip auto package from gitignore so it is included in package
63+
run: |
64+
sed -i '/\/pydra\/tasks\/afni\/auto/d' .gitignore
65+
- name: Set up Python ${{ matrix.python-version }}
66+
uses: actions/setup-python@v4
67+
with:
68+
python-version: ${{ matrix.python-version }}
69+
- name: Install build dependencies
70+
run: |
71+
python -m pip install --upgrade pip
72+
- name: Install Pydra
73+
run: |
74+
pushd $HOME
75+
pip install ${{ matrix.pydra }}
76+
popd
77+
python -c "import pydra as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')"
78+
- name: Install task package
79+
run: |
80+
pip install "./related-packages/fileformats[dev]" "related-packages/fileformats-extras[dev]"
81+
pip install ${{ matrix.pip-flags }} ".[dev]"
82+
python -c "import pydra.tasks.afni as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')"
83+
python -c "import pydra as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')"
84+
python -c "import fileformats.medimage_afni as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')"
85+
python -c "import fileformats.extras.medimage_afni as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')"
86+
87+
fileformats-test:
88+
runs-on: ubuntu-latest
89+
strategy:
90+
matrix:
91+
python-version: ['3.8', '3.11']
92+
steps:
93+
- uses: actions/checkout@v3
94+
- name: Revert version to most recent tag on upstream update
95+
if: github.event_name == 'repository_dispatch'
96+
run: git checkout $(git tag -l | tail -n 1 | awk -F post '{print $1}')
97+
- name: Set up Python ${{ matrix.python-version }}
98+
uses: actions/setup-python@v4
99+
with:
100+
python-version: ${{ matrix.python-version }}
101+
- name: Install build dependencies
102+
run: |
103+
python -m pip install --upgrade pip
104+
- name: Install task package
105+
run: |
106+
pip install "./related-packages/fileformats[test]" "./related-packages/fileformats-extras[test]"
107+
python -c "import fileformats.medimage_afni as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')"
108+
- name: Test fileformats with pytest
109+
run: |
110+
cd ./fileformats
111+
pytest -sv --cov fileformats.medimage_afni --cov fileformats.extras.medimage_afni --cov-report xml .
112+
113+
test:
114+
needs: [nipype-conv, fileformats-test]
115+
runs-on: ubuntu-22.04
116+
strategy:
117+
matrix:
118+
python-version: ['3.8'] # '3.11'
119+
steps:
120+
- name: Removed unnecessary tools to free space
121+
run: |
122+
sudo rm -rf /usr/share/dotnet
123+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
124+
- name: Get Download cache Key
125+
id: cache-key
126+
run: echo "::set-output name=key::afni-linux-ubuntu22_amd64-7.4.1"
127+
- name: Cache FreeSurfer
128+
uses: actions/cache@v2
129+
with:
130+
path: $HOME/downloads/afni
131+
key: ${{ steps.cache-key.outputs.key }}
132+
restore-keys: |
133+
afni-linux-ubuntu22_amd64-7.4.1
134+
- name: Download FreeSurfer
135+
if: steps.cache-key.outputs.key != steps.cache-hit.outputs.key
136+
run: |
137+
mkdir -p $HOME/downloads/afni
138+
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
139+
shell: bash
140+
- name: Install Freesurfer
141+
env:
142+
FREESURFER_LICENCE: ${{ secrets.FREESURFER_LICENCE }}
143+
run: |
144+
pushd $HOME/downloads/afni
145+
tar -zxpf afni-linux-ubuntu22_amd64-7.4.1.tar.gz
146+
mv afni $HOME/
147+
popd
148+
export FREESURFER_HOME=$HOME/afni
149+
source $FREESURFER_HOME/SetUpFreeSurfer.sh
150+
echo $FREESURFER_LICENCE > $FREESURFER_HOME/license.txt
151+
export PATH=$FREESURFER_HOME/bin:$PATH
152+
- uses: actions/checkout@v3
153+
- name: Revert version to most recent tag on upstream update
154+
if: github.event_name == 'repository_dispatch'
155+
run: git checkout $(git tag -l | tail -n 1 | awk -F post '{print $1}')
156+
- name: Download tasks converted from Nipype
157+
uses: actions/download-artifact@v3
158+
with:
159+
name: converted-nipype
160+
path: pydra/tasks/afni/auto
161+
- name: Strip auto package from gitignore so it is included in package
162+
run: |
163+
sed -i '/\/src\/pydra\/tasks\/afni\/auto/d' .gitignore
164+
- name: Set up Python ${{ matrix.python-version }}
165+
uses: actions/setup-python@v4
166+
with:
167+
python-version: ${{ matrix.python-version }}
168+
- name: Install build dependencies
169+
run: |
170+
python -m pip install --upgrade pip
171+
- name: Install task package
172+
run: |
173+
pip install "./related-packages/fileformats" "./related-packages/fileformats-extras" ".[test]"
174+
python -c "import pydra.tasks.afni as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')"
175+
python -c "import pydra as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')"
176+
- name: Test with pytest
177+
run: |
178+
pytest -sv --doctest-modules ./pydra/tasks/afni \
179+
--cov pydra.tasks.afni --cov-report xml
180+
- uses: codecov/codecov-action@v3
181+
if: ${{ always() }}
182+
with:
183+
files: coverage.xml,./fileformats/coverage.xml
184+
name: pydra-afni
185+
186+
deploy-fileformats:
187+
needs: [devcheck, test]
188+
runs-on: ubuntu-latest
189+
steps:
190+
- uses: actions/checkout@v3
191+
with:
192+
submodules: recursive
193+
fetch-depth: 0
194+
- name: Set up Python
195+
uses: actions/setup-python@v4
196+
with:
197+
python-version: '3.11'
198+
- name: Install build tools
199+
run: python -m pip install build twine
200+
- name: Build source and wheel distributions
201+
run: python -m build ./related-packages/fileformats
202+
- name: Check distributions
203+
run: twine check ./related-packages/fileformats/dist/*
204+
- name: Check for PyPI token on tag
205+
id: deployable
206+
if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) || github.event_name == 'repository_dispatch'
207+
env:
208+
PYPI_API_TOKEN: "${{ secrets.PYPI_FILEFORMATS_API_TOKEN }}"
209+
run: if [ -n "$PYPI_API_TOKEN" ]; then echo "DEPLOY=true" >> $GITHUB_OUTPUT; fi
210+
- name: Upload to PyPI
211+
if: steps.deployable.outputs.DEPLOY
212+
uses: pypa/gh-action-pypi-publish@release/v1
213+
with:
214+
user: __token__
215+
password: ${{ secrets.PYPI_FILEFORMATS_API_TOKEN }}
216+
packages-dir: ./related-packages/fileformats/dist
217+
218+
deploy-fileformats-extras:
219+
needs: [deploy-fileformats]
220+
runs-on: ubuntu-latest
221+
steps:
222+
- uses: actions/checkout@v3
223+
with:
224+
submodules: recursive
225+
fetch-depth: 0
226+
- name: Set up Python
227+
uses: actions/setup-python@v4
228+
with:
229+
python-version: '3.11'
230+
- name: Install build tools
231+
run: python -m pip install build twine
232+
- name: Build source and wheel distributions
233+
run: python -m build ./related-packages/fileformats-extras
234+
- name: Check distributions
235+
run: twine check ./related-packages/fileformats-extras/dist/*
236+
- name: Check for PyPI token on tag
237+
id: deployable
238+
if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) || github.event_name == 'repository_dispatch'
239+
env:
240+
PYPI_API_TOKEN: "${{ secrets.PYPI_FILEFORMATS_EXTRAS_API_TOKEN }}"
241+
run: if [ -n "$PYPI_API_TOKEN" ]; then echo "DEPLOY=true" >> $GITHUB_OUTPUT; fi
242+
- name: Upload to PyPI
243+
if: steps.deployable.outputs.DEPLOY
244+
uses: pypa/gh-action-pypi-publish@release/v1
245+
with:
246+
user: __token__
247+
password: ${{ secrets.PYPI_FILEFORMATS_EXTRAS_API_TOKEN }}
248+
packages-dir: ./related-packages/fileformats-extras/dist
249+
250+
deploy:
251+
needs: [deploy-fileformats-extras]
252+
runs-on: ubuntu-latest
253+
steps:
254+
- uses: actions/checkout@v3
255+
with:
256+
submodules: recursive
257+
fetch-depth: 0
258+
- name: Download tasks converted from Nipype
259+
uses: actions/download-artifact@v3
260+
with:
261+
name: converted-nipype
262+
path: pydra/tasks/afni/auto
263+
- name: Tag release with a post-release based on Nipype and Nipype2Pydra versions
264+
if: github.event_name == 'repository_dispatch'
265+
run: |
266+
TAG=$(git tag -l | tail -n 1 | awk -F post '{print $1}')
267+
POST=$(python -c "from pydra.tasks.afni.auto._version import *; print(post_release)")
268+
git checkout $TAG
269+
git add -f pydra/tasks/afni/auto/_version.py
270+
git commit -am"added auto-generated version to make new tag for package version"
271+
git tag ${TAG}post${POST}
272+
- name: Set up Python
273+
uses: actions/setup-python@v4
274+
with:
275+
python-version: '3.11'
276+
- name: Install build tools
277+
run: python -m pip install build twine
278+
- name: Strip auto package from gitignore so it is included in package
279+
run: |
280+
sed -i '/\/pydra\/tasks\/afni\/auto/d' .gitignore
281+
- name: Build source and wheel distributions
282+
run: python -m build .
283+
- name: Check distributions
284+
run: twine check dist/*
285+
- uses: actions/upload-artifact@v3
286+
with:
287+
name: distributions
288+
path: dist/
289+
- name: Check for PyPI token on tag
290+
id: deployable
291+
if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) || github.event_name == 'repository_dispatch'
292+
env:
293+
PYPI_API_TOKEN: "${{ secrets.PYPI_API_TOKEN }}"
294+
run: if [ -n "$PYPI_API_TOKEN" ]; then echo "DEPLOY=true" >> $GITHUB_OUTPUT; fi
295+
- name: Upload to PyPI
296+
if: steps.deployable.outputs.DEPLOY
297+
uses: pypa/gh-action-pypi-publish@release/v1
298+
with:
299+
user: __token__
300+
password: ${{ secrets.PYPI_API_TOKEN }}
301+
302+
# Deploy on tags if PYPI_API_TOKEN is defined in the repository secrets.
303+
# Secrets are not accessible in the if: condition [0], so set an output variable [1]
304+
# [0] https://github.community/t/16928
305+
# [1] https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-output-parameter

0 commit comments

Comments
 (0)