10
10
11
11
import networkx as nx
12
12
13
- from nipype .testing import (assert_raises , assert_equal , assert_true ,
14
- assert_false )
13
+ from nipype .testing import (assert_raises , assert_equal , assert_true , assert_false )
15
14
import nipype .interfaces .base as nib
16
15
import nipype .pipeline .engine as pe
17
16
from nipype import logging
@@ -551,7 +550,7 @@ def func2(a):
551
550
w1 .connect (n1 , ('a' , modify ), n2 ,'a' )
552
551
w1 .base_dir = wd
553
552
554
- w1 .config = { ' crashdump_dir': wd }
553
+ w1 .config [ 'execution' ][ ' crashdump_dir'] = wd
555
554
# generate outputs
556
555
error_raised = False
557
556
try :
@@ -581,7 +580,7 @@ def func1(in1):
581
580
n1 .inputs .in1 = [1 ]
582
581
w1 = Workflow (name = 'test' )
583
582
w1 .base_dir = wd
584
- w1 .config = { ' crashdump_dir': wd }
583
+ w1 .config [ 'execution' ][ ' crashdump_dir'] = wd
585
584
w1 .add_nodes ([n1 ])
586
585
w1 .run ()
587
586
n1 .inputs .in1 = [2 ]
@@ -606,3 +605,54 @@ def func1(in1):
606
605
yield assert_false , error_raised
607
606
os .chdir (cwd )
608
607
rmtree (wd )
608
+
609
+ def test_serial_input ():
610
+ cwd = os .getcwd ()
611
+ wd = mkdtemp ()
612
+ os .chdir (wd )
613
+ from nipype import MapNode , Function , Workflow
614
+ def func1 (in1 ):
615
+ return in1
616
+ n1 = MapNode (Function (input_names = ['in1' ],
617
+ output_names = ['out' ],
618
+ function = func1 ),
619
+ iterfield = ['in1' ],
620
+ name = 'n1' )
621
+ n1 .inputs .in1 = [1 ,2 ,3 ]
622
+
623
+
624
+ w1 = Workflow (name = 'test' )
625
+ w1 .base_dir = wd
626
+ w1 .add_nodes ([n1 ])
627
+ # set local check
628
+ w1 .config ['execution' ] = {'stop_on_first_crash' : 'true' ,
629
+ 'local_hash_check' : 'true' ,
630
+ 'crashdump_dir' : wd }
631
+
632
+ # test output of num_subnodes method when serial is default (False)
633
+ yield assert_equal , n1 .num_subnodes (), len (n1 .inputs .in1 )
634
+
635
+ # test running the workflow on default conditions
636
+ error_raised = False
637
+ try :
638
+ w1 .run (plugin = 'MultiProc' )
639
+ except Exception , e :
640
+ pe .logger .info ('Exception: %s' % str (e ))
641
+ error_raised = True
642
+ yield assert_false , error_raised
643
+
644
+ # test output of num_subnodes method when serial is True
645
+ n1 ._serial = True
646
+ yield assert_equal , n1 .num_subnodes (), 1
647
+
648
+ # test running the workflow on serial conditions
649
+ error_raised = False
650
+ try :
651
+ w1 .run (plugin = 'MultiProc' )
652
+ except Exception , e :
653
+ pe .logger .info ('Exception: %s' % str (e ))
654
+ error_raised = True
655
+ yield assert_false , error_raised
656
+
657
+ os .chdir (cwd )
658
+ rmtree (wd )
0 commit comments