Skip to content

Commit 704b6fe

Browse files
committed
Merge remote-tracking branch 'upstream/master' into enh/FSLb0calc
2 parents 45ed6d3 + 99d191a commit 704b6fe

36 files changed

+984
-460
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ python:
88
env:
99
- INSTALL_DEB_DEPENDECIES=true
1010
- INSTALL_DEB_DEPENDECIES=false
11+
- INSTALL_DEB_DEPENDECIES=true DUECREDIT_ENABLE=yes
1112
before_install:
1213
- wget http://repo.continuum.io/miniconda/Miniconda${TRAVIS_PYTHON_VERSION:0:1}-latest-Linux-x86_64.sh
1314
-O /home/travis/.cache/miniconda.sh
@@ -32,6 +33,7 @@ install:
3233
# conda install -y vtk mayavi; fi
3334
- conda install -y nipype
3435
- pip install python-coveralls coverage doctest-ignore-unicode
36+
- if [ ! -z "$DUECREDIT_ENABLE"]; then pip install duecredit; fi
3537
- rm -r /home/travis/miniconda/lib/python${TRAVIS_PYTHON_VERSION}/site-packages/nipype*
3638
- pip install -r requirements.txt
3739
- pip install -e .

bin/nipype_crash_search

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
#!/usr/bin/env python
1+
#!python
22
"""Search for tracebacks inside a folder of nipype crash
33
log files that match a given regular expression.
44
55
Examples:
66
nipype_crash_search -d nipype/wd/log -r '.*subject123.*'
77
"""
88
import re
9+
import sys
910
import os.path as op
1011
from glob import glob
1112

@@ -60,6 +61,7 @@ def display_crash_search(logdir, regex):
6061

6162
if __name__ == "__main__":
6263
from argparse import ArgumentParser, RawTextHelpFormatter
64+
6365
defstr = ' (default %(default)s)'
6466
parser = ArgumentParser(prog='nipype_crash_search',
6567
description=__doc__,
@@ -71,6 +73,10 @@ if __name__ == "__main__":
7173
default='*',
7274
help='Regular expression to be searched in each traceback.' + defstr)
7375

74-
args = parser.parse_args()
76+
if len(sys.argv) == 1:
77+
parser.print_help()
78+
exit(0)
7579

80+
args = parser.parse_args()
7681
display_crash_search(args.logdir, args.regex)
82+
exit(0)

bin/nipype_display_pklz

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!python
2+
"""Prints the content of any .pklz file in your working directory.
3+
4+
Examples:
5+
6+
nipype_print_pklz _inputs.pklz
7+
nipype_print_pklz _node.pklz
8+
"""
9+
10+
def pprint_pklz_file(pklz_file):
11+
""" Print the content of the pklz_file. """
12+
from pprint import pprint
13+
from nipype.utils.filemanip import loadpkl
14+
15+
pkl_data = loadpkl(pklz_file)
16+
pprint(pkl_data)
17+
18+
19+
if __name__ == "__main__":
20+
21+
import sys
22+
from argparse import ArgumentParser, RawTextHelpFormatter
23+
24+
defstr = ' (default %(default)s)'
25+
parser = ArgumentParser(prog='nipype_print_pklz',
26+
description=__doc__,
27+
formatter_class=RawTextHelpFormatter)
28+
parser.add_argument('pklzfile', metavar='f', type=str,
29+
help='pklz file to display')
30+
31+
if len(sys.argv) == 1:
32+
parser.print_help()
33+
exit(0)
34+
35+
args = parser.parse_args()
36+
pprint_pklz_file(args.pklzfile)

