Skip to content

Commit e064c10

Browse files
committed
chore: split binary test-data out from gh repo
1 parent f0c91b4 commit e064c10

25 files changed

+156
-157
lines changed

.circleci/config.yml

+85-104
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,107 @@
11
version: 2
22
jobs:
3-
build:
3+
build_pytest:
44
machine:
55
image: circleci/classic:201808-01
66
working_directory: /tmp/src/nitransforms
77
environment:
88
TZ: "/usr/share/zoneinfo/America/Los_Angeles"
9-
SCRATCH: "/scratch"
10-
11-
steps:
12-
- restore_cache:
13-
keys:
14-
- build-v1-{{ .Branch }}-{{ epoch }}
15-
- build-v1-{{ .Branch }}-
16-
- build-v1-master-
17-
- build-v1-
18-
paths:
19-
- /tmp/docker
20-
- run:
21-
name: Set-up a Docker registry
22-
command: |
23-
docker run -d -p 5000:5000 --restart=always --name=registry \
24-
-v /tmp/docker:/var/lib/registry registry:2
25-
- run:
26-
name: Pull existing images
27-
command: |
28-
set +e
29-
docker pull localhost:5000/ubuntu
30-
success=$?
31-
set -e
32-
if [[ "$success" = "0" ]]; then
33-
echo "Pulling from local registry"
34-
docker tag localhost:5000/ubuntu ubuntu:xenial-20200114
35-
docker pull localhost:5000/nitransforms
36-
docker tag localhost:5000/nitransforms nitransforms:latest
37-
else
38-
echo "Pulling from Docker Hub"
39-
docker pull ubuntu:xenial-20200114
40-
docker tag ubuntu:xenial-20200114 localhost:5000/ubuntu
41-
docker push localhost:5000/ubuntu
42-
fi
43-
- checkout
44-
- run:
45-
name: Build Docker image & push to registry
46-
no_output_timeout: 60m
47-
command: |
48-
e=1 && for i in {1..5}; do
49-
docker build --rm --cache-from=nitransforms:latest \
50-
-t nitransforms:latest \
51-
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
52-
--build-arg VCS_REF=`git rev-parse --short HEAD` . \
53-
&& e=0 && break || sleep 15
54-
done && [ "$e" -eq "0" ]
55-
docker tag nitransforms:latest localhost:5000/nitransforms
56-
docker push localhost:5000/nitransforms
57-
- run:
58-
name: Docker registry garbage collection
59-
command: |
60-
docker exec -it registry /bin/registry garbage-collect --delete-untagged \
61-
/etc/docker/registry/config.yml
62-
- save_cache:
63-
key: build-v1-{{ .Branch }}-{{ epoch }}
64-
paths:
65-
- /tmp/docker
66-
- run:
67-
name: Store FreeSurfer license file
68-
command: |
69-
mkdir -p /tmp/fslicense
70-
cd /tmp/fslicense
71-
echo "cHJpbnRmICJrcnp5c3p0b2YuZ29yZ29sZXdza2lAZ21haWwuY29tXG41MTcyXG4gKkN2dW12RVYzelRmZ1xuRlM1Si8yYzFhZ2c0RVxuIiA+IGxpY2Vuc2UudHh0Cg==" | base64 -d | sh
72-
- persist_to_workspace:
73-
root: /tmp
74-
paths:
75-
- fslicense
76-
77-
test_pytest:
78-
machine:
79-
image: circleci/classic:201808-01
80-
environment:
819
FS_LICENSE: "/tmp/fslicense/license.txt"
82-
working_directory: /tmp/tests
10+
8311
steps:
84-
- attach_workspace:
85-
at: /tmp
86-
- checkout:
87-
path: /tmp/src/nitransforms
88-
- run:
89-
name: Get codecov
90-
command: python -m pip install codecov
9112
- restore_cache:
9213
keys:
9314
- build-v1-{{ .Branch }}-{{ epoch }}
9415
- build-v1-{{ .Branch }}-
9516
- build-v1-master-
9617
- build-v1-
18+
paths:
19+
- /tmp/docker
20+
- run:
21+
name: Set-up a Docker registry
22+
command: |
23+
docker run -d -p 5000:5000 --restart=always --name=registry \
24+
-v /tmp/docker:/var/lib/registry registry:2
25+
- run:
26+
name: Pull existing images
27+
command: |
28+
set +e
29+
docker pull localhost:5000/ubuntu
30+
success=$?
31+
set -e
32+
if [[ "$success" = "0" ]]; then
33+
echo "Pulling from local registry"
34+
docker tag localhost:5000/ubuntu ubuntu:xenial-20200114
35+
docker pull localhost:5000/nitransforms
36+
docker tag localhost:5000/nitransforms nitransforms:latest
37+
else
38+
echo "Pulling from Docker Hub"
39+
docker pull ubuntu:xenial-20200114
40+
docker tag ubuntu:xenial-20200114 localhost:5000/ubuntu
41+
docker push localhost:5000/ubuntu
42+
fi
43+
- checkout
44+
- run:
45+
name: Build Docker image & push to registry
46+
no_output_timeout: 60m
47+
command: |
48+
e=1 && for i in {1..5}; do
49+
docker build --rm --cache-from=nitransforms:latest \
50+
-t nitransforms:latest \
51+
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
52+
--build-arg VCS_REF=`git rev-parse --short HEAD` . \
53+
&& e=0 && break || sleep 15
54+
done && [ "$e" -eq "0" ]
55+
docker tag nitransforms:latest localhost:5000/nitransforms
56+
docker push localhost:5000/nitransforms
57+
- run:
58+
name: Docker registry garbage collection
59+
command: |
60+
docker exec -it registry /bin/registry garbage-collect --delete-untagged \
61+
/etc/docker/registry/config.yml
62+
- save_cache:
63+
key: build-v1-{{ .Branch }}-{{ epoch }}
64+
paths:
65+
- /tmp/docker
9766
- run:
98-
name: Set-up a Docker registry & pull
67+
name: Store FreeSurfer license file
9968
command: |
100-
docker run -d -p 5000:5000 --restart=always --name=registry \
101-
-v /tmp/docker:/var/lib/registry registry:2
102-
docker pull localhost:5000/nitransforms
103-
docker tag localhost:5000/nitransforms nitransforms:latest
69+
mkdir -p /tmp/fslicense
70+
cd /tmp/fslicense
71+
echo "cHJpbnRmICJrcnp5c3p0b2YuZ29yZ29sZXdza2lAZ21haWwuY29tXG41MTcyXG4gKkN2dW12RVYzelRmZ1xuRlM1Si8yYzFhZ2c0RVxuIiA+IGxpY2Vuc2UudHh0Cg==" | base64 -d | sh
72+
73+
- restore_cache:
74+
keys:
75+
- data-v1-{{ .Branch }}-{{ epoch }}
76+
- data-v1-{{ .Branch }}-
77+
- data-v1-master-
78+
- data-v1-
79+
paths:
80+
- /tmp/data
81+
- run:
82+
name: Download data
83+
command: |
84+
if [[ ! -d /tmp/data ]]; then
85+
wget --retry-connrefused --waitretry=5 --read-timeout=20 --timeout=15 -t 0 -q \
86+
-O data.zip "https://files.osf.io/v1/resources/fvuh8/providers/osfstorage/5e7d5b65c3f8d300bafa05e0/?zip="
87+
unzip -d /tmp/data data.zip
88+
else
89+
echo "Dataset was cached"
90+
fi
91+
- save_cache:
92+
key: data-v1-{{ .Branch }}-{{ epoch }}
93+
paths:
94+
- /tmp/data
95+
- run:
96+
name: Get codecov
97+
command: python -m pip install codecov
10498
- run:
10599
name: Run unit tests
106100
no_output_timeout: 2h
107101
command: |
108-
mkdir -p $PWD/artifacts $PWD/summaries
109-
sudo setfacl -d -m group:ubuntu:rwx $PWD
110-
sudo setfacl -m group:ubuntu:rwx $PWD
111-
docker run -u $( id -u ) -it --rm=false -w /src/nitransforms \
102+
mkdir -p $PWD/{artifacts,summaries}
103+
docker run -u $( id -u ) -it --rm -w /src/nitransforms \
104+
-v /tmp/data:/data -e TEST_DATA_HOME=/data \
112105
-e COVERAGE_FILE=/tmp/summaries/.pytest.coverage \
113106
-v /tmp/fslicense/license.txt:/opt/freesurfer/license.txt:ro \
114107
-v ${PWD}:/tmp nitransforms:latest \
@@ -162,33 +155,21 @@ jobs:
162155
command: |
163156
python3 -m twine upload dist/*
164157
165-
166158
workflows:
167159
version: 2
168160
build_test_deploy:
169161
jobs:
170-
- build:
171-
filters:
172-
branches:
173-
ignore:
174-
- /docs?\/.*/
175-
tags:
176-
only: /.*/
177-
178-
- test_pytest:
179-
requires:
180-
- build
162+
- build_pytest:
181163
filters:
182164
branches:
183165
ignore:
184166
- /docs?\/.*/
185-
- /docker\/.*/
186167
tags:
187168
only: /.*/
188169

