-
Notifications
You must be signed in to change notification settings - Fork 532
ENH: Add SimpleInterface #2220
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
ENH: Add SimpleInterface #2220
Conversation
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 this has been very helpful in niworkflows/fmriprep/mriqc so far.
@@ -1212,6 +1212,41 @@ def save_inputs_to_json(self, json_file): | |||
json.dump(inputs, fhandle, indent=4, ensure_ascii=False) | |||
|
|||
|
|||
class SimpleInterface(BaseInterface): | |||
""" An interface pattern that allows outputs to be set in a dictionary |
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'd suggest:
"""
An interface pattern that allows outputs to be set in a dictionary called ``_results``
that is automatically interpreted by ``_list_outputs()`` to find the outputs.
...
"""
nipype/interfaces/base.py
Outdated
class SimpleInterface(BaseInterface): | ||
""" An interface pattern that allows outputs to be set in a dictionary | ||
|
||
When implementing `_run_interface`, set outputs with:: |
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.
Double quotes for the docstring:
When implementing ``_run_interface``, set outputs with::
nipype/interfaces/base.py
Outdated
|
||
self._results[out_name] = out_value | ||
|
||
This can be a way to upgrade a ``Function`` interface to do type checking: |
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.
Missing:
Example
-------
That is a standard in the docstring of nipype interfaces
Codecov Report
@@ Coverage Diff @@
## master #2220 +/- ##
==========================================
- Coverage 72.31% 72.31% -0.01%
==========================================
Files 1180 1180
Lines 58879 58885 +6
Branches 8474 8474
==========================================
+ Hits 42579 42580 +1
- Misses 14921 14926 +5
Partials 1379 1379
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #2220 +/- ##
==========================================
+ Coverage 72.31% 72.31% +<.01%
==========================================
Files 1180 1180
Lines 58879 58885 +6
Branches 8474 8474
==========================================
+ Hits 42579 42585 +6
Misses 14921 14921
Partials 1379 1379
Continue to review full report at Codecov.
|
LGTM - i can see how this is useful and keeps data validation. |
@oesteban any more comments? |
Nope :) |
This adds
niworkflows.interfaces.base.SimpleInterface
tonipype.interfaces.base
.SimpleInterface
is an interface that gives dictionary access to the output spec. We've found it a very useful boilerplate-reducer for making interfaces by simply defining input/output specs and_results
.Merging this would reduce friction for a lot of other poldracklab (niworkflows, mriqc, fmriprep) interfaces that people may want to see merged into nipype proper. I'm open to cleaning it up to be slightly less simple, as long as it achieves the same reduction in boilerplate in subclasses.
Slightly related: #2083
@oesteban EDITED: changed
_runtime
for_results
.