@@ -139,8 +139,8 @@ class Workflow(WorkflowBase):
139
139
"""Controls the setup and execution of a pipeline of processes
140
140
"""
141
141
142
- def __init__ (self , ** kwargs ):
143
- super (Workflow , self ).__init__ (** kwargs )
142
+ def __init__ (self , * args , * *kwargs ):
143
+ super (Workflow , self ).__init__ (* args , * *kwargs )
144
144
self ._graph = nx .DiGraph ()
145
145
146
146
# PUBLIC API
@@ -470,6 +470,31 @@ def write_hierarchical_dotfile(self, dotfilename=None, colored=True,
470
470
else :
471
471
logger .info (dotstr )
472
472
473
+ def export (self , prefix = "output" , format = "python" ):
474
+ """Export object into a different format
475
+
476
+ Parameters
477
+ ----------
478
+
479
+ prefix: string
480
+ prefix to use for output file
481
+
482
+ format: string
483
+ one of "python"
484
+ """
485
+ formats = ["python" ]
486
+ if format not in formats :
487
+ raise ValueError ('format must be one of: %s' % '|' .join (formats ))
488
+ flatgraph = self ._create_flat_graph ()
489
+
490
+ if format == "python" :
491
+ with open ('%s.py' , 'wt' ) as fp :
492
+ # write nodes
493
+ for node in nx .topological_sort (flatgraph ):
494
+ nodestr = node .format (format = python )
495
+ fp .writelines (nodestr )
496
+ # write connections
497
+
473
498
def run (self , plugin = None , plugin_args = None , updatehash = False ):
474
499
""" Execute the workflow
475
500
@@ -1032,6 +1057,12 @@ def help(self):
1032
1057
""" Print interface help"""
1033
1058
self ._interface .help ()
1034
1059
1060
+ def format (format = python ):
1061
+ """Format a node in a given output syntax
1062
+ """
1063
+
1064
+
1065
+
1035
1066
def hash_exists (self , updatehash = False ):
1036
1067
# Get a dictionary with hashed filenames and a hashvalue
1037
1068
# of the dictionary itself.
0 commit comments