Skip to content

Commit a38c506

Browse files
authored
log_nodes_cb -- Address nested case
1 parent 419d9e9 commit a38c506

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

nipype/utils/profiler.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,20 @@ def log_nodes_cb(node, status):
138138
import logging
139139
import json
140140

141+
# Address nested case
142+
if isinstance(node.result.runtime, (list,)):
143+
resrunlist = node.result.runtime[0]
144+
except:
145+
resrunlist = node.result.runtime
146+
141147
status_dict = {
142148
'name': node.name,
143149
'id': node._id,
144-
'start': getattr(node.result.runtime, 'startTime'),
145-
'finish': getattr(node.result.runtime, 'endTime'),
146-
'duration': getattr(node.result.runtime, 'duration'),
147-
'runtime_threads': getattr(node.result.runtime, 'cpu_percent', 'N/A'),
148-
'runtime_memory_gb': getattr(node.result.runtime, 'mem_peak_gb',
150+
'start': getattr(resrunlist, 'startTime'),
151+
'finish': getattr(resrunlist, 'endTime'),
152+
'duration': getattr(resrunlist, 'duration'),
153+
'runtime_threads': getattr(resrunlist, 'cpu_percent', 'N/A'),
154+
'runtime_memory_gb': getattr(resrunlist, 'mem_peak_gb',
149155
'N/A'),
150156
'estimated_memory_gb': node.mem_gb,
151157
'num_threads': node.n_procs,
@@ -155,8 +161,7 @@ def log_nodes_cb(node, status):
155161
status_dict['error'] = True
156162

157163
# Dump string to log
158-
logging.getLogger('callback').debug(json.dumps(status_dict))
159-
164+
logging.getLogger('callback').debug(json.dumps(status_dict, allow_nan=True))
160165

161166
# Get total system RAM
162167
def get_system_total_memory_gb():

0 commit comments

Comments
 (0)