Repository: nipy/nipype

Issue:
py.test takes much longer to run on circle relative to travis
py.test takes 39 minutes on circle and about 8 minutes on travis.


Discussion:
I think this is a function of tests not being skipped, since Circle has more software bundled.
i need to time all the tests. i used to run things with all software installed, and the tests would still run in a reasonable time.
The bedpostx test and the tbss rest are run only in circle (and are long), but they may not account for that large difference.
just downloaded the `nipype/nipype:py36` container and ran the test locally:

`
============= 2893 passed, 54 skipped, 7 xfailed, 16 warnings in 783.33 seconds =============`

will now run pytest script exactly.
So Circle does seem to have somewhat underpowered hardware. I guess we could add an entry to the config to print out the CPU and memory info, just to verify. Are there any prospects for reducing runtime apart from disabling tests? Does pytest allow parallelism, or could we hack it to create a pytest command for each file independently and use `parallel` to chug through a little faster?
@effigies - i have one more test to do: the FSL_COURSE_DATA was not mounted into the container and resource_monitoring was off. 

but if the tests associated with the FSL_COURSE_DATA is indeed the reason, we should not really be doing full scale imaging workflow runs in the pytest modules but rather via the examples. the pytests should be really lightweight and mostly be about covering our code rather than external interactions.

will post soon
yup, the differences come from four tbss tests.

`============ 2897 passed, 50 skipped, 7 xfailed, 16 warnings in 2153.62 seconds =============`

i'll try to refactor these out into examples.
ok so the regression tests that @oesteban added for the dmri/fsl workflows are indeed what takes longer. i think we should split these tests out of the unittest module. they could be added to smoketests via examples, but more generally at least for workflows we should create additional regression tests. 

this would be true of recon-all and others in addition to these.  given that these tests take a while to run, we should also be intelligent about when they are tested. we could try to create a system where we figure out which interfaces/workflows are affected by a code change. this could trigger a few or many of these examples to run. this is also what this project is going to partially support: https://github.com/ReproNim/regtests

for the moment, we could skip these tests to reduce the time of at least one of the containers on circle.

@oesteban  and @effigies : what do you think?
That seems reasonable.

Resolving patch:
diff --git a/nipype/workflows/dmri/fsl/tbss.py b/nipype/workflows/dmri/fsl/tbss.py
--- a/nipype/workflows/dmri/fsl/tbss.py
+++ b/nipype/workflows/dmri/fsl/tbss.py
@@ -264,8 +264,11 @@ def create_tbss_3_postreg(name='tbss_3_postreg', estimate_skeleton=True):
         # $FSLDIR/bin/fslmaths $FSLDIR/data/standard/FMRIB58_FA_1mm -mas mean_FA_mask mean_FA
         maskstd = pe.Node(
             fsl.ImageMaths(op_string="-mas", suffix="_masked"), name="maskstd")
-        maskstd.inputs.in_file = fsl.Info.standard_image(
-            "FMRIB58_FA_1mm.nii.gz")
+        if fsl.no_fsl():
+            warn('NO FSL found')
+        else:
+            maskstd.inputs.in_file = fsl.Info.standard_image(
+                "FMRIB58_FA_1mm.nii.gz")
 
         # $FSLDIR/bin/fslmaths mean_FA -bin mean_FA_mask
         binmaskstd = pe.Node(
@@ -281,8 +284,11 @@ def create_tbss_3_postreg(name='tbss_3_postreg', estimate_skeleton=True):
                        (maskgroup, maskgroup2, [("out_file", "in_file")]),
                        (binmaskstd, maskgroup2, [("out_file", "in_file2")])])
 
-        outputnode.inputs.skeleton_file = fsl.Info.standard_image(
-            "FMRIB58_FA-skeleton_1mm.nii.gz")
+        if fsl.no_fsl():
+            warn('NO FSL found')
+        else:
+            outputnode.inputs.skeleton_file = fsl.Info.standard_image(
+                "FMRIB58_FA-skeleton_1mm.nii.gz")
         tbss3.connect([(binmaskstd, outputnode, [('out_file', 'groupmask')]),
                        (maskstd, outputnode, [('out_file', 'meanfa_file')]),
                        (maskgroup2, outputnode, [('out_file',
@@ -387,8 +393,14 @@ def create_tbss_all(name='tbss_all', estimate_skeleton=True):
     -------
 
     >>> from nipype.workflows.dmri.fsl import tbss
-    >>> tbss = tbss.create_tbss_all('tbss')
-    >>> tbss.inputs.inputnode.skeleton_thresh = 0.2
+    >>> tbss_wf = tbss.create_tbss_all('tbss', estimate_skeleton=True)
+    >>> tbss_wf.inputs.inputnode.skeleton_thresh = 0.2
+    >>> tbss_wf.inputs.inputnode.fa_list = ['s1_wrapped_FA.nii', 's2_wrapped_FA.nii', 's3_wrapped_FA.nii']
+
+    >>> tbss_wf = tbss.create_tbss_all('tbss', estimate_skeleton=False)
+    >>> tbss_wf.inputs.inputnode.skeleton_thresh = 0.2
+    >>> tbss_wf.inputs.inputnode.fa_list = ['s1_wrapped_FA.nii', 's2_wrapped_FA.nii', 's3_wrapped_FA.nii']
+
 
     Inputs::
 


Test patch:
diff --git a/.circleci/test_py2_pytest.sh b/.circleci/test_py2_pytest.sh
--- a/.circleci/test_py2_pytest.sh
+++ b/.circleci/test_py2_pytest.sh
@@ -1,3 +1,3 @@
 #!/bin/bash
 
-docker run --rm=false -t -v $WORKDIR:/work -v $HOME/examples:/data/examples:ro -w /work -e CI_SKIP_TEST=1 -e NIPYPE_RESOURCE_MONITOR=1 -e FSL_COURSE_DATA="/data/examples/nipype-fsl_course_data" "${DOCKER_IMAGE}:py27" /usr/bin/run_pytests.sh
+docker run --rm=false -t -v $WORKDIR:/work -v $HOME/examples:/data/examples:ro -w /work -e CI_SKIP_TEST=1 -e NIPYPE_RESOURCE_MONITOR=1 "${DOCKER_IMAGE}:py27" /usr/bin/run_pytests.sh
diff --git a/.circleci/test_py3_pytest.sh b/.circleci/test_py3_pytest.sh
--- a/.circleci/test_py3_pytest.sh
+++ b/.circleci/test_py3_pytest.sh
@@ -1,3 +1,3 @@
 #!/bin/bash
 
-docker run --rm=false -t -v $WORKDIR:/work -v $HOME/examples:/data/examples:ro -w /work -e CI_SKIP_TEST=1 -e NIPYPE_RESOURCE_MONITOR=1 -e FSL_COURSE_DATA="/data/examples/nipype-fsl_course_data"  "${DOCKER_IMAGE}:py36" /usr/bin/run_pytests.sh
+docker run --rm=false -t -v $WORKDIR:/work -v $HOME/examples:/data/examples:ro -w /work -e CI_SKIP_TEST=1 -e NIPYPE_RESOURCE_MONITOR=1 "${DOCKER_IMAGE}:py36" /usr/bin/run_pytests.sh