-
Notifications
You must be signed in to change notification settings - Fork 525
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
Conversation
nipype/interfaces/bids_utils.py
Outdated
>>> results = bg.run() | ||
>>> basename(results.outputs.anat[0]) # doctest: +ALLOW_UNICODE | ||
'sub-01_T1w.nii.gz' | ||
>>> bg = BIDSDataGrabber() # doctest: +SKIP |
There was a problem hiding this comment.
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.
nipype/interfaces/bids_utils.py
Outdated
>>> basename(results.outputs.anat[0]) # doctest: +ALLOW_UNICODE | ||
'sub-01_T1w.nii.gz' | ||
>>> bg = BIDSDataGrabber() # doctest: +SKIP | ||
>>> bg.inputs.base_dir = 'ds005/' # doctest: +SKIP |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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'), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nipype/interfaces/bids_utils.py
Outdated
>>> 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 |
There was a problem hiding this comment.
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 Report
@@ 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
Continue to review full report at Codecov.
|
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
There seems to be a mismatch in Travis' 3.4 build, which looks to be silently failing in older PRs as well...
|
.travis.yml
Outdated
conda config --add channels conda-forge && | ||
conda install python=${TRAVIS_PYTHON_VERSION} && |
There was a problem hiding this comment.
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.
nipype/interfaces/bids_utils.py
Outdated
>>> bg.inputs.base_dir = 'ds005/' | ||
>>> bg.inputs.subject = '01' | ||
>>> results = bg.run() | ||
>>> basename(results.outputs.anat[0]) # doctest: +ALLOW_UNICODE | ||
>>> results = bg.run() # doctest |
There was a problem hiding this comment.
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.
nipype/interfaces/bids_utils.py
Outdated
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't skip this.
There was a problem hiding this comment.
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')
…ncies from requirements.txt
nipype/interfaces/bids_utils.py
Outdated
|
||
""" | ||
input_spec = BIDSDataGrabberInputSpec | ||
output_spec = DynamicTraitedSpec | ||
_always_run = True | ||
|
||
def __init__(self, infields=None, **kwargs): | ||
def __init__(self, infields=[], **kwargs): |
There was a problem hiding this comment.
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
nipype/interfaces/bids_utils.py
Outdated
@@ -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 []: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Fixes #2246 .
Changes proposed in this pull request
tests/test_bids.py
, with skips for Raise exception if BIDSDataGrabber is imported using Python 2 #2207nipype/interfaces/tests/test_resource_monitor.py
for the time being