Skip to content

Import error for nipype.interfaces.dipy.base #3411

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

Closed
koenhelwegen opened this issue Nov 22, 2021 · 4 comments · Fixed by #3414
Closed

Import error for nipype.interfaces.dipy.base #3411

koenhelwegen opened this issue Nov 22, 2021 · 4 comments · Fixed by #3414

Comments

@koenhelwegen
Copy link
Contributor

Summary

import nipype.interfaces.dipy generates an error for me, with Python 3.9 and 3.8, Dipy 4.12 (latest release) and latest release or current master of nipype.

Actual behavior

Running the above import generates the error TypeError: 'NoneType' object is not iterable generated from dipy_to_nipype_interface at:

for args, val in zip(parser.output_parameters, default_values[start:])

This function is executed during import in interfaces.dipy.preprocess. It seems this works correctly for several workflows (LabelsBundles, MedianOtsu, RecoBundles, LocalFiberTrackingPAM, PFTrackingPAM) but crashes for GibbsRingingFlow because default_values is None.

How to replicate the behavior

  • create a fresh venv
  • pip install the latest dipy and nipype packages
  • open python and run import nipype.interfaces.dipy

Expected behavior

A working import. This seems an easy fix, if others can reproduce the issue I would be happy to make a PR replacing

default_values = inspect.getfullargspec(flow.run).defaults
with:

    default_values = inspect.getfullargspec(flow.run).defaults or []

Platform details:

{'commit_hash': 'f756b7111',
 'commit_source': 'repository',
 'networkx_version': '2.6.3',
 'nibabel_version': '3.2.1',
 'nipype_version': '1.7.1-dev+gf756b7111',
 'numpy_version': '1.21.4',
 'pkg_path': '/home/.../basedir/nipype/nipype',
 'scipy_version': '1.7.2',
 'sys_executable': '/home/.../basedir/venv/bin/python',
 'sys_platform': 'linux',
 'sys_version': '3.9.9 (main, Nov 16 2021, 03:08:02) \n[GCC 9.3.0]',
 'traits_version': '6.3.2'}

(Error is the same for Python 3.8)

Execution environment

  • My python environment outside container
@effigies
Copy link
Member

Please also report upstream to dipy. We need to make these imports more resilient to API breakages.

cc @skoudoro

@koenhelwegen
Copy link
Contributor Author

On closer inspection I realize the bug is actually a bit more complicated. The run() method on GibbsRingingFlow does have default arguments, but inspect.getfullargspec() breaks here because of a decorator that was added a few months ago (https://github.com/dipy/dipy/blob/61a6f14015b8cd58b48501e1ef6fc853e55b6807/dipy/workflows/denoise.py#L311). So it is not really an API change from dipy.

@skoudoro
Copy link
Member

Thank you for pinging me. It is strange that the decorator does not keep the same function signature. I need to improve the new decorator management in Nipype.

Otherwise, it will break each time we deprecate an argument. I have a quite busy period but I will have a deeper look into it for sure.

@skoudoro
Copy link
Member

I suppose I should use inspect.signature() instead of inspect.getfullargspec()

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 a pull request may close this issue.

3 participants