Skip to content

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

Merged
merged 31 commits into from
Oct 6, 2017
Merged

Sort out terminal_output #2209

merged 31 commits into from
Oct 6, 2017

Conversation

oesteban
Copy link
Contributor

@oesteban oesteban commented Oct 4, 2017

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:

  • Update documentation
  • Before merging, I make specs should be run. I'm holding off to ease code review.

oesteban added 25 commits March 1, 2016 13:34
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 nipy#1407. Thus, closes nipy#1407.
Integrate the code from that branch that was stale waiting for `terminal_output` to be revised. Close nipy#1398.
@codecov-io
Copy link

Codecov Report

Merging #2209 into master will increase coverage by <.01%.
The diff coverage is 87.8%.

Impacted file tree graph

@@            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
Flag Coverage Δ
#smoketests 72.27% <87.8%> (ø) ⬆️
#unittests 69.81% <84.75%> (+0.01%) ⬆️
Impacted Files Coverage Δ
nipype/interfaces/fsl/__init__.py 100% <ø> (ø) ⬆️
nipype/interfaces/afni/tests/test_auto_ROIStats.py 85.71% <ø> (ø) ⬆️
nipype/interfaces/tests/test_base.py 96.81% <100%> (+0.07%) ⬆️
nipype/interfaces/matlab.py 79.79% <100%> (ø) ⬆️
...pe/interfaces/afni/tests/test_auto_OutlierCount.py 85.71% <100%> (-14.29%) ⬇️
nipype/pipeline/plugins/multiproc.py 77.94% <100%> (ø) ⬆️
nipype/interfaces/afni/preprocess.py 80.75% <46.15%> (-0.55%) ⬇️
nipype/interfaces/freesurfer/base.py 73.07% <50%> (-0.61%) ⬇️
nipype/interfaces/fsl/utils.py 72.91% <82.35%> (+0.18%) ⬆️
...nterfaces/fsl/tests/test_auto_WarpPointsFromStd.py 85.71% <85.71%> (ø)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2e5f5fc...82263dc. Read the comment docs.

@codecov-io
Copy link

codecov-io commented Oct 5, 2017

Codecov Report

Merging #2209 into master will decrease coverage by <.01%.
The diff coverage is 82.75%.

Impacted file tree graph

@@            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
Flag Coverage Δ
#smoketests 72.3% <82.75%> (-0.01%) ⬇️
#unittests 69.87% <79.31%> (+0.01%) ⬆️
Impacted Files Coverage Δ
nipype/interfaces/afni/tests/test_auto_Qwarp.py 85.71% <ø> (ø) ⬆️
...pe/interfaces/freesurfer/tests/test_auto_MS_LDA.py 85.71% <ø> (ø) ⬆️
...ipype/interfaces/fsl/tests/test_auto_ApplyTOPUP.py 85.71% <ø> (ø) ⬆️
nipype/interfaces/afni/tests/test_auto_Axialize.py 85.71% <ø> (ø) ⬆️
...pype/interfaces/camino/tests/test_auto_Shredder.py 85.71% <ø> (ø) ⬆️
...nterfaces/camino/tests/test_auto_TrackBootstrap.py 85.71% <ø> (ø) ⬆️
nipype/interfaces/afni/tests/test_auto_Refit.py 85.71% <ø> (ø) ⬆️
...erfaces/freesurfer/tests/test_auto_MakeSurfaces.py 85.71% <ø> (ø) ⬆️
...ipype/interfaces/afni/tests/test_auto_ABoverlap.py 85.71% <ø> (ø) ⬆️
nipype/interfaces/fsl/tests/test_auto_BEDPOSTX5.py 85.71% <ø> (ø) ⬆️
... and 694 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4d08138...a66678c. Read the comment docs.

@oesteban
Copy link
Contributor Author

oesteban commented Oct 5, 2017

@satra, @effigies, this is ready for final review

@satra
Copy link
Member

satra commented Oct 5, 2017

@oesteban - this will need to resolve a few things post the display PR merge.

@effigies
Copy link
Member

effigies commented Oct 5, 2017

@satra @oesteban The conflicts looked simple to resolve to me, so I went ahead and did it to get the tests queued up. Please check the diff to make sure you agree with the changes.

@oesteban
Copy link
Contributor Author

oesteban commented Oct 5, 2017

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 :)

@oesteban oesteban requested review from effigies and satra October 5, 2017 17:19
Copy link
Member

@effigies effigies left a 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.

if sep is None:
sep = ' '
if argstr.endswith('...'):
sep = trait_spec.sep or ' '
Copy link
Member

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
Copy link
Member

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.

Copy link
Contributor Author

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'
Copy link
Member

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'

@@ -1457,7 +1471,7 @@ class must be instantiated with a command argument
{'args': '-al',
'environ': {'DISPLAY': ':1'},
'ignore_exception': False,
'terminal_output': 'stream'}
'terminal_output': <undefined>}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is syntactically off.

Copy link
Contributor Author

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}

@@ -1652,7 +1672,7 @@ def _filename_from_source(self, name, chain=None):
ns = trait_spec.name_source
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')
Copy link
Member

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.

@@ -25,9 +25,8 @@ def test_ROIStats_inputs():
quiet=dict(argstr='-quiet',
position=1,
),
terminal_output=dict(mandatory=True,
terminal_output=dict(deprecated='1.0.0',
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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'
Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Member

@satra satra left a 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.

@oesteban
Copy link
Contributor Author

oesteban commented Oct 5, 2017

I still have to add in your comments and make specs. Please hold off merging till then.

@satra satra merged commit 2b10ff2 into nipy:master Oct 6, 2017
@oesteban oesteban deleted the fix/1407 branch October 6, 2017 16:33
@satra satra added this to the 0.14.0 milestone Oct 20, 2017
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 this pull request may close these issues.

[ENH] terminal_output as output
4 participants