circle.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,18 @@ dependencies:
2121
- if [[ -e ~/docker/image.tar ]]; then docker load -i ~/docker/image.tar; fi
2222
- docker build -f docker/nipype_test/Dockerfile_py35 -t nipype/nipype_test:py35 . :
2323
timeout: 1600
24-
- mkdir -p ~/docker; docker save nipype/nipype_test:py35 > ~/docker/image.tar :
24+
- docker build -f docker/nipype_test/Dockerfile_py27 -t nipype/nipype_test:py27 . :
2525
timeout: 1600
26+
- mkdir -p ~/docker; docker save nipype/nipype_test:py27 > ~/docker/image.tar :
27+
timeout: 1600
28+
- pip install xunitmerge
2629

2730
test:
2831
override:
2932
- docker run -v /etc/localtime:/etc/localtime:ro -v ~/scratch:/scratch -w /root/src/nipype/doc nipype/nipype_test:py35 /usr/bin/run_builddocs.sh
30-
- docker run -v /etc/localtime:/etc/localtime:ro -e FSL_COURSE_DATA="/root/examples/nipype-fsl_course_data" -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /root/src/nipype nipype/nipype_test:py35 /usr/bin/run_nosetests.sh :
33+
- docker run -v /etc/localtime:/etc/localtime:ro -e FSL_COURSE_DATA="/root/examples/nipype-fsl_course_data" -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /root/src/nipype nipype/nipype_test:py35 /usr/bin/run_nosetests.sh py35 :
34+
timeout: 2600
35+
- docker run -v /etc/localtime:/etc/localtime:ro -e FSL_COURSE_DATA="/root/examples/nipype-fsl_course_data" -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /root/src/nipype nipype/nipype_test:py27 /usr/bin/run_nosetests.sh py27 :
3136
timeout: 2600
3237
- docker run -v /etc/localtime:/etc/localtime:ro -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /scratch nipype/nipype_test:py35 /usr/bin/run_examples.sh test_spm Linear /root/examples/ workflow3d :
3338
timeout: 1600
@@ -39,15 +44,19 @@ test:
3944
- docker run -v /etc/localtime:/etc/localtime:ro -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /scratch nipype/nipype_test:py35 /usr/bin/run_examples.sh fmri_spm_dartel Linear /root/examples/ l2pipeline :
4045
timeout: 1600
4146
- docker run -v /etc/localtime:/etc/localtime:ro -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /scratch nipype/nipype_test:py35 /usr/bin/run_examples.sh fmri_fsl_reuse Linear /root/examples/ level1_workflow
42-
- docker run -v /etc/localtime:/etc/localtime:ro -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /scratch nipype/nipype_test:py35 /usr/bin/run_examples.sh fmri_spm_nested Linear /root/examples/ level1
43-
- docker run -v /etc/localtime:/etc/localtime:ro -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /scratch nipype/nipype_test:py35 /usr/bin/run_examples.sh fmri_spm_nested Linear /root/examples/ l2pipeline
47+
- docker run -v /etc/localtime:/etc/localtime:ro -e NIPYPE_NUMBER_OF_CPUS=4 -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /scratch nipype/nipype_test:py27 /usr/bin/run_examples.sh fmri_spm_nested MultiProc /root/examples/ level1
48+
- docker run -v /etc/localtime:/etc/localtime:ro -e NIPYPE_NUMBER_OF_CPUS=4 -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /scratch nipype/nipype_test:py35 /usr/bin/run_examples.sh fmri_spm_nested MultiProc /root/examples/ level1
49+
- docker run -v /etc/localtime:/etc/localtime:ro -e NIPYPE_NUMBER_OF_CPUS=4 -v ~/examples:/root/examples:ro -v ~/scratch:/scratch -w /scratch nipype/nipype_test:py35 /usr/bin/run_examples.sh fmri_spm_nested MultiProc /root/examples/ l2pipeline
50+
4451
post:
4552
- bash docker/circleci/teardown.sh
4653

4754
general:
4855
artifacts:
4956
- "~/docs"
5057
- "~/logs"
51-
- "~/coverage.xml"
52-
- "~/nosetests.xml"
58+
- "~/coverage_py27.xml"
59+
- "~/coverage_py35.xml"
60+
- "~/nosetests_py27.xml"
61+
- "~/nosetests_py35.xml"
5362
- "~/scratch"

