-
Notifications
You must be signed in to change notification settings - Fork 536
improve python 3 compatibility when parameterize_dirs is False #1764
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
update to nipy/nipype master
Required for python 3 compatibility
|
LGTM - thanks @wtriplett |
Current coverage is 72.44% (diff: 81.81%)@@ master #1764 diff @@
==========================================
Files 1055 1055
Lines 52823 52844 +21
Methods 0 0
Messages 0 0
Branches 7672 7672
==========================================
+ Hits 38266 38284 +18
- Misses 13345 13347 +2
- Partials 1212 1213 +1
|
|
@wtriplett - could you please add #1762 as a test case? essentially something like the following which should fail before your fix is applied: |
|
@satra: Ok, I can do that. |
|
@satra: So I'm not sure how the automated tests will end up working with this new test case. I guess it might be easier just to call Anyway, hope this helps. |
|
The CircleCI tests are also running here without the fix (e060bbc) applied. The expected results would be pass on python2.7 and fail on 3.5. |
| from ....interfaces.utility import IdentityInterface | ||
| from ....testing import example_data | ||
|
|
||
| config.update_config({'execution': {'parameterize_dirs': False}}) |
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.
make this a local change rather than a global change.
|
|
||
| wf = pe.Workflow(name="Test") | ||
| wf.base_dir = wd | ||
| wf.connect([(n1, n2, [('output1', 'in1')])]) |
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.
local change for wf: wf.config['execution']['parameterize_dirs'] = False
| config.update_config({'execution': {'parameterize_dirs': False}}) | ||
|
|
||
| wd = str(tmpdir) | ||
| os.chdir(wd) |
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.
these two statements are not required for a workflow since you set wf.base_dir = wd later.
* making configuration changes local instead of global
* removed unnecessary statements
also:
* string quoting (" => ') consistent other tests
* catch more general exception to be consistent with other tests
| error_raised = False | ||
| try: | ||
| wf.run() | ||
| except Exception as ex: |
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.
shouldn't this be specifically a TypeError?
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.
Good question. I was looking at the other tests, and they all seemed to catch generic exceptions. It dawned on me that if this is a test of a configuration specific execution pathway, that maybe it was better to catch a general exception in case there was another reason for failure and the assertion would still work rather than bailing out.
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.
in this case since we know it's a TypeError we should use that. the intent of a Test should be to catch the most specific error, because the other types of errors may require different handling.
for many of the tests in this file, they do raise a generic exception, but this should also be improved ( ping @djarecka )
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.
Roger that - I'll revert back to TypeError.
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 : I don't understand this try/except block, since we expect wr.run() to work, and if we get ANY exception, the test should fail (and pytest will inform what exception has been raised). IMO, we should remove try/except block at all, just keep wr.run(). The same is true about all test that have assert not error_raised. And the test that have assert error_raised can be rewritten using with pytest.raises(Exception).
If you agree with me, I can clean whole file after this PR is merged (unless you prefer to do it before).
|
let's do it after it's merged. but yes - we should clean up logic where we can. |
Tested in python 3.5 and 2.7.12 before and after fix. Used non-specific/empty
encode()based on what looks like the common usage elsewhere in code.Fixes #1762