-
Notifications
You must be signed in to change notification settings - Fork 533
[MAINT] Cleanup EngineBase #2376
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
nipype/pipeline/engine/base.py
Outdated
from ...interfaces.base import DynamicTraitedSpec | ||
from ...utils.filemanip import loadpkl, savepkl | ||
|
||
logger = logging.getLogger('workflow') | ||
standard_library.install_aliases() |
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.
Isn't the point of having this before most imports to ensure that the imports work as expected?
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.
The aliases would modify the behavior of imports, so I guess that is the reason. Anyways, I moved it because flake8 suggested so. I can roll back at any moment
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.
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.
some comments on the order are here: https://pypi.python.org/pypi/future
All examples here have it at the very beginning
nipype/pipeline/engine/base.py
Outdated
if name and bool(re.match(r'^[\w_]+$', name)): | ||
self._name = name | ||
else: | ||
raise ValueError('[Workflow|Node] name "%s" is not valid.' % name) |
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 prefer:
if not name or not re.match(r'^\w+$', name):
raise ValueError(...)
self._name = name
Note that I simplified the regex. \w
matches underscores.
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 think we were supporting also dashes -
so I'll add them.
Testing with FMRIPREP this seems to work correctly. |
@@ -18,18 +18,14 @@ | |||
absolute_import) | |||
from builtins import object | |||
|
|||
from future import standard_library | |||
standard_library.install_aliases() |
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 meant not to bother removing or reordering, and just tolerate the PEP8 violation. Unless it's causing problems, let's not change this here.
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've checked locally with Python 2 and this aliases are not necessary. Let's get rid of them whenever possible.
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.
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 don't believe it does.
|
||
|
||
def test_node_init(): | ||
with pytest.raises(Exception): |
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 can change change Exception
to TypeError
Good to go! |
A quick cleanup of the
EngineBase
class:test_utils.py
, and moved some tests totest_nodes.py
andtest_workflows.py
test_workflows.py::test_outputs_removal_wf
addingMultiProc
and removing for loops