Skip to content

Fix/misc test fixes #1757

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

Merged
merged 39 commits into from
Dec 24, 2016
Merged

Fix/misc test fixes #1757

merged 39 commits into from
Dec 24, 2016

Conversation

satra
Copy link
Member

@satra satra commented Dec 18, 2016

this includes changes from #1751

satra and others added 30 commits November 7, 2016 22:55
* upstream/master: (28 commits)
  less brittle test
  don't calculate var/stddev twice
  don't let divide by zero errors pass by
  specify tab delimiter
  try longer timeout
  revert identity transform
  use from io import open
  fix up test (e.g. pep8)
  chdir back to original dir before deleting tempdir
  revert 4d validation, fix input spec desc
  add headers to outputs of compcor, framewise displacement + test fix
  pull from nipy/nipype master
  merge with master
  make specs
  don't load the whole thing into memory
  check and error if input to fsl ApplyTopUp is not 4 dimensional
  better test
  less mysterious error messages
  Add more informative error msg
  test specs auto
  ...
* upstream/master:
  better test
  Revert "my own nipype version"
  fix
  test
  Update __init__.py in fsl interfaces to have new ApplyXFM
  my own nipype version
  fix outputs
  test
  Revert "fix fast??"
  fix fast??
  fix README after neurostars is down
  m
  m
  ApplyXfm -> ApplyXFM
  fix: hierarchy typo
  add: itername to track hierarchy + iterables
  fix: missing import
  tst: added test case
  test: use fullname
* upstream/master:
  missed skipif
  fixed multiproc plugin deadlock problem and re-enabled tests
  && not valid in python...
  check to make sure keep_temporary_files is defined
  add auto generated spec test for changed file
  fix error accessing brainextraction input
  add new files to ants brain extraction output spec and list outputs
…apnode

* dorota/pytest_satrarev:
  it looks like codecov works at the end, removing COVERAGE_PROCESS_START  and COVERAGE_DATA_FILE from travis again
  trying to fix coverage (codecov doesnt report anything), restoring some lines from travis
  removing workflows from the directories that are omitted
  restore get_info in nipype/__init__.py
  Removing nosetest from nipype/__init__.py; pytest version is missing for now
  fixing the travis file
  removing coverage from travis (so the coverage is calculated from Circle CI only)
  removing fixes
  removing scripts from tools directory that are not used anymore
  changing test_auto_TCompCor.py to the output of checkspecs.py
  adding the auto test for ACompCor
  changing a simple assert to np.isclose in test_icc_anova
  cleaning:removing pdb
  restring one skipif in interfaces/tests/test_io.py
  removing one test from interfaces/tests/test_base.py; it was repeating the same assert as the previous one
  fixing one assert in test_math
  restoring 2 tests that had only import statement, changing comments
@codecov-io
Copy link

codecov-io commented Dec 21, 2016

Current coverage is 72.41% (diff: 78.10%)

Merging #1757 into master will increase coverage by 1.28%

@@             master      #1757   diff @@
==========================================
  Files          1028       1055     +27   
  Lines         50665      52823   +2158   
  Methods           0          0           
  Messages          0          0           
  Branches       7335       7672    +337   
==========================================
+ Hits          36039      38252   +2213   
+ Misses        13499      13359    -140   
- Partials       1127       1212     +85   

Powered by Codecov. Last update fa866eb...75300a5

@satra
Copy link
Member Author

satra commented Dec 22, 2016

@chrisfilo, @oesteban, @djarecka - any help would be much appreciated here:

for the moment ignore that this PR passes - it doesn't have the correct test. as you can see py3 gives the correct answer, py2 does not. note the error pattern. A Function interface is dynamic and uses DynamicTraits for it's inputspec.

test function:

import nipype.pipeline.engine as pe
import nipype.interfaces.utility as niu

def test_mapnode_crash3():
    """Test mapnode crash when mapnode is embedded in a workflow"""
    def myfunction(value):
        return value + 1
    node = pe.MapNode(niu.Function(input_names=['WRONG'],
                                   output_names=['newstring'],
                                   function=myfunction),
                      iterfield=['WRONG'],
                      name='myfunc')
    node.inputs.WRONG = ['mystring{}'.format(i) for i in range(3)]
    wf = pe.Workflow('testmapnodecrash')
    wf.add_nodes([node])
    wf.run(plugin='Linear')

py27 output:

Exception: Subnodes of node: myfunc failed:
Subnode 0 failed
Error:
myfunction() got an unexpected keyword argument 'WRONG'
Interface Function failed to run. 
Subnode 1 failed
Error:
'FunctionInputSpec' object has no attribute 'read'
Interface Function failed to run. 
Subnode 2 failed
Error:
'FunctionInputSpec' object has no attribute 'read'
Interface Function failed to run. 

py35 output

Subnode 0 failed
Error:
myfunction() got an unexpected keyword argument 'WRONG'
Interface Function failed to run. 
Subnode 1 failed
Error:
myfunction() got an unexpected keyword argument 'WRONG'
Interface Function failed to run. 
Subnode 2 failed
Error:
myfunction() got an unexpected keyword argument 'WRONG'
Interface Function failed to run. 

@djarecka
Copy link
Collaborator

djarecka commented Dec 22, 2016

@satra: can't repeat your output from py.27. My output from py27 looks like output from py35

@satra
Copy link
Member Author

satra commented Dec 24, 2016

@djarecka - finally found the culprit, but no solution yet. see the second line - if you comment it then the code runs properly.

from __future__ import print_function, division, absolute_import
from __future__ import unicode_literals # <---- this is the culprit in py27
from builtins import range, open

import nipype.pipeline.engine as pe
import nipype.interfaces.utility as niu

def test_mapnode_crash3():#tmpdir):
    """Test mapnode crash when mapnode is embedded in a workflow"""
    def myfunction(value):
        return value + 1
    node = pe.MapNode(niu.Function(input_names=['WRONG'],
                                   output_names=['newstring'],
                                   function=myfunction),
                      iterfield=['WRONG'],
                      name='myfunc')
    node.inputs.WRONG = ['mystring{}'.format(i) for i in range(3)]
    wf = pe.Workflow('testmapnodecrash')
    wf.add_nodes([node])
    #wf.base_dir = str(tmpdir)
    #with pytest.raises(RuntimeError):
    wf.run(plugin='Linear')

if __name__ == "__main__":
    test_mapnode_crash3()

@djarecka
Copy link
Collaborator

@satra : that would explain, why I didn't get the same output for py27 yesterday, since I simply copy your code that was without this line.
Do you understand why unicode_literals breaks the code in these specific tests?

regarding solution (at least temporary): unicode_literals is actually not needed for these tests...

@satra
Copy link
Member Author

satra commented Dec 24, 2016

@djarecka - needed for other tests. that's something we cannot change immediately. for the moment i've pushed some code that should enable all of these tests to pass. but we need to clean up traits sometime soon.

@satra satra merged commit 0ebb301 into nipy:master Dec 24, 2016
@satra satra deleted the fix/misc_test_fixes branch October 30, 2017 15:15
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.

3 participants