Skip to content

Commit b0b7495

Browse files
committed
brk: adding save changes
1 parent b36cc9c commit b0b7495

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

nipype/pipeline/engine.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ class Workflow(WorkflowBase):
139139
"""Controls the setup and execution of a pipeline of processes
140140
"""
141141

142-
def __init__(self, **kwargs):
143-
super(Workflow, self).__init__(**kwargs)
142+
def __init__(self, *args, **kwargs):
143+
super(Workflow, self).__init__(* args, **kwargs)
144144
self._graph = nx.DiGraph()
145145

146146
# PUBLIC API
@@ -470,6 +470,31 @@ def write_hierarchical_dotfile(self, dotfilename=None, colored=True,
470470
else:
471471
logger.info(dotstr)
472472

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+
473498
def run(self, plugin=None, plugin_args=None, updatehash=False):
474499
""" Execute the workflow
475500
@@ -1032,6 +1057,12 @@ def help(self):
10321057
""" Print interface help"""
10331058
self._interface.help()
10341059

1060+
def format(format=python):
1061+
"""Format a node in a given output syntax
1062+
"""
1063+
1064+
1065+
10351066
def hash_exists(self, updatehash=False):
10361067
# Get a dictionary with hashed filenames and a hashvalue
10371068
# of the dictionary itself.

0 commit comments

Comments
 (0)