Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TEST: Parallelize pytest #2469

Merged
merged 7 commits into from
Mar 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions nipype/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@


class NipypeTester(object):
def __call__(self, doctests=True):
def __call__(self, doctests=True, parallel=True):
try:
import pytest
except:
raise RuntimeError(
'py.test not installed, run: pip install pytest')
params = {'args': []}
if doctests:
params['args'].append('--doctest-modules')
nipype_path = os.path.dirname(__file__)
params['args'].extend(
['-x', '--ignore={}/external'.format(nipype_path), nipype_path])
pytest.main(**params)
args = []
if not doctests:
args.extend(['-p', 'no:doctest'])
if not parallel:
args.append('-n0')
args.append(os.path.dirname(__file__))
pytest.main(args=args)


test = NipypeTester()
Expand Down
7 changes: 0 additions & 7 deletions nipype/algorithms/confounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@
# vi: set ft=python sts=4 ts=4 sw=4 et:
'''
Algorithms to compute confounds in :abbr:`fMRI (functional MRI)`

Change directory to provide relative paths for doctests
>>> import os
>>> filepath = os.path.dirname(os.path.realpath(__file__))
>>> datadir = os.path.realpath(os.path.join(filepath, '../testing/data'))
>>> os.chdir(datadir)

'''
from __future__ import (print_function, division, unicode_literals,
absolute_import)
Expand Down
8 changes: 0 additions & 8 deletions nipype/algorithms/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@
# vi: set ft=python sts=4 ts=4 sw=4 et:
"""
Miscellaneous algorithms for 2D contours and 3D triangularized meshes handling

.. testsetup::
# Change directory to provide relative paths for doctests
>>> import os
>>> filepath = os.path.dirname(os.path.realpath( __file__ ))
>>> datadir = os.path.realpath(os.path.join(filepath, '../testing/data'))
>>> os.chdir(datadir)

"""
from __future__ import (print_function, division, unicode_literals,
absolute_import)
Expand Down
7 changes: 0 additions & 7 deletions nipype/algorithms/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@
'''
Image assessment algorithms. Typical overlap and error computation
measures to evaluate results from other processing units.

Change directory to provide relative paths for doctests
>>> import os
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
>>> datadir = os.path.realpath(os.path.join(filepath, '../testing/data'))
>>> os.chdir(datadir)

'''
from __future__ import (print_function, division, unicode_literals,
absolute_import)
Expand Down
7 changes: 0 additions & 7 deletions nipype/algorithms/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@
# vi: set ft=python sts=4 ts=4 sw=4 et:
'''
Miscellaneous algorithms

Change directory to provide relative paths for doctests
>>> import os
>>> filepath = os.path.dirname(os.path.realpath(__file__))
>>> datadir = os.path.realpath(os.path.join(filepath, '../testing/data'))
>>> os.chdir(datadir)

'''
from __future__ import (print_function, division, unicode_literals,
absolute_import)
Expand Down
7 changes: 0 additions & 7 deletions nipype/algorithms/modelgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@
These functions include:

* SpecifyModel: allows specification of sparse and non-sparse models

Change directory to provide relative paths for doctests
>>> import os
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
>>> datadir = os.path.realpath(os.path.join(filepath, '../testing/data'))
>>> os.chdir(datadir)

"""
from __future__ import (print_function, division, unicode_literals,
absolute_import)
Expand Down
6 changes: 0 additions & 6 deletions nipype/algorithms/rapidart.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@

* StimulusCorrelation: determines correlation between stimuli
schedule and movement/intensity parameters

Change directory to provide relative paths for doctests
>>> import os
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
>>> datadir = os.path.realpath(os.path.join(filepath, '../testing/data'))
>>> os.chdir(datadir)
"""
from __future__ import (print_function, division, unicode_literals,
absolute_import)
Expand Down
6 changes: 0 additions & 6 deletions nipype/caching/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
"""
Using nipype with persistence and lazy recomputation but without explicit
name-steps pipeline: getting back scope in command-line based programming.

Change directory to provide relative paths for doctests
>>> import os
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
>>> datadir = os.path.realpath(os.path.join(filepath, '../testing/data'))
>>> os.chdir(datadir)
"""
from __future__ import (print_function, division, unicode_literals,
absolute_import)
Expand Down
14 changes: 11 additions & 3 deletions nipype/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
import numpy
import os

