@@ -365,9 +365,10 @@ def test_odir_init():
365
365
366
366
367
367
@pytest .mark .flaky (reruns = 2 ) # when dask
368
- def test_task_nostate_1 (plugin_dask_opt ):
368
+ def test_task_nostate_1 (plugin_dask_opt , tmpdir ):
369
369
""" task without splitter"""
370
370
nn = fun_addtwo (name = "NA" , a = 3 )
371
+ nn .cache_dir = tmpdir
371
372
assert np .allclose (nn .inputs .a , [3 ])
372
373
assert nn .state is None
373
374
@@ -405,9 +406,10 @@ def test_task_nostate_1_call():
405
406
406
407
407
408
@pytest .mark .flaky (reruns = 2 ) # when dask
408
- def test_task_nostate_1_call_subm (plugin_dask_opt ):
409
+ def test_task_nostate_1_call_subm (plugin_dask_opt , tmpdir ):
409
410
""" task without splitter"""
410
411
nn = fun_addtwo (name = "NA" , a = 3 )
412
+ nn .cache_dir = tmpdir
411
413
assert np .allclose (nn .inputs .a , [3 ])
412
414
assert nn .state is None
413
415
@@ -422,9 +424,10 @@ def test_task_nostate_1_call_subm(plugin_dask_opt):
422
424
423
425
424
426
@pytest .mark .flaky (reruns = 2 ) # when dask
425
- def test_task_nostate_1_call_plug (plugin_dask_opt ):
427
+ def test_task_nostate_1_call_plug (plugin_dask_opt , tmpdir ):
426
428
""" task without splitter"""
427
429
nn = fun_addtwo (name = "NA" , a = 3 )
430
+ nn .cache_dir = tmpdir
428
431
assert np .allclose (nn .inputs .a , [3 ])
429
432
assert nn .state is None
430
433
@@ -450,9 +453,10 @@ def test_task_nostate_1_call_updateinp():
450
453
assert nn .output_dir .exists ()
451
454
452
455
453
- def test_task_nostate_2 (plugin ):
456
+ def test_task_nostate_2 (plugin , tmpdir ):
454
457
""" task with a list as an input, but no splitter"""
455
458
nn = moment (name = "NA" , n = 3 , lst = [2 , 3 , 4 ])
459
+ nn .cache_dir = tmpdir
456
460
assert np .allclose (nn .inputs .n , [3 ])
457
461
assert np .allclose (nn .inputs .lst , [2 , 3 , 4 ])
458
462
assert nn .state is None
@@ -467,9 +471,10 @@ def test_task_nostate_2(plugin):
467
471
assert nn .output_dir .exists ()
468
472
469
473
470
- def test_task_nostate_3 (plugin ):
474
+ def test_task_nostate_3 (plugin , tmpdir ):
471
475
""" task with a dictionary as an input"""
472
476
nn = fun_dict (name = "NA" , d = {"a" : "ala" , "b" : "bala" })
477
+ nn .cache_dir = tmpdir
473
478
assert nn .inputs .d == {"a" : "ala" , "b" : "bala" }
474
479
475
480
with Submitter (plugin = plugin ) as sub :
@@ -489,6 +494,7 @@ def test_task_nostate_4(plugin, tmpdir):
489
494
f .write ("hello from pydra\n " )
490
495
491
496
nn = fun_file (name = "NA" , filename = file1 )
497
+ nn .cache_dir = tmpdir
492
498
493
499
with Submitter (plugin ) as sub :
494
500
sub (nn )
@@ -719,13 +725,14 @@ def test_task_nostate_cachelocations_updated(plugin, tmpdir):
719
725
720
726
@pytest .mark .flaky (reruns = 2 ) # when dask
721
727
@pytest .mark .parametrize ("input_type" , ["list" , "array" ])
722
- def test_task_state_1 (plugin_dask_opt , input_type ):
728
+ def test_task_state_1 (plugin_dask_opt , input_type , tmpdir ):
723
729
""" task with the simplest splitter"""
724
730
a_in = [3 , 5 ]
725
731
if input_type == "array" :
726
732
a_in = np .array (a_in )
727
733
728
734
nn = fun_addtwo (name = "NA" ).split (splitter = "a" , a = a_in )
735
+ nn .cache_dir = tmpdir
729
736
730
737
assert nn .state .splitter == "NA.a"
731
738
assert nn .state .splitter_rpn == ["NA.a" ]
@@ -761,11 +768,12 @@ def test_task_state_1(plugin_dask_opt, input_type):
761
768
assert odir .exists ()
762
769
763
770
764
- def test_task_state_1a (plugin ):
771
+ def test_task_state_1a (plugin , tmpdir ):
765
772
""" task with the simplest splitter (inputs set separately)"""
766
773
nn = fun_addtwo (name = "NA" )
767
774
nn .split (splitter = "a" )
768
775
nn .inputs .a = [3 , 5 ]
776
+ nn .cache_dir = tmpdir
769
777
770
778
assert nn .state .splitter == "NA.a"
771
779
assert nn .state .splitter_rpn == ["NA.a" ]
@@ -781,11 +789,12 @@ def test_task_state_1a(plugin):
781
789
assert results [i ].output .out == res [1 ]
782
790
783
791
784
- def test_task_state_singl_1 (plugin ):
792
+ def test_task_state_singl_1 (plugin , tmpdir ):
785
793
""" Tasks with two inputs and a splitter (no combiner)
786
794
one input is a single value, the other is in the splitter and combiner
787
795
"""
788
796
nn = fun_addvar (name = "NA" ).split (splitter = "a" , a = [3 , 5 ], b = 10 )
797
+ nn .cache_dir = tmpdir
789
798
790
799
assert nn .inputs .a == [3 , 5 ]
791
800
assert nn .inputs .b == 10
@@ -839,7 +848,14 @@ def test_task_state_singl_1(plugin):
839
848
)
840
849
@pytest .mark .parametrize ("input_type" , ["list" , "array" , "mixed" ])
841
850
def test_task_state_2 (
842
- plugin , splitter , state_splitter , state_rpn , expected , expected_ind , input_type
851
+ plugin ,
852
+ splitter ,
853
+ state_splitter ,
854
+ state_rpn ,
855
+ expected ,
856
+ expected_ind ,
857
+ input_type ,
858
+ tmpdir ,
843
859
):
844
860
""" Tasks with two inputs and a splitter (no combiner)"""
845
861
a_in , b_in = [3 , 5 ], [10 , 20 ]
@@ -848,6 +864,8 @@ def test_task_state_2(
848
864
elif input_type == "mixed" :
849
865
a_in = np .array (a_in )
850
866
nn = fun_addvar (name = "NA" ).split (splitter = splitter , a = a_in , b = b_in )
867
+ nn .cache_dir = tmpdir
868
+
851
869
assert (nn .inputs .a == np .array ([3 , 5 ])).all ()
852
870
assert (nn .inputs .b == np .array ([10 , 20 ])).all ()
853
871
assert nn .state .splitter == state_splitter
@@ -883,9 +901,10 @@ def test_task_state_2(
883
901
assert odir .exists ()
884
902
885
903
886
- def test_task_state_3 (plugin ):
904
+ def test_task_state_3 (plugin , tmpdir ):
887
905
""" task with the simplest splitter, the input is an empty list"""
888
906
nn = fun_addtwo (name = "NA" ).split (splitter = "a" , a = [])
907
+ nn .cache_dir = tmpdir
889
908
890
909
assert nn .state .splitter == "NA.a"
891
910
assert nn .state .splitter_rpn == ["NA.a" ]
@@ -904,12 +923,14 @@ def test_task_state_3(plugin):
904
923
905
924
906
925
@pytest .mark .parametrize ("input_type" , ["list" , "array" ])
907
- def test_task_state_4 (plugin , input_type ):
926
+ def test_task_state_4 (plugin , input_type , tmpdir ):
908
927
""" task with a list as an input, and a simple splitter """
909
928
lst_in = [[2 , 3 , 4 ], [1 , 2 , 3 ]]
910
929
if input_type == "array" :
911
930
lst_in = np .array (lst_in )
912
931
nn = moment (name = "NA" , n = 3 , lst = lst_in ).split (splitter = "lst" )
932
+ nn .cache_dir = tmpdir
933
+
913
934
assert np .allclose (nn .inputs .n , 3 )
914
935
assert np .allclose (nn .inputs .lst , [[2 , 3 , 4 ], [1 , 2 , 3 ]])
915
936
assert nn .state .splitter == "NA.lst"
@@ -935,9 +956,11 @@ def test_task_state_4(plugin, input_type):
935
956
assert odir .exists ()
936
957
937
958
938
- def test_task_state_4a (plugin ):
959
+ def test_task_state_4a (plugin , tmpdir ):
939
960
""" task with a tuple as an input, and a simple splitter """
940
961
nn = moment (name = "NA" , n = 3 , lst = [(2 , 3 , 4 ), (1 , 2 , 3 )]).split (splitter = "lst" )
962
+ nn .cache_dir = tmpdir
963
+
941
964
assert np .allclose (nn .inputs .n , 3 )
942
965
assert np .allclose (nn .inputs .lst , [[2 , 3 , 4 ], [1 , 2 , 3 ]])
943
966
assert nn .state .splitter == "NA.lst"
@@ -955,11 +978,13 @@ def test_task_state_4a(plugin):
955
978
assert odir .exists ()
956
979
957
980
958
- def test_task_state_5 (plugin ):
981
+ def test_task_state_5 (plugin , tmpdir ):
959
982
""" task with a list as an input, and the variable is part of the scalar splitter"""
960
983
nn = moment (name = "NA" , n = [1 , 3 ], lst = [[2 , 3 , 4 ], [1 , 2 , 3 ]]).split (
961
984
splitter = ("n" , "lst" )
962
985
)
986
+ nn .cache_dir = tmpdir
987
+
963
988
assert np .allclose (nn .inputs .n , [1 , 3 ])
964
989
assert np .allclose (nn .inputs .lst , [[2 , 3 , 4 ], [1 , 2 , 3 ]])
965
990
assert nn .state .splitter == ("NA.n" , "NA.lst" )
@@ -977,13 +1002,15 @@ def test_task_state_5(plugin):
977
1002
assert odir .exists ()
978
1003
979
1004
980
- def test_task_state_5_exception (plugin ):
1005
+ def test_task_state_5_exception (plugin , tmpdir ):
981
1006
""" task with a list as an input, and the variable is part of the scalar splitter
982
1007
the shapes are not matching, so exception should be raised
983
1008
"""
984
1009
nn = moment (name = "NA" , n = [1 , 3 , 3 ], lst = [[2 , 3 , 4 ], [1 , 2 , 3 ]]).split (
985
1010
splitter = ("n" , "lst" )
986
1011
)
1012
+ nn .cache_dir = tmpdir
1013
+
987
1014
assert np .allclose (nn .inputs .n , [1 , 3 , 3 ])
988
1015
assert np .allclose (nn .inputs .lst , [[2 , 3 , 4 ], [1 , 2 , 3 ]])
989
1016
assert nn .state .splitter == ("NA.n" , "NA.lst" )
@@ -994,11 +1021,13 @@ def test_task_state_5_exception(plugin):
994
1021
assert "shape" in str (excinfo .value )
995
1022
996
1023
997
- def test_task_state_6 (plugin ):
1024
+ def test_task_state_6 (plugin , tmpdir ):
998
1025
""" ask with a list as an input, and the variable is part of the outer splitter """
999
1026
nn = moment (name = "NA" , n = [1 , 3 ], lst = [[2 , 3 , 4 ], [1 , 2 , 3 ]]).split (
1000
1027
splitter = ["n" , "lst" ]
1001
1028
)
1029
+ nn .cache_dir = tmpdir
1030
+
1002
1031
assert np .allclose (nn .inputs .n , [1 , 3 ])
1003
1032
assert np .allclose (nn .inputs .lst , [[2 , 3 , 4 ], [1 , 2 , 3 ]])
1004
1033
assert nn .state .splitter == ["NA.n" , "NA.lst" ]
@@ -1016,11 +1045,13 @@ def test_task_state_6(plugin):
1016
1045
assert odir .exists ()
1017
1046
1018
1047
1019
- def test_task_state_6a (plugin ):
1048
+ def test_task_state_6a (plugin , tmpdir ):
1020
1049
""" ask with a tuple as an input, and the variable is part of the outer splitter """
1021
1050
nn = moment (name = "NA" , n = [1 , 3 ], lst = [(2 , 3 , 4 ), (1 , 2 , 3 )]).split (
1022
1051
splitter = ["n" , "lst" ]
1023
1052
)
1053
+ nn .cache_dir = tmpdir
1054
+
1024
1055
assert np .allclose (nn .inputs .n , [1 , 3 ])
1025
1056
assert np .allclose (nn .inputs .lst , [[2 , 3 , 4 ], [1 , 2 , 3 ]])
1026
1057
assert nn .state .splitter == ["NA.n" , "NA.lst" ]
@@ -1039,9 +1070,10 @@ def test_task_state_6a(plugin):
1039
1070
1040
1071
1041
1072
@pytest .mark .flaky (reruns = 2 ) # when dask
1042
- def test_task_state_comb_1 (plugin_dask_opt ):
1073
+ def test_task_state_comb_1 (plugin_dask_opt , tmpdir ):
1043
1074
""" task with the simplest splitter and combiner"""
1044
1075
nn = fun_addtwo (name = "NA" ).split (a = [3 , 5 ], splitter = "a" ).combine (combiner = "a" )
1076
+ nn .cache_dir = tmpdir
1045
1077
1046
1078
assert (nn .inputs .a == np .array ([3 , 5 ])).all ()
1047
1079
@@ -1173,13 +1205,15 @@ def test_task_state_comb_2(
1173
1205
state_rpn_final ,
1174
1206
expected ,
1175
1207
expected_val ,
1208
+ tmpdir ,
1176
1209
):
1177
1210
""" Tasks with scalar and outer splitters and partial or full combiners"""
1178
1211
nn = (
1179
1212
fun_addvar (name = "NA" )
1180
1213
.split (a = [3 , 5 ], b = [10 , 20 ], splitter = splitter )
1181
1214
.combine (combiner = combiner )
1182
1215
)
1216
+ nn .cache_dir = tmpdir
1183
1217
1184
1218
assert (nn .inputs .a == np .array ([3 , 5 ])).all ()
1185
1219
@@ -1219,11 +1253,12 @@ def test_task_state_comb_2(
1219
1253
assert odir .exists ()
1220
1254
1221
1255
1222
- def test_task_state_comb_singl_1 (plugin ):
1256
+ def test_task_state_comb_singl_1 (plugin , tmpdir ):
1223
1257
""" Tasks with two inputs;
1224
1258
one input is a single value, the other is in the splitter and combiner
1225
1259
"""
1226
1260
nn = fun_addvar (name = "NA" ).split (splitter = "a" , a = [3 , 5 ], b = 10 ).combine (combiner = "a" )
1261
+ nn .cache_dir = tmpdir
1227
1262
1228
1263
assert nn .inputs .a == [3 , 5 ]
1229
1264
assert nn .inputs .b == 10
@@ -1248,9 +1283,10 @@ def test_task_state_comb_singl_1(plugin):
1248
1283
assert odir .exists ()
1249
1284
1250
1285
1251
- def test_task_state_comb_3 (plugin ):
1286
+ def test_task_state_comb_3 (plugin , tmpdir ):
1252
1287
""" task with the simplest splitter, the input is an empty list"""
1253
1288
nn = fun_addtwo (name = "NA" ).split (splitter = "a" , a = []).combine (combiner = ["a" ])
1289
+ nn .cache_dir = tmpdir
1254
1290
1255
1291
assert nn .state .splitter == "NA.a"
1256
1292
assert nn .state .splitter_rpn == ["NA.a" ]
0 commit comments