189170
- test_packaging_and_deploy:
190171
requires:
191-
- test_pytest
172+
- build_pytest
192173
filters:
193174
branches:
194175
ignore: /.*/

.travis.yml

+14-1
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,31 @@ env:
1212
global:
1313
- BUILD_TYPE="src"
1414
- DOCKER_IMAGE="poldracklab/fmriprep:latest"
15+
- TEST_DATA_HOME="$HOME/.nitransforms/testdata"
1516

1617
matrix:
1718
include:
1819
- python: 3.7
1920
env: BUILD_TYPE="docker"
2021

22+
cache:
23+
directories:
24+
- $HOME/.nitransforms/testdata
25+
2126
before_install:
2227
- |
28+
if [[ ! -d $TEST_DATA_HOME ]]; then
29+
mkdir -p $HOME/.nitransforms
30+
wget --retry-connrefused --waitretry=5 --read-timeout=20 --timeout=15 -t 0 -q \
31+
-O data.zip "https://files.osf.io/v1/resources/fvuh8/providers/osfstorage/5e7d5b65c3f8d300bafa05e0/?zip="
32+
unzip -d $TEST_DATA_HOME data.zip
33+
else
34+
echo "Dataset was cached"
35+
fi
2336
if [ ${BUILD_TYPE} == "docker" ]; then
2437
CI_ENV=`bash <(curl -s https://codecov.io/env)`
2538
docker pull ${DOCKER_IMAGE} # pull latest release
26-
docker run $CI_ENV -itd --name fmriprep --entrypoint=/bin/bash -v `pwd`:/opt/nt -w /opt/nt ${DOCKER_IMAGE}
39+
docker run $CI_ENV -v $TEST_DATA_HOME:/data -e TEST_DATA_HOME=/data -itd --name fmriprep --entrypoint=/bin/bash -v `pwd`:/opt/nt -w /opt/nt ${DOCKER_IMAGE}
2740
docker exec fmriprep sh -c 'echo "cHJpbnRmICJrcnp5c3p0b2YuZ29yZ29sZXdza2lAZ21haWwuY29tXG41MTcyXG4gKkN2dW12RVYzelRmZ1xuRlM1Si8yYzFhZ2c0RVxuIiA+IC9vcHQvZnJlZXN1cmZlci9saWNlbnNlLnR4dAo=" | base64 -d | sh'
2841
fi
2942

