-
Notifications
You must be signed in to change notification settings - Fork 533
ENH: Reduce within-package absolute imports #2059
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
Conversation
The slicer modules are auto-generated. It looks like the generating script has been updated, I just didn't take the time to figure out how to run it. Edit: And I believe the other instances are in doctests or functions that import locally. I think those have to be absolute. |
Codecov Report
@@ Coverage Diff @@
## master #2059 +/- ##
==========================================
+ Coverage 72.17% 72.17% +<.01%
==========================================
Files 1136 1136
Lines 57147 57150 +3
Branches 8185 8185
==========================================
+ Hits 41243 41249 +6
+ Misses 14617 14614 -3
Partials 1287 1287
Continue to review full report at Codecov.
|
I think there are still some imports apart from the autogenerated classes (in dipy and petpvc for example). |
f5056c4
to
891f69f
Compare
891f69f
to
10c641d
Compare
I think I got all of them now. |
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.
LGTM, only make sure those from __future__ import absolute_import
are there (for python 2 to work equivalently)
nipype/interfaces/fsl/ICA_AROMA.py
Outdated
traits, | ||
OutputMultiPath | ||
) | ||
from ..base import (TraitedSpec, CommandLineInputSpec, CommandLine, |
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.
for backwards compatibility, make sure to add from __future__ import absolute_import
before this
nipype/interfaces/fsl/fix.py
Outdated
@@ -54,7 +54,7 @@ | |||
|
|||
""" | |||
|
|||
from nipype.interfaces.base import ( | |||
from ..base import ( |
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.
for backwards compatibility, make sure to add from __future__ import absolute_import
before this
nipype/interfaces/niftyseg/base.py
Outdated
@@ -16,8 +16,8 @@ | |||
See the docstrings of the individual classes for examples. | |||
""" | |||
|
|||
from nipype.interfaces.niftyreg.base import no_nifty_package | |||
from nipype.interfaces.niftyfit.base import NiftyFitCommand | |||
from ..niftyreg.base import no_nifty_package |
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.
for backwards compatibility, make sure to add from __future__ import absolute_import
before this
nipype/utils/__init__.py
Outdated
@@ -1,6 +1,4 @@ | |||
# -*- coding: utf-8 -*- | |||
from __future__ import absolute_import |
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 removing this?
@@ -4,13 +4,13 @@ | |||
# vi: set ft=python sts=4 ts=4 sw=4 et: | |||
from __future__ import division | |||
|
|||
from nipype.utils import NUMPY_MMAP | |||
|
|||
from ....interfaces.io import JSONFileGrabber |
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.
for backwards compatibility, make sure to add from __future__ import absolute_import
before this
from nipype.interfaces.utility import Function,IdentityInterface | ||
import nipype.pipeline.engine as pe # pypeline engine | ||
from nipype.interfaces.freesurfer import * | ||
from ....utils import NUMPY_MMAP |
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.
for backwards compatibility, make sure to add from __future__ import absolute_import
before this
from nipype.interfaces.utility import Function, IdentityInterface, Merge | ||
import nipype.pipeline.engine as pe # pypeline engine | ||
from nipype.interfaces.freesurfer import * | ||
from ....interfaces.utility import Function, IdentityInterface, Merge |
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.
for backwards compatibility, make sure to add from __future__ import absolute_import
before this
from nipype.interfaces.utility import IdentityInterface, Merge, Function | ||
import nipype.pipeline.engine as pe # pypeline engine | ||
from nipype.interfaces.freesurfer import * | ||
from ....interfaces.utility import IdentityInterface, Merge, Function |
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.
for backwards compatibility, make sure to add from __future__ import absolute_import
before this
from nipype.interfaces.freesurfer import * | ||
from nipype.interfaces.io import DataGrabber | ||
from nipype.interfaces.utility import Merge | ||
from ....interfaces.utility import Function, IdentityInterface |
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.
for backwards compatibility, make sure to add from __future__ import absolute_import
before this
import nipype.interfaces.utility as niu | ||
import nipype.interfaces.niftyreg as niftyreg | ||
import nipype.pipeline.engine as pe | ||
from ....interfaces import utility as niu |
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.
for backwards compatibility, make sure to add from __future__ import absolute_import
before this
I thought Instead it seems that it does the opposite, always preferring an installed package to the local package. Which makes me wonder why we were using absolute imports for within-package imports at all. |
@oesteban Updated. |
With our (FMRIPREP/MRIQC) mismatched release cycles, we're running into the situation where correctly managing dependencies puts an undue burden on users (at least those installing natively, rather than running the Docker/Singularity images). We're attempting to move to include nipype as a submodule in niworkflows. Our projects will then import from
niworkflows.nipype
, which will avoid clashing with other installs of nipype.Absolute imports assume that the root module is named
nipype
, where relative imports will permit (relatively) easy use as a submodule.This should not affect the actual behavior of nipype at all, but will require that future PRs refrain from using absolute imports.
Changes proposed in this pull request: