Skip to content

Commit c074299

Browse files
committed
Made when result is None that the end stats are N/A
1 parent 544dddf commit c074299

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

nipype/pipeline/plugins/callback_log.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
def log_nodes_cb(node, status, result=None):
55
logger = logging.getLogger('callback')
6-
try:
6+
if result is None:
7+
node_mem = cmd_mem = run_seconds = cmd_threads = 'N/A'
8+
else:
79
node_mem = result['node_memory']
810
cmd_mem = result['cmd_memory']
911
run_seconds = result['run_seconds']
1012
cmd_threads = result['cmd_threads']
11-
except Exception as exc:
12-
node_mem = cmd_mem = run_seconds = cmd_threads = 'N/A'
1313
if status == 'start':
1414
message = '{"name":' + '"' + node.name + '"' + ',"id":' + '"' +\
1515
node._id + '"' + ',"start":' + '"' +str(datetime.datetime.now()) +\

nipype/pipeline/plugins/multiproc.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,15 @@ def run_node(node, updatehash, runtime_profile=False):
4141
# Init function tuple
4242
proc = (node.run, (), {'updatehash' : updatehash})
4343
start = datetime.datetime.now()
44-
mem_mb, retval = memory_profiler.memory_usage(proc=proc, retval=True, include_children=True, max_usage=True)
44+
mem_mb, retval = memory_profiler.memory_usage(proc=proc, retval=True,
45+
include_children=True,
46+
max_usage=True)
4547
runtime = (datetime.datetime.now() - start).total_seconds()
4648
result['result'] = retval
4749
result['node_memory'] = mem_mb[0]/1024.0
50+
result['run_seconds'] = runtime
4851
result['cmd_memory'] = retval.runtime.get('cmd_memory')
4952
result['cmd_threads'] = retval.runtime.get('cmd_threads')
50-
result['run_seconds'] = runtime
5153
except:
5254
etype, eval, etr = sys.exc_info()
5355
result['traceback'] = format_exception(etype,eval,etr)

nipype/pipeline/plugins/tests/test_callback.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,3 @@ def test_callback_multiproc_exception():
104104
yield assert_equal, so.statuses[0][1], 'start'
105105
yield assert_equal, so.statuses[1][1], 'exception'
106106
rmtree(wf.base_dir)
107-
108-
if __name__ == '__main__':
109-
import nose
110-
nose.run()

0 commit comments

Comments
 (0)