DATADIR = os.path.realpath(
os.path.join(os.path.dirname(__file__), 'testing/data'))


@pytest.fixture(autouse=True)
def add_np(doctest_namespace):
doctest_namespace['np'] = numpy
doctest_namespace['os'] = os

filepath = os.path.dirname(os.path.realpath(__file__))
datadir = os.path.realpath(os.path.join(filepath, 'testing/data'))
doctest_namespace["datadir"] = datadir
doctest_namespace["datadir"] = DATADIR


@pytest.fixture(autouse=True)
def in_testing(request):
# This seems to be a reliable way to distinguish tests from doctests
if request.function is None:
os.chdir(DATADIR)
2 changes: 1 addition & 1 deletion nipype/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def get_nipype_gitversion():
if sys.version_info <= (3, 4):
REQUIRES.append('configparser')

TESTS_REQUIRES = ['pytest-cov', 'codecov']
TESTS_REQUIRES = ['pytest-cov', 'codecov', 'pytest-xdist', 'pytest-env']

EXTRA_REQUIRES = {
'doc': ['Sphinx>=1.4', 'numpydoc', 'matplotlib', 'pydotplus', 'pydot>=1.2.3'],
Expand Down
5 changes: 0 additions & 5 deletions nipype/interfaces/afni/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
Examples
--------
See the docstrings of the individual classes for examples.
.. testsetup::
# Change directory to provide relative paths for doctests
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
>>> os.chdir(datadir)
"""
from __future__ import (print_function, division, unicode_literals,
absolute_import)
Expand Down
6 changes: 0 additions & 6 deletions nipype/interfaces/afni/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
"""AFNI preprocessing interfaces

Change directory to provide relative paths for doctests
>>> import os
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
>>> os.chdir(datadir)
"""
from __future__ import (print_function, division, unicode_literals,
absolute_import)
Expand Down
6 changes: 0 additions & 6 deletions nipype/interfaces/afni/svm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft = python sts = 4 ts = 4 sw = 4 et:
"""Afni svm interfaces

Change directory to provide relative paths for doctests
>>> import os
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
>>> os.chdir(datadir)
"""
from __future__ import (print_function, division, unicode_literals,
absolute_import)
Expand Down
5 changes: 0 additions & 5 deletions nipype/interfaces/afni/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
Examples
--------
See the docstrings of the individual classes for examples.
.. testsetup::
# Change directory to provide relative paths for doctests
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
>>> os.chdir(datadir)
"""
from __future__ import (print_function, division, unicode_literals,
absolute_import)
Expand Down
6 changes: 0 additions & 6 deletions nipype/interfaces/ants/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
# of the antsApplyTransform program. This implementation is here
# for backwards compatibility.
"""ANTS Apply Transforms interface

Change directory to provide relative paths for doctests
>>> import os
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
>>> os.chdir(datadir)
"""

from builtins import range
Expand Down
6 changes: 0 additions & 6 deletions nipype/interfaces/ants/registration.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
# -*- coding: utf-8 -*-
"""The ants module provides basic functions for interfacing with ants
functions.

Change directory to provide relative paths for doctests
>>> import os
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
>>> os.chdir(datadir)
"""
from __future__ import (print_function, division, unicode_literals,
absolute_import)
Expand Down
6 changes: 0 additions & 6 deletions nipype/interfaces/ants/resampling.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# -*- coding: utf-8 -*-
"""ANTS Apply Transforms interface

Change directory to provide relative paths for doctests
>>> import os
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
>>> os.chdir(datadir)
"""
from __future__ import (print_function, division, unicode_literals,
absolute_import)
Expand Down
7 changes: 0 additions & 7 deletions nipype/interfaces/ants/segmentation.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
# -*- coding: utf-8 -*-
"""The ants module provides basic functions for interfacing with ants functions.

Change directory to provide relative paths for doctests
>>> import os
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
>>> os.chdir(datadir)

"""
from __future__ import (print_function, division, unicode_literals,
absolute_import)
Expand Down
6 changes: 0 additions & 6 deletions nipype/interfaces/ants/utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# -*- coding: utf-8 -*-
"""ANTS Apply Transforms interface

Change directory to provide relative paths for doctests
>>> import os
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
>>> os.chdir(datadir)
"""
from __future__ import (print_function, division, unicode_literals,
absolute_import)
Expand Down
5 changes: 0 additions & 5 deletions nipype/interfaces/ants/visualization.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# -*- coding: utf-8 -*-
"""The ants visualisation module provides basic functions based on ITK.
Change directory to provide relative paths for doctests
>>> import os
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
>>> os.chdir(datadir)
"""
from __future__ import (print_function, division, unicode_literals,
absolute_import)
Expand Down
6 changes: 0 additions & 6 deletions nipype/interfaces/bru2nii.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# -*- coding: utf-8 -*-
"""The bru2nii module provides basic functions for dicom conversion

Change directory to provide relative paths for doctests
>>> import os
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
>>> datadir = os.path.realpath(os.path.join(filepath, '../testing/data'))
>>> os.chdir(datadir)
"""
from __future__ import (print_function, division, unicode_literals,
absolute_import)
Expand Down
6 changes: 0 additions & 6 deletions nipype/interfaces/c3.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
# -*- coding: utf-8 -*-
"""The ants module provides basic functions for interfacing with ants
functions.

Change directory to provide relative paths for doctests
>>> import os
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
>>> datadir = os.path.realpath(os.path.join(filepath, '../testing/data'))
>>> os.chdir(datadir)
"""
from __future__ import (print_function, division, unicode_literals,
absolute_import)
Expand Down
8 changes: 0 additions & 8 deletions nipype/interfaces/camino/calib.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
# -*- coding: utf-8 -*-
"""
Change directory to provide relative paths for doctests
>>> import os
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
>>> os.chdir(datadir)

"""
from __future__ import (print_function, division, unicode_literals,
absolute_import)

Expand Down
8 changes: 0 additions & 8 deletions nipype/interfaces/camino/connectivity.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
# -*- coding: utf-8 -*-
"""
Change directory to provide relative paths for doctests
>>> import os
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
>>> os.chdir(datadir)

"""
from __future__ import (print_function, division, unicode_literals,
absolute_import)
import os
Expand Down
8 changes: 0 additions & 8 deletions nipype/interfaces/camino/convert.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
# -*- coding: utf-8 -*-
"""
Change directory to provide relative paths for doctests
>>> import os
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
>>> os.chdir(datadir)

"""
from __future__ import (print_function, division, unicode_literals,
absolute_import)

Expand Down
8 changes: 0 additions & 8 deletions nipype/interfaces/camino/dti.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
# -*- coding: utf-8 -*-
"""
Change directory to provide relative paths for doctests
>>> import os
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
>>> os.chdir(datadir)

"""
from __future__ import (print_function, division, unicode_literals,
absolute_import)

Expand Down
8 changes: 0 additions & 8 deletions nipype/interfaces/camino/odf.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
# -*- coding: utf-8 -*-
"""
Change directory to provide relative paths for doctests
>>> import os
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
>>> os.chdir(datadir)

"""
from __future__ import (print_function, division, unicode_literals,
absolute_import)

Expand Down
8 changes: 0 additions & 8 deletions nipype/interfaces/camino/utils.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
# -*- coding: utf-8 -*-
"""
Change directory to provide relative paths for doctests
>>> import os
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
>>> os.chdir(datadir)

"""
from __future__ import (print_function, division, unicode_literals,
absolute_import)
import os
Expand Down
7 changes: 0 additions & 7 deletions nipype/interfaces/camino2trackvis/convert.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
# -*- coding: utf-8 -*-
"""
Provides interfaces to various commands provided by Camino-Trackvis

Change directory to provide relative paths for doctests
>>> import os
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
>>> os.chdir(datadir)

"""
from __future__ import (print_function, division, unicode_literals,
absolute_import)
Expand Down
Loading