Skip to content

Commit 0abc8ac

Browse files
committed
move documentation to the interface_specs file
1 parent 6279fb2 commit 0abc8ac

File tree

2 files changed

+64
-63
lines changed

2 files changed

+64
-63
lines changed

doc/devel/interface_specs.rst

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,70 @@ generated depending on inputs, by the tool. OutputSpecs inherit from
159159
``interfaces.base.TraitedSpec`` directly.
160160

161161

162+
Controlling outputs to terminal
163+
-------------------------------
164+
165+
It is very likely that the software wrapped within the interface writes
166+
to the standard output or the standard error of the terminal.
167+
Interfaces provide a means to access and retrieve these outputs, by
168+
using the ``terminal_output`` attribute: ::
169+
170+
import nipype.interfaces.fsl as fsl
171+
mybet = fsl.BET(from_file='bet-settings.json')
172+
mybet.terminal_output = 'file_split'
173+
174+
In the example, the ``terminal_output = 'file_split'`` will redirect the
175+
standard output and the standard error to split files (called
176+
``stdout.nipype`` and ``stderr.nipype`` respectively).
177+
The possible values for ``terminal_output`` are:
178+
179+
*file*
180+
Redirects both standard output and standard error to the same file
181+
called ``output.nipype``.
182+
Messages from both streams will be overlapped as they arrive to
183+
the file.
184+
185+
*file_split*
186+
Redirects the output streams separately, to ``stdout.nipype``
187+
and ``stderr.nipype`` respectively, as described in the example.
188+
189+
*file_stdout*
190+
Only the standard output will be redirected to ``stdout.nipype``
191+
and the standard error will be discarded.
192+
193+
*file_stderr*
194+
Only the standard error will be redirected to ``stderr.nipype``
195+
and the standard output will be discarded.
196+
197+
*stream*
198+
Both output streams are redirected to the current logger printing
199+
their messages interleaved and immediately to the terminal.
200+
201+
*allatonce*
202+
Both output streams will be forwarded to a buffer and stored
203+
separately in the `runtime` object that the `run()` method returns.
204+
No files are written nor streams printed out to terminal.
205+
206+
*none*
207+
Both outputs are discarded
208+
209+
In all cases, except for the ``'none'`` setting of ``terminal_output``,
210+
the ``run()`` method will return a "runtime" object that will contain
211+
the streams in the corresponding properties (``runtime.stdout``
212+
for the standard output, ``runtime.stderr`` for the standard error, and
213+
``runtime.merged`` for both when streams are mixed, eg. when using the
214+
*file* option). ::
215+
216+
import nipype.interfaces.fsl as fsl
217+
mybet = fsl.BET(from_file='bet-settings.json')
218+
mybet.terminal_output = 'file_split'
219+
...
220+
result = mybet.run()
221+
result.runtime.stdout
222+
' ... captured standard output ...'
223+
224+
225+
162226
Traited Attributes
163227
------------------
164228

doc/users/interface_tutorial.rst

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -81,69 +81,6 @@ In this case, ``mybet.inputs.frac`` will contain the value ``0.7`` regardless
8181
the value that could be stored in the ``bet-settings.json`` file.
8282

8383

84-
Controlling the standard output and error
85-
-----------------------------------------
86-
87-
It is very likely that the software wrapped within the interface writes
88-
to the standard output or the standard error of the terminal.
89-
Interfaces provide a means to access and retrieve these outputs, by
90-
using the ``terminal_output`` attribute: ::
91-
92-
import nipype.interfaces.fsl as fsl
93-
mybet = fsl.BET(from_file='bet-settings.json')
94-
mybet.terminal_output = 'file_split'
95-
96-
In the example, the ``terminal_output = 'file_split'`` will redirect the
97-
standard output and the standard error to split files (called
98-
``stdout.nipype`` and ``stderr.nipype`` respectively).
99-
The possible values for ``terminal_output`` are:
100-
101-
*file*
102-
Redirects both standard output and standard error to the same file
103-
called ``output.nipype``.
104-
Messages from both streams will be overlapped as they arrive to
105-
the file.
106-
107-
*file_split*
108-
Redirects the output streams separately, to ``stdout.nipype``
109-
and ``stderr.nipype`` respectively, as described in the example.
110-
111-
*file_stdout*
112-
Only the standard output will be redirected to ``stdout.nipype``
113-
and the standard error will be discarded.
114-
115-
*file_stderr*
116-
Only the standard error will be redirected to ``stderr.nipype``
117-
and the standard output will be discarded.
118-
119-
*stream*
120-
Both output streams are redirected to the current logger printing
121-
their messages interleaved and immediately to the terminal.
122-
123-
*allatonce*
124-
Both output streams will be forwarded to a buffer and stored
125-
separately in the `runtime` object that the `run()` method returns.
126-
No files are written nor streams printed out to terminal.
127-
128-
*none*
129-
Both outputs are discarded
130-
131-
In all cases, except for the ``'none'`` setting of ``terminal_output``,
132-
the ``run()`` method will return a "runtime" object that will contain
133-
the streams in the corresponding properties (``runtime.stdout``
134-
for the standard output, ``runtime.stderr`` for the standard error, and
135-
``runtime.merged`` for both when streams are mixed, eg. when using the
136-
*file* option). ::
137-
138-
import nipype.interfaces.fsl as fsl
139-
mybet = fsl.BET(from_file='bet-settings.json')
140-
mybet.terminal_output = 'file_split'
141-
...
142-
result = mybet.run()
143-
result.runtime.stdout
144-
' ... captured standard output ...'
145-
146-
14784
Getting Help
14885
------------
14986

0 commit comments

Comments
 (0)