@@ -79,7 +79,7 @@ def _write_inputs(node):
79
79
return lines
80
80
81
81
82
- def format_node (node , format = 'python' ):
82
+ def format_node (node , format = 'python' , include_config = False ):
83
83
"""Format a node in a given output syntax
84
84
"""
85
85
lines = []
@@ -112,9 +112,15 @@ def format_node(node, format='python'):
112
112
args ,
113
113
name )
114
114
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
+
115
120
if node .iterables is not None :
116
121
lines .append ('%s.iterables = %s' % (name , node .iterables ))
117
122
lines .extend (_write_inputs (node ))
123
+
118
124
return lines
119
125
120
126
@@ -537,7 +543,7 @@ def write_hierarchical_dotfile(self, dotfilename=None, colored=True,
537
543
else :
538
544
logger .info (dotstr )
539
545
540
- def export (self , prefix = "output" , format = "python" ):
546
+ def export (self , prefix = "output" , format = "python" , include_config = False ):
541
547
"""Export object into a different format
542
548
543
549
Parameters
@@ -563,10 +569,12 @@ def export(self, prefix="output", format="python"):
563
569
connect_template2 = '%s.connect(%%s, "%%s", %%s, "%%s")' % self .name
564
570
wfdef = '%s = Workflow("%s")' % (self .name , self .name )
565
571
lines .append (wfdef )
572
+ if include_config :
573
+ lines .append ('%s.config = %s' % (self .name , self .config ))
566
574
for idx , node in enumerate (nodes ):
567
575
nodename = node .fullname .replace ('.' , '_' )
568
576
# write nodes
569
- nodelines = format_node (node , format = 'python' )
577
+ nodelines = format_node (node , format = 'python' , include_config = include_config )
570
578
for line in nodelines :
571
579
if line .startswith ('from' ):
572
580
if line not in importlines :
0 commit comments