doc/devel/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ conventions documented in the `NIPY Developers Guide
1919
architecture
2020
provenance
2121
software_using_nipype
22+
testing_nipype
2223

2324

2425
.. include:: ../links_names.txt

doc/devel/testing_nipype.rst

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
==============
2+
Testing nipype
3+
==============
4+
5+
In order to ensure the stability of each release of Nipype, the project uses two
6+
continuous integration services: `CircleCI <https://circleci.com/gh/nipy/nipype/tree/master>`_
7+
and `Travis CI <https://travis-ci.org/nipy/nipype>`_.
8+
If both batteries of tests are passing, the following badges should be shown in green color:
9+
10+
.. image:: https://travis-ci.org/nipy/nipype.png?branch=master
11+
:target: https://travis-ci.org/nipy/nipype
12+
13+
.. image:: https://circleci.com/gh/nipy/nipype/tree/master.svg?style=svg
14+
:target: https://circleci.com/gh/nipy/nipype/tree/master
15+
16+
17+
Tests implementation
18+
--------------------
19+
20+
Nipype testing framework is built upon `nose <http://nose.readthedocs.io/en/latest/>`_.
21+
By the time these guidelines are written, Nipype implements 17638 tests.
22+
23+
To run the tests locally, first get nose installed::
24+
25+
pip install nose
26+
27+
28+
Then, after nipype is `installed in developer mode <../users/install.html#nipype-for-developers>`_,
29+
the tests can be run with the following simple command::
30+
31+
make tests
32+
33+
34+
Skip tests
35+
----------
36+
37+
Nipype will skip some tests depending on the currently available software and data
38+
dependencies. Installing software dependencies and downloading the necessary data
39+
will reduce the number of skip tests.
40+
41+
Some tests in Nipype make use of some images distributed within the `FSL course data
42+
<http://fsl.fmrib.ox.ac.uk/fslcourse/>`_. This reduced version of the package can be downloaded `here
43+
<https://3552243d5be815c1b09152da6525cb8fe7b900a6.googledrive.com/host/0BxI12kyv2olZVUswazA3NkFvOXM/nipype-fsl_course_data.tar.gz>`_.
44+
To enable the tests depending on these data, just unpack the targz file and set the :code:`FSL_COURSE_DATA` environment
45+
variable to point to that folder.
46+
47+
48+
Testing Nipype using Docker
49+
---------------------------
50+
51+
As of :code:`nipype-0.13`, Nipype is tested inside Docker containers. Once the developer
52+
`has installed the Docker Engine <https://docs.docker.com/engine/installation/>`_, testing
53+
Nipype is as easy as follows::
54+
55+
cd path/to/nipype/
56+
docker build -f docker/nipype_test/Dockerfile_py27 -t nipype/nipype_test:py27
57+
docker run -it --rm -v /etc/localtime:/etc/localtime:ro \
58+
-e FSL_COURSE_DATA="/root/examples/nipype-fsl_course_data" \
59+
-v ~/examples:/root/examples:ro \
60+
-v ~/scratch:/scratch \
61+
-w /root/src/nipype \
62+
nipype/nipype_test:py27 /usr/bin/run_nosetests.sh
63+
64+
For running nipype in Python 3.5::
65+
66+
cd path/to/nipype/
67+
docker build -f docker/nipype_test/Dockerfile_py35 -t nipype/nipype_test:py35
68+
docker run -it --rm -v /etc/localtime:/etc/localtime:ro \
69+
-e FSL_COURSE_DATA="/root/examples/nipype-fsl_course_data" \
70+
-v ~/examples:/root/examples:ro \
71+
-v ~/scratch:/scratch \
72+
-w /root/src/nipype \
73+
nipype/nipype_test:py35 /usr/bin/run_nosetests.sh

