@@ -349,6 +349,7 @@ def test_odir_init():
349
349
# Tests for tasks without state (i.e. no splitter)
350
350
351
351
352
+ @pytest .mark .flaky (reruns = 2 ) # when dask
352
353
def test_task_nostate_1 (plugin_dask_opt ):
353
354
""" task without splitter"""
354
355
nn = fun_addtwo (name = "NA" , a = 3 )
@@ -377,6 +378,7 @@ def test_task_nostate_1(plugin_dask_opt):
377
378
assert nn .output_dir .exists ()
378
379
379
380
381
+ @pytest .mark .flaky (reruns = 2 ) # when dask
380
382
def test_task_nostate_1_call_subm (plugin_dask_opt ):
381
383
""" task without splitter"""
382
384
nn = fun_addtwo (name = "NA" , a = 3 )
@@ -393,6 +395,7 @@ def test_task_nostate_1_call_subm(plugin_dask_opt):
393
395
assert nn .output_dir .exists ()
394
396
395
397
398
+ @pytest .mark .flaky (reruns = 2 ) # when dask
396
399
def test_task_nostate_1_call_plug (plugin_dask_opt ):
397
400
""" task without splitter"""
398
401
nn = fun_addtwo (name = "NA" , a = 3 )
@@ -521,6 +524,7 @@ def test_task_nostate_7():
521
524
# Testing caching for tasks without states
522
525
523
526
527
+ @pytest .mark .flaky (reruns = 2 ) # when dask
524
528
def test_task_nostate_cachedir (plugin_dask_opt , tmpdir ):
525
529
""" task with provided cache_dir using pytest tmpdir"""
526
530
cache_dir = tmpdir .mkdir ("test_task_nostate" )
@@ -536,6 +540,7 @@ def test_task_nostate_cachedir(plugin_dask_opt, tmpdir):
536
540
assert results .output .out == 5
537
541
538
542
543
+ @pytest .mark .flaky (reruns = 2 ) # when dask
539
544
def test_task_nostate_cachedir_relativepath (tmpdir , plugin_dask_opt ):
540
545
""" task with provided cache_dir as relative path"""
541
546
cwd = tmpdir .chdir ()
@@ -556,6 +561,7 @@ def test_task_nostate_cachedir_relativepath(tmpdir, plugin_dask_opt):
556
561
shutil .rmtree (cache_dir )
557
562
558
563
564
+ @pytest .mark .flaky (reruns = 2 ) # when dask
559
565
def test_task_nostate_cachelocations (plugin_dask_opt , tmpdir ):
560
566
"""
561
567
Two identical tasks with provided cache_dir;
@@ -686,6 +692,7 @@ def test_task_nostate_cachelocations_updated(plugin, tmpdir):
686
692
# Tests for tasks with states (i.e. with splitter)
687
693
688
694
695
+ @pytest .mark .flaky (reruns = 2 ) # when dask
689
696
def test_task_state_1 (plugin_dask_opt ):
690
697
""" task with the simplest splitter"""
691
698
nn = fun_addtwo (name = "NA" ).split (splitter = "a" , a = [3 , 5 ])
@@ -724,7 +731,7 @@ def test_task_state_1(plugin_dask_opt):
724
731
assert odir .exists ()
725
732
726
733
727
- def test_task_state_1a (plugin_dask_opt ):
734
+ def test_task_state_1a (plugin ):
728
735
""" task with the simplest splitter (inputs set separately)"""
729
736
nn = fun_addtwo (name = "NA" )
730
737
nn .split (splitter = "a" )
@@ -734,7 +741,7 @@ def test_task_state_1a(plugin_dask_opt):
734
741
assert nn .state .splitter_rpn == ["NA.a" ]
735
742
assert (nn .inputs .a == np .array ([3 , 5 ])).all ()
736
743
737
- with Submitter (plugin = plugin_dask_opt ) as sub :
744
+ with Submitter (plugin = plugin ) as sub :
738
745
sub (nn )
739
746
740
747
# checking the results
@@ -744,6 +751,33 @@ def test_task_state_1a(plugin_dask_opt):
744
751
assert results [i ].output .out == res [1 ]
745
752
746
753
754
+ def test_task_state_singl_1 (plugin ):
755
+ """ Tasks with two inputs and a splitter (no combiner)
756
+ one input is a single value, the other is in the splitter and combiner
757
+ """
758
+ nn = fun_addvar (name = "NA" ).split (splitter = "a" , a = [3 , 5 ], b = 10 )
759
+
760
+ assert nn .inputs .a == [3 , 5 ]
761
+ assert nn .inputs .b == 10
762
+ assert nn .state .splitter == "NA.a"
763
+ assert nn .state .splitter_rpn == ["NA.a" ]
764
+ assert nn .state .splitter_final == "NA.a"
765
+ assert nn .state .splitter_rpn_final == ["NA.a" ]
766
+
767
+ with Submitter (plugin = plugin ) as sub :
768
+ sub (nn )
769
+
770
+ # checking the results
771
+ expected = [({"NA.a" : 3 , "NA.b" : 10 }, 13 ), ({"NA.a" : 5 , "NA.b" : 10 }, 15 )]
772
+ results = nn .result ()
773
+ for i , res in enumerate (expected ):
774
+ assert results [i ].output .out == res [1 ]
775
+ # checking the output_dir
776
+ assert nn .output_dir
777
+ for odir in nn .output_dir :
778
+ assert odir .exists ()
779
+
780
+
747
781
@pytest .mark .parametrize (
748
782
"splitter, state_splitter, state_rpn, expected, expected_ind" ,
749
783
[
@@ -774,7 +808,7 @@ def test_task_state_1a(plugin_dask_opt):
774
808
],
775
809
)
776
810
def test_task_state_2 (
777
- plugin_dask_opt , splitter , state_splitter , state_rpn , expected , expected_ind
811
+ plugin , splitter , state_splitter , state_rpn , expected , expected_ind
778
812
):
779
813
""" Tasks with two inputs and a splitter (no combiner)"""
780
814
nn = fun_addvar (name = "NA" ).split (splitter = splitter , a = [3 , 5 ], b = [10 , 20 ])
@@ -786,7 +820,7 @@ def test_task_state_2(
786
820
assert nn .state .splitter_final == state_splitter
787
821
assert nn .state .splitter_rpn_final == state_rpn
788
822
789
- with Submitter (plugin = plugin_dask_opt ) as sub :
823
+ with Submitter (plugin = plugin ) as sub :
790
824
sub (nn )
791
825
792
826
# checking the results
@@ -814,34 +848,7 @@ def test_task_state_2(
814
848
assert odir .exists ()
815
849
816
850
817
- def test_task_state_singl_1 (plugin_dask_opt ):
818
- """ Tasks with two inputs and a splitter (no combiner)
819
- one input is a single value, the other is in the splitter and combiner
820
- """
821
- nn = fun_addvar (name = "NA" ).split (splitter = "a" , a = [3 , 5 ], b = 10 )
822
-
823
- assert nn .inputs .a == [3 , 5 ]
824
- assert nn .inputs .b == 10
825
- assert nn .state .splitter == "NA.a"
826
- assert nn .state .splitter_rpn == ["NA.a" ]
827
- assert nn .state .splitter_final == "NA.a"
828
- assert nn .state .splitter_rpn_final == ["NA.a" ]
829
-
830
- with Submitter (plugin = plugin_dask_opt ) as sub :
831
- sub (nn )
832
-
833
- # checking the results
834
- expected = [({"NA.a" : 3 , "NA.b" : 10 }, 13 ), ({"NA.a" : 5 , "NA.b" : 10 }, 15 )]
835
- results = nn .result ()
836
- for i , res in enumerate (expected ):
837
- assert results [i ].output .out == res [1 ]
838
- # checking the output_dir
839
- assert nn .output_dir
840
- for odir in nn .output_dir :
841
- assert odir .exists ()
842
-
843
-
844
- def test_task_state_2 (plugin ):
851
+ def test_task_state_3 (plugin ):
845
852
""" task with the simplest splitter, the input is an empty list"""
846
853
nn = fun_addtwo (name = "NA" ).split (splitter = "a" , a = [])
847
854
@@ -861,7 +868,7 @@ def test_task_state_2(plugin):
861
868
assert nn .output_dir == []
862
869
863
870
864
- def test_task_state_3 (plugin ):
871
+ def test_task_state_4 (plugin ):
865
872
""" task with a list as an input, and a simple splitter """
866
873
nn = moment (name = "NA" , n = 3 , lst = [[2 , 3 , 4 ], [1 , 2 , 3 ]]).split (splitter = "lst" )
867
874
assert np .allclose (nn .inputs .n , 3 )
@@ -881,7 +888,7 @@ def test_task_state_3(plugin):
881
888
assert odir .exists ()
882
889
883
890
884
- def test_task_state_3a (plugin ):
891
+ def test_task_state_4a (plugin ):
885
892
""" task with a tuple as an input, and a simple splitter """
886
893
nn = moment (name = "NA" , n = 3 , lst = [(2 , 3 , 4 ), (1 , 2 , 3 )]).split (splitter = "lst" )
887
894
assert np .allclose (nn .inputs .n , 3 )
@@ -901,7 +908,7 @@ def test_task_state_3a(plugin):
901
908
assert odir .exists ()
902
909
903
910
904
- def test_task_state_4 (plugin ):
911
+ def test_task_state_5 (plugin ):
905
912
""" task with a list as an input, and the variable is part of the scalar splitter"""
906
913
nn = moment (name = "NA" , n = [1 , 3 ], lst = [[2 , 3 , 4 ], [1 , 2 , 3 ]]).split (
907
914
splitter = ("n" , "lst" )
@@ -923,7 +930,7 @@ def test_task_state_4(plugin):
923
930
assert odir .exists ()
924
931
925
932
926
- def test_task_state_4_exception (plugin ):
933
+ def test_task_state_5_exception (plugin ):
927
934
""" task with a list as an input, and the variable is part of the scalar splitter
928
935
the shapes are not matching, so exception should be raised
929
936
"""
@@ -940,7 +947,7 @@ def test_task_state_4_exception(plugin):
940
947
assert "shape" in str (excinfo .value )
941
948
942
949
943
- def test_task_state_5 ( plugin_dask_opt ):
950
+ def test_task_state_6 ( plugin ):
944
951
""" ask with a list as an input, and the variable is part of the outer splitter """
945
952
nn = moment (name = "NA" , n = [1 , 3 ], lst = [[2 , 3 , 4 ], [1 , 2 , 3 ]]).split (
946
953
splitter = ["n" , "lst" ]
@@ -949,7 +956,7 @@ def test_task_state_5(plugin_dask_opt):
949
956
assert np .allclose (nn .inputs .lst , [[2 , 3 , 4 ], [1 , 2 , 3 ]])
950
957
assert nn .state .splitter == ["NA.n" , "NA.lst" ]
951
958
952
- with Submitter (plugin = plugin_dask_opt ) as sub :
959
+ with Submitter (plugin = plugin ) as sub :
953
960
sub (nn )
954
961
955
962
# checking the results
@@ -962,7 +969,7 @@ def test_task_state_5(plugin_dask_opt):
962
969
assert odir .exists ()
963
970
964
971
965
- def test_task_state_5a (plugin ):
972
+ def test_task_state_6a (plugin ):
966
973
""" ask with a tuple as an input, and the variable is part of the outer splitter """
967
974
nn = moment (name = "NA" , n = [1 , 3 ], lst = [(2 , 3 , 4 ), (1 , 2 , 3 )]).split (
968
975
splitter = ["n" , "lst" ]
@@ -1164,7 +1171,7 @@ def test_task_state_comb_2(
1164
1171
assert odir .exists ()
1165
1172
1166
1173
1167
- def test_task_state_comb_singl_1 (plugin_dask_opt ):
1174
+ def test_task_state_comb_singl_1 (plugin ):
1168
1175
""" Tasks with two inputs;
1169
1176
one input is a single value, the other is in the splitter and combiner
1170
1177
"""
@@ -1178,7 +1185,7 @@ def test_task_state_comb_singl_1(plugin_dask_opt):
1178
1185
assert nn .state .splitter_final == None
1179
1186
assert nn .state .splitter_rpn_final == []
1180
1187
1181
- with Submitter (plugin = plugin_dask_opt ) as sub :
1188
+ with Submitter (plugin = plugin ) as sub :
1182
1189
sub (nn )
1183
1190
1184
1191
# checking the results
@@ -1290,7 +1297,7 @@ def test_task_state_cachedir(plugin_dask_opt, tmpdir):
1290
1297
assert results [i ].output .out == res [1 ]
1291
1298
1292
1299
1293
- def test_task_state_cachelocations (plugin_dask_opt , tmpdir ):
1300
+ def test_task_state_cachelocations (plugin , tmpdir ):
1294
1301
"""
1295
1302
Two identical tasks with a state and cache_dir;
1296
1303
the second task has cache_locations and should not recompute the results
@@ -1299,13 +1306,13 @@ def test_task_state_cachelocations(plugin_dask_opt, tmpdir):
1299
1306
cache_dir2 = tmpdir .mkdir ("test_task_nostate2" )
1300
1307
1301
1308
nn = fun_addtwo (name = "NA" , a = 3 , cache_dir = cache_dir ).split (splitter = "a" , a = [3 , 5 ])
1302
- with Submitter (plugin = plugin_dask_opt ) as sub :
1309
+ with Submitter (plugin = plugin ) as sub :
1303
1310
sub (nn )
1304
1311
1305
1312
nn2 = fun_addtwo (
1306
1313
name = "NA" , a = 3 , cache_dir = cache_dir2 , cache_locations = cache_dir
1307
1314
).split (splitter = "a" , a = [3 , 5 ])
1308
- with Submitter (plugin = plugin_dask_opt ) as sub :
1315
+ with Submitter (plugin = plugin ) as sub :
1309
1316
sub (nn2 )
1310
1317
1311
1318
# checking the results
0 commit comments