@@ -602,6 +602,46 @@ def test_set_join_node_file_input():
602
602
os .chdir (cwd )
603
603
rmtree (wd )
604
604
605
+ def test_nested_workflow_join ():
606
+ """Test collecting join inputs within a nested workflow"""
607
+ cwd = os .getcwd ()
608
+ wd = mkdtemp ()
609
+ os .chdir (wd )
610
+
611
+ # Make the nested workflow
612
+ def nested_wf (i , name = 'smallwf' ):
613
+ #iterables with list of nums
614
+ inputspec = pe .Node (IdentityInterface (fields = ['n' ]), name = 'inputspec' )
615
+ inputspec .iterables = [('n' , i )]
616
+ # increment each iterable before joining
617
+ pre_join = pe .Node (IncrementInterface (),
618
+ name = 'pre_join' )
619
+ # rejoin nums into list
620
+ join = pe .JoinNode (IdentityInterface (fields = ['n' ]),
621
+ joinsource = 'inputspec' ,
622
+ joinfield = 'n' ,
623
+ name = 'join' )
624
+ #define and connect nested workflow
625
+ wf = pe .Workflow (name = 'wf_%d' % i [0 ])
626
+ wf .connect (inputspec , 'n' , pre_join , 'input1' )
627
+ wf .connect (pre_join , 'output1' , join , 'n' )
628
+ return wf
629
+ # master wf
630
+ meta_wf = Workflow (name = 'meta' , base_dir = '.' )
631
+ # add each mini-workflow to master
632
+ for i in [[1 ,3 ],[2 ,4 ]]:
633
+ mini_wf = nested_wf (i )
634
+ meta_wf .add_nodes ([mini_wf ])
635
+
636
+ result = meta_wf .run ()
637
+
638
+ # there should be six nodes in total
639
+ assert_equal (len (result .nodes ()), 6 ,
640
+ "The number of expanded nodes is incorrect." )
641
+
642
+ os .chdir (cwd )
643
+ rmtree (wd )
644
+
605
645
606
646
if __name__ == "__main__" :
607
647
import nose
0 commit comments