docker/circleci/run_nosetests.sh

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,35 @@ set -e
33
set -x
44
set -u
55

6+
PYTHON_VERSION=$( python -c "import sys; print('{}{}'.format(sys.version_info[0], sys.version_info[1]))" )
7+
68
# Create necessary directories
7-
mkdir -p /scratch/nose /scratch/crashfiles
9+
mkdir -p /scratch/nose /scratch/crashfiles /scratch/logs/py${PYTHON_VERSION}
810

911
# Create a nipype config file
1012
mkdir -p /root/.nipype
1113
echo '[logging]' > /root/.nipype/nipype.cfg
1214
echo 'log_to_file = true' >> /root/.nipype/nipype.cfg
13-
echo 'log_directory = /scratch/logs/' >> /root/.nipype/nipype.cfg
15+
echo "log_directory = /scratch/logs/py${PYTHON_VERSION}" >> /root/.nipype/nipype.cfg
1416

17+
# Enable profile_runtime tests only for python 2.7
18+
if [[ "${PYTHON_VERSION}" -lt "30" ]]; then
19+
echo '[execution]' >> /root/.nipype/nipype.cfg
20+
echo 'profile_runtime = true' >> /root/.nipype/nipype.cfg
21+
fi
1522

1623
# Run tests
1724
cd /root/src/nipype/
1825
make clean
19-
nosetests -s nipype -c /root/src/nipype/.noserc --xunit-file="/scratch/nosetests.xml" --cover-xml-file="/scratch/coverage.xml"
26+
nosetests -s nipype -c /root/src/nipype/.noserc --xunit-file="/scratch/nosetests_py${PYTHON_VERSION}.xml" --cover-xml-file="/scratch/coverage_py${PYTHON_VERSION}.xml"
27+
28+
# Workaround: run here the profiler tests in python 3
29+
if [[ "${PYTHON_VERSION}" -ge "30" ]]; then
30+
echo '[execution]' >> /root/.nipype/nipype.cfg
31+
echo 'profile_runtime = true' >> /root/.nipype/nipype.cfg
32+
nosetests nipype/interfaces/tests/test_runtime_profiler.py --xunit-file="/scratch/nosetests_py${PYTHON_VERSION}_profiler.xml" --cover-xml-file="/scratch/coverage_py${PYTHON_VERSION}_profiler.xml"
33+
nosetests nipype/pipeline/plugins/tests/test_multiproc*.py --xunit-file="/scratch/nosetests_py${PYTHON_VERSION}_multiproc.xml" --cover-xml-file="/scratch/coverage_py${PYTHON_VERSION}_multiproc.xml"
34+
fi
2035

2136
# Copy crashfiles to scratch
2237
for i in $(find /root/src/nipype/ -name "crash-*" ); do cp $i /scratch/crashfiles/; done

docker/circleci/teardown.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ set -u
77
set -e
88

