-
Notifications
You must be signed in to change notification settings - Fork 536
Sort out terminal_output #2209
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
Sort out terminal_output #2209
Conversation
…o enh/FSLstd2imgcoords
Integrate the code from that branch that was stale waiting for `terminal_output` to be revised. Close nipy#1398.
Codecov Report
@@ Coverage Diff @@
## master #2209 +/- ##
==========================================
+ Coverage 72.26% 72.27% +<.01%
==========================================
Files 1177 1178 +1
Lines 58642 58695 +53
Branches 8446 8453 +7
==========================================
+ Hits 42376 42419 +43
- Misses 14902 14909 +7
- Partials 1364 1367 +3
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #2209 +/- ##
=========================================
- Coverage 72.3% 72.3% -0.01%
=========================================
Files 1178 1179 +1
Lines 58768 58789 +21
Branches 8458 8463 +5
=========================================
+ Hits 42494 42509 +15
- Misses 14901 14905 +4
- Partials 1373 1375 +2
Continue to review full report at Codecov.
|
|
@oesteban - this will need to resolve a few things post the display PR merge. |
|
Testing one conflict that wasn't correctly resolved. If it passes locally I'll push very soon. Thanks a lot @effigies for the merge with upstream :) |
effigies
left a comment
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.
Looks good. Everything I saw ended up being stylistic, so feel free to ignore.
nipype/interfaces/base.py
Outdated
| if sep is None: | ||
| sep = ' ' | ||
| if argstr.endswith('...'): | ||
| sep = trait_spec.sep or ' ' |
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.
This will replace '' with ' '. I'm not sure that's what people will expect. Actually equivalent:
sep = trait_spec.sep if trait_spec.sep is not None else ' '| return self._gen_outfilename() | ||
| else: | ||
| return None | ||
| return self._gen_outfilename() if name == 'out_file' else None |
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.
Functions return None implicitly. This could just drop the else condition.
def _getn_filename(self, name):
if name == 'out_file':
return self._gen_outfilename()I'm not sure which one is easier to understand. Your choice.
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 generally prefer explicit over implicit ...
| # Don't allow streaming outputs | ||
| if hasattr(node.interface, 'terminal_output') and \ | ||
| node.interface.terminal_output == 'stream': | ||
| node.interface.terminal_output = 'allatonce' |
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.
This might be something I messed up with my merge, but I think the getattr approach is cleaner.
# Don't allow streaming outputs
if getattr(node.interface, 'terminal_output', '') == 'stream':
node.interface.terminal_output = 'allatonce'
nipype/interfaces/base.py
Outdated
| 'environ': {'DISPLAY': ':1'}, | ||
| 'ignore_exception': False, | ||
| 'terminal_output': 'stream'} | ||
| 'terminal_output': <undefined>} |
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.
this is syntactically off.
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.
what about:
# Use get_traitsfree() to check all inputs set
>>> pprint.pprint(cli.inputs.get_traitsfree()) # doctest: +NORMALIZE_WHITESPACE +ALLOW_UNICODE
{'args': '-al',
'environ': {'DISPLAY': ':1'},
'ignore_exception': False}| while isinstance(ns, (list, tuple)): | ||
| if len(ns) > 1: | ||
| iflogger.warn('Only one name_source per trait is allowed') | ||
| iflogger.warning('Only one name_source per trait is allowed') |
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 in a next refactor, we should move this up to the base class.
| position=1, | ||
| ), | ||
| terminal_output=dict(mandatory=True, | ||
| terminal_output=dict(deprecated='1.0.0', |
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.
can we set version temporarily to 1.0.0 and make sure nothing breaks :) doesn't have to be a in a test. could be your local test.
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.
Running locally with version 1.0.1. Will also run some examples.
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.
Confirmed it runs correctly.
|
|
||
| import nipype.interfaces.fsl as fsl | ||
| mybet = fsl.BET(from_file='bet-settings.json') | ||
| mybet.terminal_output = 'file_split' |
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.
does this suggest that we should consider two types of fields in the json files? things that set node/interface attributes, like mem, proc, terminal_output, etc.,. and then a section that's exclusively the inputs?
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 point. We could think of a JSON representation of the interface state for nipype 2.0, don't you think?
satra
left a comment
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 general things look good, left a few comments.
|
I still have to add in your comments and |
This PR revises the terminal_output feature, making it a class attribute and deprecating the old InputSpec trait.
It also implements new ways of storing the output of a CommandLine, as discussed in #1407. Thus, closes #1407.
Work in progress:
make specsshould be run. I'm holding off to ease code review.