Skip to content

Commit 9e02e43

Browse files
committed
Added optional config inclusion
1 parent cf89477 commit 9e02e43

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

nipype/pipeline/engine.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def _write_inputs(node):
7979
return lines
8080

8181

82-
def format_node(node, format='python'):
82+
def format_node(node, format='python', include_config=False):
8383
"""Format a node in a given output syntax
8484
"""
8585
lines = []
@@ -112,9 +112,15 @@ def format_node(node, format='python'):
112112
args,
113113
name)
114114
lines = [importline, comment, nodedef]
115+
116+
if include_config:
117+
lines = [importline, "from collections import OrderedDict", comment, nodedef]
118+
lines.append('%s.config = %s' % (name, node.config))
119+
115120
if node.iterables is not None:
116121
lines.append('%s.iterables = %s' % (name, node.iterables))
117122
lines.extend(_write_inputs(node))
123+
118124
return lines
119125

120126

@@ -537,7 +543,7 @@ def write_hierarchical_dotfile(self, dotfilename=None, colored=True,
537543
else:
538544
logger.info(dotstr)
539545

540-
def export(self, prefix="output", format="python"):
546+
def export(self, prefix="output", format="python", include_config=False):
541547
"""Export object into a different format
542548
543549
Parameters
@@ -563,10 +569,12 @@ def export(self, prefix="output", format="python"):
563569
connect_template2 = '%s.connect(%%s, "%%s", %%s, "%%s")' % self.name
564570
wfdef = '%s = Workflow("%s")' % (self.name, self.name)
565571
lines.append(wfdef)
572+
if include_config:
573+
lines.append('%s.config = %s' % (self.name, self.config))
566574
for idx, node in enumerate(nodes):
567575
nodename = node.fullname.replace('.', '_')
568576
# write nodes
569-
nodelines = format_node(node, format='python')
577+
nodelines = format_node(node, format='python', include_config=include_config)
570578
for line in nodelines:
571579
if line.startswith('from'):
572580
if line not in importlines:

0 commit comments

Comments
 (0)