Skip to content

Commit d7a2d16

Browse files
committed
enable reuse of resource_monitor.json, write it in base_dir
1 parent e4e95f3 commit d7a2d16

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

nipype/pipeline/engine/utils.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,7 @@ def write_workflow_prov(graph, filename=None, format='all'):
12971297
return ps.g
12981298

12991299

1300-
def write_workflow_resources(graph, filename=None):
1300+
def write_workflow_resources(graph, filename=None, append=True):
13011301
"""
13021302
Generate a JSON file with profiling traces that can be loaded
13031303
in a pandas DataFrame or processed with JavaScript like D3.js
@@ -1316,14 +1316,21 @@ def write_workflow_resources(graph, filename=None):
13161316
'params': [],
13171317
}
13181318

1319+
# If file exists, just append new profile information
1320+
# If we append different runs, then we will see different
1321+
# "bursts" of timestamps corresponding to those executions.
1322+
if append and os.path.isfile(filename):
1323+
with open(filename, 'r' if PY3 else 'rb') as rsf:
1324+
big_dict = json.load(rsf)
1325+
13191326
for idx, node in enumerate(graph.nodes()):
13201327
nodename = node.fullname
13211328
classname = node._interface.__class__.__name__
13221329

13231330
params = ''
13241331
if node.parameterization:
13251332
params = '_'.join(['{}'.format(p)
1326-
for p in node.parameterization])
1333+
for p in node.parameterization])
13271334

13281335
try:
13291336
rt_list = node.result.runtime

nipype/pipeline/engine/workflows.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,10 @@ def run(self, plugin=None, plugin_args=None, updatehash=False):
596596
write_workflow_prov(execgraph, prov_base, format='all')
597597

598598
if config.resource_monitor:
599-
write_workflow_resources(execgraph)
599+
write_workflow_resources(
600+
execgraph,
601+
filename=op.join(self.base_dir, self.name, 'resource_monitor.json')
602+
)
600603
return execgraph
601604

602605
# PRIVATE API AND FUNCTIONS

0 commit comments

Comments
 (0)