Skip to content

Commit 2809de4

Browse files
committed
redirect print when verbose is False
1 parent 3dc458a commit 2809de4

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

pipeline.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ def execute(self, bayer, save_intermediates=False, verbose=True):
9494
intermediates: a dict containing intermediate results if save_intermediates=True,
9595
otherwise a empty dict
9696
"""
97+
def print_(*args, **kwargs):
98+
return print(*args, **kwargs) if verbose else None
9799

98100
pipeline_start = time.time()
99101

@@ -102,20 +104,16 @@ def execute(self, bayer, save_intermediates=False, verbose=True):
102104

103105
for module_name, module in self.modules.items():
104106
start = time.time()
105-
if verbose:
106-
print('Executing {}... '.format(module_name), end='', flush=True)
107+
print_('Executing {}... '.format(module_name), end='', flush=True)
107108

108109
module.execute(data)
109110
if save_intermediates:
110111
intermediates[module_name] = copy.copy(data)
111112

112-
if verbose:
113-
print('Done. Elapsed {:.3f}s'.format(time.time() - start))
113+
print_('Done. Elapsed {:.3f}s'.format(time.time() - start))
114114

115115
data['output'] = self.get_output(data)
116-
117-
if verbose:
118-
print('Pipeline elapsed {:.3f}s'.format(time.time() - pipeline_start))
116+
print_('Pipeline elapsed {:.3f}s'.format(time.time() - pipeline_start))
119117

120118
return data, intermediates
121119

0 commit comments

Comments
 (0)