99
mkdir -p ${CIRCLE_TEST_REPORTS}/nose
10-
sudo cp ~/scratch/nosetests.xml ${CIRCLE_TEST_REPORTS}/nose/${CIRCLE_PROJECT_REPONAME}.xml
11-
sudo mv ~/scratch/coverage.xml ~/coverage.xml
10+
xunitmerge ~/scratch/nosetests*.xml ${CIRCLE_TEST_REPORTS}/nose/${CIRCLE_PROJECT_REPONAME}.xml
11+
sudo mv ~/scratch/coverage*.xml ~/
1212
mkdir -p ~/docs
1313
sudo mv ~/scratch/docs/* ~/docs/
1414
mkdir -p ~/logs

docker/nipype_test/Dockerfile_base

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,37 @@ RUN curl -sSL http://www.fil.ion.ucl.ac.uk/spm/download/restricted/utopia/dev/sp
9191
unzip spm12.zip && \
9292
rm -rf spm12.zip
9393

94-
ENV MATLABCMD "/opt/mcr/v85/toolbox/matlab" \
95-
SPMMCRCMD "/opt/spm12/run_spm12.sh /opt/mcr/v85/ script" \
96-
FORCE_SPMMCR 1
94+
ENV MATLABCMD="/opt/mcr/v85/toolbox/matlab" \
95+
SPMMCRCMD="/opt/spm12/run_spm12.sh /opt/mcr/v85/ script" \
96+
FORCE_SPMMCR=1
9797

98+
WORKDIR /root
99+
# Install miniconda
100+
RUN curl -sSLO https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
101+
/bin/bash Miniconda3-latest-Linux-x86_64.sh -b -p /usr/local/miniconda && \
102+
rm Miniconda3-latest-Linux-x86_64.sh
98103

99-
CMD ["/bin/bash"]
104+
ENV PATH /usr/local/miniconda/bin:$PATH
105+
106+
# http://bugs.python.org/issue19846
107+
# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK.
108+
ENV LANG=C.UTF-8 \
109+
LC_ALL=C.UTF-8
100110

111+
# Add conda-forge channel in conda
112+
RUN conda config --add channels conda-forge && \
113+
conda install -y lockfile \
114+
nipype \
115+
matplotlib \
116+
sphinx \
117+
boto \
118+
boto3 \
119+
coverage \
120+
mock \
121+
pbr \
122+
nitime \
123+
dipy \
124+
pandas && \
125+
pip install nose-cov doctest-ignore-unicode configparser
126+
127+
CMD ["/bin/bash"]

docker/nipype_test/Dockerfile_py27

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,43 +26,26 @@
2626
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2727
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828

29-
FROM nipype/nipype_test:base
29+
FROM nipype/nipype_test:base-0.0.2
3030
MAINTAINER The nipype developers https://github.com/nipy/nipype
31-
# Preparations
32-
RUN ln -snf /bin/bash /bin/sh
33-
WORKDIR /root
3431

35-
# Install miniconda
36-
RUN curl -sSLO https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh && \
37-
/bin/bash Miniconda-latest-Linux-x86_64.sh -b -p /usr/local/miniconda && \
38-
rm Miniconda-latest-Linux-x86_64.sh
39-
40-
ENV PATH /usr/local/miniconda/bin:$PATH
41-
42-
# http://bugs.python.org/issue19846
43-
# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK.
44-
ENV LANG C.UTF-8
45-
ENV LC_ALL C.UTF-8
46-
47-
# Add conda-forge channel in conda
48-
RUN conda config --add channels conda-forge && \
49-
conda install -y lockfile nipype matplotlib sphinx boto boto3 coverage mock pbr nitime dipy && \
32+
# Downgrade python to 2.7
33+
RUN conda update -y conda && \
34+
conda update --all -y python=2.7 && \
5035
pip install nose-cov doctest-ignore-unicode configparser
51-
36+
5237
COPY docker/circleci/run_* /usr/bin/
5338
RUN chmod +x /usr/bin/run_*
5439

40+
# Speed up building
5541
RUN mkdir -p /root/src/nipype
56-
COPY . /root/src/nipype
42+
COPY requirements.txt /root/src/nipype/requirements.txt
43+
RUN pip install -r /root/src/nipype/requirements.txt
5744

45+
# Re-install nipype
46+
COPY . /root/src/nipype
5847
RUN rm -r /usr/local/miniconda/lib/python2.7/site-packages/nipype* && \
5948
cd /root/src/nipype && \
60-
pip install -r requirements.txt && \
61-
pip install -e . && \
62-
make specs
63-
64-
# Replace imglob with Python3 compatible version
65-
RUN rm -r ${FSLDIR}/bin/imglob && \
66-
ln -s $(which fsl_imglob.py) ${FSLDIR}/bin/imglob
49+
pip install -e .
6750

6851
CMD ["/bin/bash"]

0 commit comments

Comments
 (0)