@@ -1259,31 +1259,36 @@ class GraftWorkflow(InterfacedWorkflow):
1259
1259
_children = dict ()
1260
1260
_outnodes = dict ()
1261
1261
1262
- def __init__ (self , name , base_dir = None , fields_from = None , input_names = [], output_names = []):
1262
+ def __init__ (self , name , base_dir = None , fields_from = None ,
1263
+ input_names = [], output_names = []):
1263
1264
"""
1264
1265
Initializes the workflow from an existing InterfacedWorkflow
1265
1266
"""
1266
1267
from nipype .interfaces .utility import IdentityInterface
1267
1268
fields_undefined = ((input_names is None ) or (output_names is None ))
1268
1269
wf_undefined = (fields_from is None )
1269
1270
if wf_undefined and fields_undefined :
1270
- raise ValueError (('An existing InterfacedWorkflow or the input/output_names are '
1271
- 'required to initialize the GraftWorkflow' ))
1271
+ raise ValueError (('An existing InterfacedWorkflow or the in/output'
1272
+ ' names are required to initialize the '
1273
+ 'GraftWorkflow' ))
1272
1274
if not wf_undefined :
1273
1275
if not isinstance (fields_from , InterfacedWorkflow ):
1274
- raise TypeError ('Reference workflow is not an InterfacedWorkflow.' )
1276
+ raise TypeError ('Workflow is not an InterfacedWorkflow.' )
1275
1277
input_names = fields_from .input_names
1276
1278
output_names = fields_from .output_names
1277
1279
if (((input_names is None ) or (not input_names )) and
1278
- ((output_names is None ) or (not output_names ))):
1279
- raise ValueError (('A GraftWorkflow cannot be initialized without specifying either a '
1280
- 'fields_from workflow or i/o names lists' ))
1280
+ ((output_names is None ) or (not output_names ))):
1281
+ raise ValueError (('A GraftWorkflow cannot be initialized without '
1282
+ 'specifying either a fields_from workflow or i/o'
1283
+ ' names lists' ))
1281
1284
1282
1285
super (GraftWorkflow , self ).__init__ (name = name , base_dir = base_dir ,
1283
1286
input_names = input_names ,
1284
1287
output_names = output_names )
1285
1288
1286
- self ._outputnode = InputMultiNode (IdentityInterface (fields = output_names ), name = 'outputnode' )
1289
+ self ._outputnode = InputMultiNode (IdentityInterface (
1290
+ fields = output_names ),
1291
+ name = 'outputnode' )
1287
1292
1288
1293
def insert (self , workflow ):
1289
1294
"""
@@ -1292,33 +1297,34 @@ def insert(self, workflow):
1292
1297
from nipype .interfaces .utility import IdentityInterface
1293
1298
1294
1299
if not isinstance (workflow , InterfacedWorkflow ):
1295
- raise TypeError ('Only InterfacedWorkflows can be inserted in a GraftWorkflow.' )
1300
+ raise TypeError (('Only InterfacedWorkflows can be inserted in '
1301
+ 'a GraftWorkflow.' ))
1296
1302
1297
1303
ckey = workflow .name
1298
1304
cid = len (self ._children )
1299
1305
1300
1306
if ckey in self ._children .keys ():
1301
- raise RuntimeError ('Trying to add an existing workflow to GraftWorkflow' )
1307
+ raise RuntimeError (('Trying to add an existing workflow to '
1308
+ 'GraftWorkflow' ))
1302
1309
1303
1310
self ._children [ckey ] = workflow
1304
- self ._outnodes [ckey ] = Node (IdentityInterface (fields = self .output_names ),
1311
+ self ._outnodes [ckey ] = Node (IdentityInterface (
1312
+ fields = self .output_names ),
1305
1313
name = 'out%02d' % cid )
1306
1314
1307
-
1308
1315
# Check that interfaces are satisfied
1309
1316
if ((workflow .input_names != self .input_names ) or
1310
- (workflow .output_names != self .output_names )):
1317
+ (workflow .output_names != self .output_names )):
1311
1318
raise RuntimeError ('Workflow does not meet the general interface' )
1312
1319
1313
1320
self .connect ([('in' , workflow ), (workflow , self ._outnodes [ckey ]),
1314
1321
(self ._outnodes [ckey ], 'out' )])
1315
1322
1316
-
1317
1323
def write_graph (self , * args , ** kwargs ):
1318
- return super (GraftWorkflow ,self ).write_graph (* args , ** kwargs )
1324
+ return super (GraftWorkflow , self ).write_graph (* args , ** kwargs )
1319
1325
1320
1326
def run (self , * args , ** kwargs ):
1321
- return super (GraftWorkflow ,self ).run (* args , ** kwargs )
1327
+ return super (GraftWorkflow , self ).run (* args , ** kwargs )
1322
1328
1323
1329
1324
1330
class Node (WorkflowBase ):
0 commit comments