nitransforms/conftest.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
import nibabel as nb
66
import pytest
77
import tempfile
8-
import pkg_resources
98

10-
SOMEONES_ANATOMY = pkg_resources.resource_filename(
11-
'nitransforms', 'tests/data/someones_anatomy.nii.gz')
129
_data = None
10+
_testdir = Path(os.getenv('TEST_DATA_HOME', '~/.nitransforms/testdata')).expanduser()
1311

1412

1513
@pytest.fixture(autouse=True)
@@ -19,7 +17,8 @@ def doctest_autoimport(doctest_namespace):
1917
doctest_namespace['nb'] = nb
2018
doctest_namespace['os'] = os
2119
doctest_namespace['Path'] = Path
22-
doctest_namespace['datadir'] = Path(__file__).parent / 'tests' / 'data'
20+
doctest_namespace['regress_dir'] = Path(__file__).parent / 'tests' / 'data'
21+
doctest_namespace['test_dir'] = _testdir
2322

2423
tmpdir = tempfile.TemporaryDirectory()
2524
doctest_namespace['tmpdir'] = tmpdir.name
@@ -38,6 +37,12 @@ def data_path():
3837
return Path(__file__).parent / 'tests' / 'data'
3938

4039

40+
@pytest.fixture
41+
def testdata_path():
42+
"""Return the heavy test-data folder."""
43+
return _testdir
44+
45+
4146
@pytest.fixture
4247
def get_testdata():
4348
"""Generate data in the requested orientation."""
@@ -46,7 +51,7 @@ def get_testdata():
4651
if _data is not None:
4752
return _data
4853

49-
img = nb.load(SOMEONES_ANATOMY)
54+
img = nb.load(_testdir / 'someones_anatomy.nii.gz')
5055
imgaff = img.affine
5156

5257
_data = {'RAS': img}

