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

fix+tst: ensure no pybids does not break testing #2248

Merged
merged 10 commits into from
Oct 28, 2017
Merged

Conversation

mgxd
Copy link
Member

@mgxd mgxd commented Oct 23, 2017

Fixes #2246 .

Changes proposed in this pull request

>>> results = bg.run()
>>> basename(results.outputs.anat[0]) # doctest: +ALLOW_UNICODE
'sub-01_T1w.nii.gz'
>>> bg = BIDSDataGrabber() # doctest: +SKIP
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need doctest skip on everything.

>>> basename(results.outputs.anat[0]) # doctest: +ALLOW_UNICODE
'sub-01_T1w.nii.gz'
>>> bg = BIDSDataGrabber() # doctest: +SKIP
>>> bg.inputs.base_dir = 'ds005/' # doctest: +SKIP
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could add a dummy directory with a fake file or reuse an existing directory from the testing/data folder

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we want to add more testing data to nipype? we'll need a dedicated bids layout for grabbids

>>> import bids
>>> filepath = os.path.realpath(os.path.dirname(bids.__file__))
>>> datadir = os.path.realpath(os.path.join(filepath, 'grabbids/tests/data/'))
>>> os.chdir(datadir)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can replace this with the standard header that changes to the testing/data folder.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't we skipping these tests anyways since it would require pybids to be installed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct, but we can make a directory ds005 with a dummy file (since git does not store empty directories), just not call the bidsgrabber run function. we won't actually call pybids here.

reason="Pybids is not installed")
@pytest.mark.skipif(sys.version_info < (3, 0),
reason="Pybids no longer supports Python 2")
@pytest.mark.skipif(not dist_is_editable('pybids'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this bit necessary?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from the initial #2174 - that's how the testing data was done

also #2207

>>> bg.inputs.output_query['dwi'] = dict(modality='dwi') # doctest: +SKIP
>>> results = bg.run() # doctest: +SKIP
>>> basename(results.outputs.dwi[0]) # doctest: +SKIP
'sub-01_dwi.nii.gz' # doctest: +SKIP
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comments as above.

@codecov-io
Copy link

codecov-io commented Oct 24, 2017

Codecov Report

Merging #2248 into master will increase coverage by 0.01%.
The diff coverage is 90.47%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2248      +/-   ##
==========================================
+ Coverage   72.32%   72.33%   +0.01%     
==========================================
  Files        1183     1184       +1     
  Lines       59008    59048      +40     
  Branches     8490     8492       +2     
==========================================
+ Hits        42679    42715      +36     
- Misses      14945    14948       +3     
- Partials     1384     1385       +1
Flag Coverage Δ
#smoketests 72.33% <90.47%> (+0.01%) ⬆️
#unittests 69.91% <90.47%> (+0.01%) ⬆️
Impacted Files Coverage Δ
nipype/interfaces/bids_utils.py 81.03% <100%> (ø) ⬆️
nipype/utils/filemanip.py 84.71% <66.66%> (-0.36%) ⬇️
nipype/interfaces/tests/test_bids.py 94.11% <94.11%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 96c359d...78c15e4. Read the comment docs.

@codecov-io
Copy link

codecov-io commented Oct 24, 2017

Codecov Report

Merging #2248 into master will increase coverage by 0.01%.
The diff coverage is 87.5%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2248      +/-   ##
==========================================
+ Coverage   72.32%   72.34%   +0.01%     
==========================================
  Files        1185     1186       +1     
  Lines       59036    59077      +41     
  Branches     8491     8493       +2     
==========================================
+ Hits        42700    42739      +39     
- Misses      14952    14953       +1     
- Partials     1384     1385       +1
Flag Coverage Δ
#smoketests 72.34% <87.5%> (+0.01%) ⬆️
#unittests 69.92% <87.5%> (+0.01%) ⬆️
Impacted Files Coverage Δ
nipype/interfaces/tests/test_resource_monitor.py 60.97% <100%> (+0.97%) ⬆️
nipype/utils/filemanip.py 84.71% <66.66%> (-0.36%) ⬇️
nipype/interfaces/bids_utils.py 81.03% <71.42%> (ø) ⬆️
nipype/interfaces/tests/test_bids.py 94.11% <94.11%> (ø)
nipype/utils/profiler.py 41.56% <0%> (+1.2%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1a74013...20eccd3. Read the comment docs.

@mgxd
Copy link
Member Author

mgxd commented Oct 24, 2017

There seems to be a mismatch in Travis' 3.4 build, which looks to be silently failing in older PRs as well...
perhaps the conda-forge channel should be added earlier to ensure no download of ipaddress

The following packages will be UPDATED:
 conda: 4.3.27-py36h2866c0b_0 --> 4.3.30-py36h5d9f9f4_0
Fetching package metadata ...........
Solving package specifications: .
UnsatisfiableError: The following specifications were found to be in conflict:
 - python 3.4*
 - urllib3 -> ipaddress -> python 2.7*
Use "conda info <package>" to see the dependencies for each package.

.travis.yml Outdated
conda config --add channels conda-forge &&
conda install python=${TRAVIS_PYTHON_VERSION} &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now that we can install almost any python dependencies with pip, would it make sense to simplify this for the time being to just installing with pip -y -r requirements.txt instead of using conda install in the next step.

>>> bg.inputs.base_dir = 'ds005/'
>>> bg.inputs.subject = '01'
>>> results = bg.run()
>>> basename(results.outputs.anat[0]) # doctest: +ALLOW_UNICODE
>>> results = bg.run() # doctest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skip this and remove the next step.

By default, the BIDSDataGrabber fetches anatomical and functional images
from a project, and makes BIDS entities (e.g. subject) available for
filtering outputs.

>>> bg = BIDSDataGrabber()
>>> bg = BIDSDataGrabber() # doctest: +SKIP
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't skip this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bidsdatagrabber should initialize without pybids, just not run without it.

talking of which it would be useful in run_interface to do:

if not have_pybids:
    raise ImportError('Could not import pybids')

@mgxd mgxd added this to the 0.14.0 milestone Oct 24, 2017

"""
input_spec = BIDSDataGrabberInputSpec
output_spec = DynamicTraitedSpec
_always_run = True

def __init__(self, infields=None, **kwargs):
def __init__(self, infields=[], **kwargs):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would revert this and check for not infields is None

@@ -123,13 +107,17 @@ def __init__(self, infields=None, **kwargs):

# used for mandatory inputs check
undefined_traits = {}
for key in infields:
for key in infields or []:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be done in list outputs as well.

and travis tests are not testing the have_bids==True branch.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@satra this might be required here, since it's using **kwargs and setting traits

@satra satra merged commit 1a4efff into nipy:master Oct 28, 2017
@satra satra modified the milestone: 0.14.0 Oct 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants