Skip to content

Commit 58b4905

Browse files
committed
Merge branch 'fix/resource-monitor-file' into fix/resource-monitor-revisions
2 parents e50226e + d7a2d16 commit 58b4905

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
@@ -1298,7 +1298,7 @@ def write_workflow_prov(graph, filename=None, format='all'):
12981298
return ps.g
12991299

13001300

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

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

13241331
params = ''
13251332
if node.parameterization:
13261333
params = '_'.join(['{}'.format(p)
1327-
for p in node.parameterization])
1334+
for p in node.parameterization])
13281335

13291336
try:
13301337
rt_list = node.result.runtime

nipype/pipeline/engine/workflows.py

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

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

603606
# PRIVATE API AND FUNCTIONS

0 commit comments

Comments
 (0)