nitransforms/linear.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def __init__(self, matrix=None, reference=None):
4040
4141
Examples
4242
--------
43-
>>> xfm = Affine(reference=datadir / "someones_anatomy.nii.gz")
43+
>>> xfm = Affine(reference=test_dir / "someones_anatomy.nii.gz")
4444
>>> xfm.matrix # doctest: +NORMALIZE_WHITESPACE
4545
array([[1., 0., 0., 0.],
4646
[0., 1., 0., 0.],
@@ -452,11 +452,11 @@ def load(filename, fmt="X5", reference=None, moving=None):
452452
453453
Examples
454454
--------
455-
>>> xfm = load(datadir / "affine-LAS.itk.tfm", fmt="itk")
455+
>>> xfm = load(regress_dir / "affine-LAS.itk.tfm", fmt="itk")
456456
>>> isinstance(xfm, Affine)
457457
True
458458
459-
>>> xfm = load(datadir / "itktflist.tfm", fmt="itk")
459+
>>> xfm = load(regress_dir / "itktflist.tfm", fmt="itk")
460460
>>> isinstance(xfm, LinearTransformsMapping)
461461
True
462462
-18.8 MB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

nitransforms/tests/data/fmap.nii.gz

-699 KB
Binary file not shown.

nitransforms/tests/data/func.nii.gz

-14.2 MB
Binary file not shown.
Binary file not shown.
Binary file not shown.
-114 KB
Binary file not shown.

nitransforms/tests/data/sbref.nii.gz

-859 KB
Binary file not shown.
-187 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.

nitransforms/tests/test_base.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
from ..base import SpatialReference, SampledSpatialData, ImageGrid, TransformBase
88

99

10-
def test_SpatialReference(data_path):
10+
def test_SpatialReference(testdata_path):
1111
"""Ensure the reference factory is working properly."""
12-
obj1 = data_path / 'someones_anatomy.nii.gz'
13-
obj2 = data_path / 'sub-200148_hemi-R_pial.surf.gii'
14-
obj3 = data_path / 'func.nii.gz'
12+
obj1 = testdata_path / 'someones_anatomy.nii.gz'
13+
obj2 = testdata_path / 'sub-200148_hemi-R_pial.surf.gii'
14+
obj3 = testdata_path / 'func.nii.gz'
1515

1616
assert isinstance(SpatialReference.factory(obj1), ImageGrid)
1717
assert isinstance(SpatialReference.factory(str(obj1)), ImageGrid)
@@ -58,12 +58,12 @@ def test_ImageGrid(get_testdata, image_orientation):
5858
assert (img2 != img) is False
5959

6060

61-
def test_ImageGrid_utils(tmpdir, data_path, get_testdata):
61+
def test_ImageGrid_utils(tmpdir, testdata_path, get_testdata):
6262
"""Check that images can be objects or paths and equality."""
6363
tmpdir.chdir()
6464

6565
im1 = get_testdata['RAS']
66-
im2 = data_path / 'someones_anatomy.nii.gz'
66+
im2 = testdata_path / 'someones_anatomy.nii.gz'
6767

6868
ig = ImageGrid(im1)
6969
assert ig == ImageGrid(im2)
@@ -73,7 +73,7 @@ def test_ImageGrid_utils(tmpdir, data_path, get_testdata):
7373
ImageGrid(im1)._to_hdf5(f.create_group('Reference'))
7474

7575

76-
def test_TransformBase(monkeypatch, data_path, tmpdir):
76+
def test_TransformBase(monkeypatch, testdata_path, tmpdir):
7777
"""Check the correctness of TransformBase components."""
7878
tmpdir.chdir()
7979

@@ -85,7 +85,7 @@ def _to_hdf5(klass, x5_root):
8585

8686
monkeypatch.setattr(TransformBase, 'map', _fakemap)
8787
monkeypatch.setattr(TransformBase, '_to_hdf5', _to_hdf5)
88-
fname = data_path / 'someones_anatomy.nii.gz'
88+
fname = testdata_path / 'someones_anatomy.nii.gz'
8989

9090
# Test identity transform
9191
xfm = TransformBase()
@@ -114,9 +114,9 @@ def _to_hdf5(klass, x5_root):
114114
xfm.to_filename('data.x5')
115115

116116

117-
def test_SampledSpatialData(data_path):
117+
def test_SampledSpatialData(testdata_path):
118118
"""Check the reference generated by cifti files."""
119-
gii = data_path / 'sub-200148_hemi-R_pial.surf.gii'
119+
gii = testdata_path / 'sub-200148_hemi-R_pial.surf.gii'
120120

121121
ssd = SampledSpatialData(gii)
122122
assert ssd.npoints == 249277

0 commit comments

Comments
 (0)