Skip to content

Commit 2c79a0c

Browse files
authored
Merge pull request #96 from effigies/ci/test_minimum_dependencies
MAINT: Test minimum dependencies with TravisCI
2 parents d01d882 + 553a806 commit 2c79a0c

File tree

8 files changed

+132
-5
lines changed

8 files changed

+132
-5
lines changed

.travis.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# vim ft=yaml
2+
os: linux
3+
dist: xenial
4+
5+
addons:
6+
apt:
7+
packages:
8+
- libgomp1
9+
10+
11+
language: python
12+
cache: pip
13+
14+
python:
15+
- 3.6
16+
- 3.7
17+
- 3.8
18+
19+
env:
20+
global:
21+
- CHECK_TYPE="tests"
22+
- INSTALL_DEPENDS="pip setuptools"
23+
- DEPENDS="-r min-requirements.txt"
24+
- MRI_ROBUST_TEMPLATE=sx2n7/providers/osfstorage/5e825301d0e35400ebb481f2
25+
- FS_LICENSE=/tmp/freesurfer/license.txt
26+
- TEST_DATA_HOME=/tmp/data
27+
28+
before_install:
29+
- python -m pip install --upgrade pip virtualenv
30+
- virtualenv --python=python /tmp/venv
31+
- source /tmp/venv/bin/activate
32+
- python --version
33+
- python -m pip --version
34+
- python -m pip install --upgrade $INSTALL_DEPENDS
35+
- python -m pip --version
36+
37+
install:
38+
- if [ -n "$DEPENDS" ]; then python -m pip install $DEPENDS; fi
39+
- python -m pip install .
40+
- python -c "import sdcflows; print(sdcflows.__version__)"
41+
- travis_retry python -m pip install "sdcflows[$CHECK_TYPE]"
42+
43+
before_script:
44+
# External dependencies
45+
- travis_retry bash <(wget -q -O- http://neuro.debian.net/_files/neurodebian-travis.sh);
46+
- sudo apt-get update
47+
- sudo apt-get install -y --no-install-recommends git-annex-standalone fsl afni ants
48+
- curl https://files.osf.io/v1/resources/$MRI_ROBUST_TEMPLATE?direct > mri_robust_template
49+
- sudo install mri_robust_template /usr/local/bin
50+
- mkdir /tmp/freesurfer
51+
- echo "b2VzdGViYW5Ac3RhbmZvcmQuZWR1CjMwNzU2CiAqQ1MzYkJ5VXMxdTVNCiBGU2kvUGJsejJxR1V3Cg==" | base64 -d > $FS_LICENSE
52+
- python -m pip install datalad
53+
# Data dependencies
54+
- python -c "from templateflow import api as tfapi;
55+
tfapi.get('MNI152NLin2009cAsym', resolution=2, desc='brain', suffix='mask');
56+
tfapi.get('MNI152NLin2009cAsym', resolution=1, label='brain', suffix='probseg');
57+
tfapi.get('MNI152NLin2009cAsym', resolution=2, desc='fMRIPrep', suffix='boldref');"
58+
- mkdir -p $TEST_DATA_HOME
59+
- datalad install -rg -J 1 -s ///openneuro/ds001600 $TEST_DATA_HOME/ds001600
60+
- curl https://files.osf.io/v1/resources/9sy2a/providers/osfstorage/5d44b940bcd6d900198ed6be/?zip= --output testdata.zip
61+
- unzip testdata.zip -d $TEST_DATA_HOME/testdata
62+
63+
script:
64+
- pytest -v --cov sdcflows --cov-report xml:cov.xml --doctest-modules sdcflows
65+
66+
after_script:
67+
- python -m pip install codecov
68+
- python -m codecov --flags travis --file cov.xml -e $TRAVIS_JOB_NUMBER

min-requirements.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Auto-generated by tools/update_requirements.py
2+
nibabel==3.0.1
3+
niflow-nipype1-workflows==0.0.1
4+
nipype==1.5.1
5+
niworkflows==1.3.0
6+
numpy
7+
pybids==0.11.1
8+
templateflow==0.6

requirements.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Auto-generated by tools/update_requirements.py
2+
nibabel>=3.0.1
3+
niflow-nipype1-workflows~=0.0.1
4+
nipype<2.0,>=1.5.1
5+
niworkflows~=1.3.0
6+
numpy
7+
pybids>=0.11.1
8+
templateflow>=0.6

sdcflows/conftest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ def outdir():
4747

4848
@pytest.fixture
4949
def bids_layouts():
50-
return layouts
50+
if layouts:
51+
return layouts
52+
pytest.skip()
5153

5254

5355
@pytest.fixture

sdcflows/models/tests/test_pepolar.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Test pepolar type of fieldmaps."""
2+
import os
23
from pathlib import Path
34
from json import loads
45
import pytest
@@ -9,6 +10,7 @@
910
from ..pepolar import Workflow, init_topup_wf
1011

1112

13+
@pytest.mark.skipif(os.getenv("TRAVIS") == "true", reason="this is TravisCI")
1214
@pytest.mark.parametrize(
1315
"epi_path",
1416
[

sdcflows/models/tests/test_phdiff.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Test phase-difference type of fieldmaps."""
2+
import os
23
from pathlib import Path
34
from json import loads
45

@@ -9,6 +10,7 @@
910
from ..fieldmap import init_fmap_wf, Workflow
1011

1112

13+
@pytest.mark.skipif(os.getenv("TRAVIS") == "true", reason="this is TravisCI")
1214
@pytest.mark.parametrize(
1315
"fmap_path",
1416
[

setup.cfg

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ classifiers =
66
Intended Audience :: Science/Research
77
Topic :: Scientific/Engineering :: Image Recognition
88
License :: OSI Approved :: BSD License
9-
Programming Language :: Python :: 3.5
109
Programming Language :: Python :: 3.6
1110
Programming Language :: Python :: 3.7
11+
Programming Language :: Python :: 3.8
1212
description = Susceptibility Distortion Correction (SDC) workflows for EPI MR schemes.
1313
license = Apache-2.0
1414
long_description = file:README.rst
@@ -20,7 +20,7 @@ project_urls =
2020
url = https://www.nipreps.org/sdcflows
2121

2222
[options]
23-
python_requires = >=3.5
23+
python_requires = >=3.6
2424
setup_requires =
2525
setuptools >= 42.0
2626
setuptools_scm >= 3.4
@@ -56,8 +56,8 @@ docs =
5656
%(doc)s
5757
tests =
5858
pytest
59-
pytest-xdist
60-
pytest-cov == 2.5.1
59+
pytest-xdist >= 2.0
60+
pytest-cov == 2.10.1
6161
coverage
6262
all =
6363
%(doc)s

tools/update_requirements.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env python3
2+
from copy import copy
3+
from configparser import ConfigParser
4+
from pathlib import Path
5+
from packaging.requirements import Requirement, SpecifierSet
6+
7+
repo_root = Path(__file__).parent.parent
8+
setup_cfg = repo_root / "setup.cfg"
9+
reqs = repo_root / "requirements.txt"
10+
min_reqs = repo_root / "min-requirements.txt"
11+
12+
config = ConfigParser()
13+
config.read(setup_cfg)
14+
requirements = [Requirement(req)
15+
for req in config.get("options", "install_requires").strip().splitlines()]
16+
17+
script_name = Path(__file__).relative_to(repo_root)
18+
19+
20+
def to_min(req):
21+
if req.specifier:
22+
req = copy(req)
23+
min_spec = [spec for spec in req.specifier if spec.operator in ('>=', '~=')][0]
24+
min_spec._spec = ('==', ) + min_spec._spec[1:]
25+
req.specifier = SpecifierSet(str(min_spec))
26+
return req
27+
28+
29+
lines = [f"# Auto-generated by {script_name}", ""]
30+
31+
# Write requirements
32+
lines[1:-1] = [str(req) for req in requirements]
33+
reqs.write_text("\n".join(lines))
34+
35+
# Write minimum requirements
36+
lines[1:-1] = [str(to_min(req)) for req in requirements]
37+
min_reqs.write_text("\n".join(lines))

0 commit comments

Comments
 (0)