1
1
import pytest
2
- import shutil , os
2
+ import shutil , os , sys
3
3
import time
4
4
import attr
5
5
from pathlib import Path
@@ -2070,9 +2070,11 @@ def test_wf_nostate_cachelocations(plugin, tmpdir):
2070
2070
results2 = wf2 .result ()
2071
2071
assert 8 == results2 .output .out
2072
2072
2073
- # checking execution time
2074
- assert t1 > 3
2075
- assert t2 < 0.5
2073
+ # checking execution time (for unix and cf)
2074
+ # for win and dask/slurm the time for dir creation etc. might take much longer
2075
+ if sys .platform .startswith ("win" ) and plugin == "cf" :
2076
+ assert t1 > 2
2077
+ assert t2 < 0.5
2076
2078
2077
2079
# checking if the second wf didn't run again
2078
2080
assert wf1 .output_dir .exists ()
@@ -2125,10 +2127,12 @@ def test_wf_nostate_cachelocations_a(plugin, tmpdir):
2125
2127
results2 = wf2 .result ()
2126
2128
assert 8 == results2 .output .out
2127
2129
2128
- # checking execution time (second one should be quick)
2129
- assert t1 > 3
2130
- # testing relative values (windows or slurm takes much longer to create wf itself)
2131
- assert t2 / t1 < 0.9
2130
+ # for win and dask/slurm the time for dir creation etc. might take much longer
2131
+ if sys .platform .startswith ("win" ) and plugin == "cf" :
2132
+ # checking execution time (second one should be quick)
2133
+ assert t1 > 2
2134
+ # testing relative values (windows or slurm takes much longer to create wf itself)
2135
+ assert t2 < 0.5
2132
2136
2133
2137
# checking if both wf.output_dir are created
2134
2138
assert wf1 .output_dir .exists ()
@@ -2184,9 +2188,11 @@ def test_wf_nostate_cachelocations_b(plugin, tmpdir):
2184
2188
results2 = wf2 .result ()
2185
2189
assert 8 == results2 .output .out == results2 .output .out_pr
2186
2190
2187
- # checking execution time
2188
- assert t1 > 3
2189
- assert t2 / t1 < 0.9
2191
+ # for win and dask/slurm the time for dir creation etc. might take much longer
2192
+ if sys .platform .startswith ("win" ) and plugin == "cf" :
2193
+ # checking execution time
2194
+ assert t1 > 2
2195
+ assert t2 < 0.5
2190
2196
2191
2197
# checking if the second wf didn't run again
2192
2198
assert wf1 .output_dir .exists ()
@@ -2240,10 +2246,12 @@ def test_wf_nostate_cachelocations_setoutputchange(plugin, tmpdir):
2240
2246
results2 = wf2 .result ()
2241
2247
assert 8 == results2 .output .out2
2242
2248
2243
- # checking execution time (the second wf should be fast, nodes do not have to rerun)
2244
- assert t1 > 3
2245
- # testing relative values (windows or slurm takes much longer to create wf itself)
2246
- assert t2 / t1 < 0.9
2249
+ # for win and dask/slurm the time for dir creation etc. might take much longer
2250
+ if sys .platform .startswith ("win" ) and plugin == "cf" :
2251
+ # checking execution time (the second wf should be fast, nodes do not have to rerun)
2252
+ assert t1 > 2
2253
+ # testing relative values (windows or slurm takes much longer to create wf itself)
2254
+ assert t2 < 0.5
2247
2255
2248
2256
# both wf output_dirs should be created
2249
2257
assert wf1 .output_dir .exists ()
@@ -2294,10 +2302,12 @@ def test_wf_nostate_cachelocations_setoutputchange_a(plugin, tmpdir):
2294
2302
results2 = wf2 .result ()
2295
2303
assert 8 == results2 .output .out2
2296
2304
2297
- # checking execution time (the second wf should be fast, nodes do not have to rerun)
2298
- assert t1 > 3
2299
- # testing relative values (windows or slurm takes much longer to create wf itself)
2300
- assert t2 / t1 < 0.9
2305
+ # for win and dask/slurm the time for dir creation etc. might take much longer
2306
+ if sys .platform .startswith ("win" ) and plugin == "cf" :
2307
+ # checking execution time (the second wf should be fast, nodes do not have to rerun)
2308
+ assert t1 > 2
2309
+ # testing relative values (windows or slurm takes much longer to create wf itself)
2310
+ assert t2 < 0.5
2301
2311
2302
2312
# both wf output_dirs should be created
2303
2313
assert wf1 .output_dir .exists ()
@@ -2350,9 +2360,11 @@ def test_wf_nostate_cachelocations_forcererun(plugin, tmpdir):
2350
2360
results2 = wf2 .result ()
2351
2361
assert 8 == results2 .output .out
2352
2362
2353
- # checking execution time
2354
- assert t1 > 3
2355
- assert t2 > 3
2363
+ # for win and dask/slurm the time for dir creation etc. might take much longer
2364
+ if sys .platform .startswith ("win" ) and plugin == "cf" :
2365
+ # checking execution time
2366
+ assert t1 > 2
2367
+ assert t2 > 2
2356
2368
2357
2369
# checking if the second wf didn't run again
2358
2370
assert wf1 .output_dir .exists ()
@@ -2413,8 +2425,11 @@ def test_wf_nostate_cachelocations_wftaskrerun_propagateTrue(plugin, tmpdir):
2413
2425
# everything has to be recomputed
2414
2426
assert len (list (Path (cache_dir1 ).glob ("F*" ))) == 2
2415
2427
assert len (list (Path (cache_dir2 ).glob ("F*" ))) == 2
2416
- assert t1 > 3
2417
- assert t2 > 3
2428
+
2429
+ # for win and dask/slurm the time for dir creation etc. might take much longer
2430
+ if sys .platform .startswith ("win" ) and plugin == "cf" :
2431
+ assert t1 > 2
2432
+ assert t2 > 2
2418
2433
2419
2434
2420
2435
def test_wf_nostate_cachelocations_wftaskrerun_propagateFalse (plugin , tmpdir ):
@@ -2470,6 +2485,12 @@ def test_wf_nostate_cachelocations_wftaskrerun_propagateFalse(plugin, tmpdir):
2470
2485
assert wf1 .output_dir .exists ()
2471
2486
assert wf2 .output_dir .exists ()
2472
2487
2488
+ # for win and dask/slurm the time for dir creation etc. might take much longer
2489
+ if sys .platform .startswith ("win" ) and plugin == "cf" :
2490
+ # checking the time
2491
+ assert t1 > 2
2492
+ assert t2 > 2
2493
+
2473
2494
# tasks should not be recomputed
2474
2495
assert len (list (Path (cache_dir1 ).glob ("F*" ))) == 2
2475
2496
assert len (list (Path (cache_dir2 ).glob ("F*" ))) == 0
@@ -2524,14 +2545,17 @@ def test_wf_nostate_cachelocations_taskrerun_wfrerun_propagateFalse(plugin, tmpd
2524
2545
results2 = wf2 .result ()
2525
2546
assert 8 == results2 .output .out
2526
2547
2548
+ # for win and dask/slurm the time for dir creation etc. might take much longer
2549
+ if sys .platform .startswith ("win" ) and plugin == "cf" :
2550
+ # checking the execution time
2551
+ assert t1 > 2
2552
+ assert t2 > 2
2527
2553
# checking if the second wf doesn't runs again
2528
2554
assert wf1 .output_dir .exists ()
2529
2555
assert wf2 .output_dir .exists ()
2530
2556
# the second task should be recomputed
2531
2557
assert len (list (Path (cache_dir1 ).glob ("F*" ))) == 2
2532
2558
assert len (list (Path (cache_dir2 ).glob ("F*" ))) == 1
2533
- assert t1 > 3
2534
- assert t2 > 3
2535
2559
2536
2560
2537
2561
def test_wf_nostate_nodecachelocations (plugin , tmpdir ):
@@ -2578,6 +2602,11 @@ def test_wf_nostate_nodecachelocations(plugin, tmpdir):
2578
2602
results2 = wf2 .result ()
2579
2603
assert 12 == results2 .output .out
2580
2604
2605
+ # for win and dask/slurm the time for dir creation etc. might take much longer
2606
+ if sys .platform .startswith ("win" ) and plugin == "cf" :
2607
+ # checking the execution time
2608
+ assert t1 > 2
2609
+ assert t2 > 2
2581
2610
# checking if the second wf runs again, but runs only one task
2582
2611
assert wf1 .output_dir .exists ()
2583
2612
assert wf2 .output_dir .exists ()
@@ -2627,6 +2656,11 @@ def test_wf_nostate_nodecachelocations_upd(plugin, tmpdir):
2627
2656
results2 = wf2 .result ()
2628
2657
assert 12 == results2 .output .out
2629
2658
2659
+ # for win and dask/slurm the time for dir creation etc. might take much longer
2660
+ if sys .platform .startswith ("win" ) and plugin == "cf" :
2661
+ # checking the execution time
2662
+ assert t1 > 2
2663
+ assert t2 > 2
2630
2664
# checking if the second wf runs again, but runs only one task
2631
2665
assert wf1 .output_dir .exists ()
2632
2666
assert wf2 .output_dir .exists ()
@@ -2684,9 +2718,11 @@ def test_wf_state_cachelocations(plugin, tmpdir):
2684
2718
assert results2 [0 ].output .out == 8
2685
2719
assert results2 [1 ].output .out == 82
2686
2720
2687
- # checking execution time
2688
- assert t1 > 3
2689
- assert t2 < 0.5
2721
+ # for win and dask/slurm the time for dir creation etc. might take much longer
2722
+ if sys .platform .startswith ("win" ) and plugin == "cf" :
2723
+ # checking the execution time
2724
+ assert t1 > 2
2725
+ assert t2 < 0.5
2690
2726
2691
2727
# checking all directories
2692
2728
assert wf1 .output_dir
@@ -2749,9 +2785,11 @@ def test_wf_state_cachelocations_forcererun(plugin, tmpdir):
2749
2785
assert results2 [0 ].output .out == 8
2750
2786
assert results2 [1 ].output .out == 82
2751
2787
2752
- # checking execution time
2753
- assert t1 > 3
2754
- assert t2 > 3
2788
+ # for win and dask/slurm the time for dir creation etc. might take much longer
2789
+ if sys .platform .startswith ("win" ) and plugin == "cf" :
2790
+ # checking the execution time
2791
+ assert t1 > 2
2792
+ assert t2 > 2
2755
2793
2756
2794
# checking all directories
2757
2795
assert wf1 .output_dir
@@ -2816,9 +2854,11 @@ def test_wf_state_cachelocations_updateinp(plugin, tmpdir):
2816
2854
assert results2 [0 ].output .out == 8
2817
2855
assert results2 [1 ].output .out == 82
2818
2856
2819
- # checking execution time
2820
- assert t1 > 3
2821
- assert t2 < 0.5
2857
+ # for win and dask/slurm the time for dir creation etc. might take much longer
2858
+ if sys .platform .startswith ("win" ) and plugin == "cf" :
2859
+ # checking the execution time
2860
+ assert t1 > 2
2861
+ assert t2 < 0.5
2822
2862
2823
2863
# checking all directories
2824
2864
assert wf1 .output_dir
@@ -2930,9 +2970,11 @@ def test_wf_nostate_cachelocations_updated(plugin, tmpdir):
2930
2970
results2 = wf2 .result ()
2931
2971
assert 8 == results2 .output .out
2932
2972
2933
- # checking execution time
2934
- assert t1 > 3
2935
- assert t2 > 3
2973
+ # for win and dask/slurm the time for dir creation etc. might take much longer
2974
+ if sys .platform .startswith ("win" ) and plugin == "cf" :
2975
+ # checking the execution time
2976
+ assert t1 > 2
2977
+ assert t2 > 2
2936
2978
2937
2979
# checking if both wf run
2938
2980
assert wf1 .output_dir .exists ()
@@ -2990,6 +3032,12 @@ def test_wf_nostate_cachelocations_recompute(plugin, tmpdir):
2990
3032
assert wf1 .output_dir .exists ()
2991
3033
assert wf2 .output_dir .exists ()
2992
3034
3035
+ # for win and dask/slurm the time for dir creation etc. might take much longer
3036
+ if sys .platform .startswith ("win" ) and plugin == "cf" :
3037
+ # checking the execution time
3038
+ assert t1 > 2
3039
+ assert t2 > 2
3040
+
2993
3041
# the second wf should have only one task run
2994
3042
assert len (list (Path (cache_dir1 ).glob ("F*" ))) == 2
2995
3043
assert len (list (Path (cache_dir2 ).glob ("F*" ))) == 1
@@ -3044,9 +3092,11 @@ def test_wf_ndstate_cachelocations(plugin, tmpdir):
3044
3092
results2 = wf2 .result ()
3045
3093
assert results2 .output .out == [8 , 82 ]
3046
3094
3047
- # checking execution time
3048
- assert t1 > 3
3049
- assert t2 < 0.5
3095
+ # for win and dask/slurm the time for dir creation etc. might take much longer
3096
+ if sys .platform .startswith ("win" ) and plugin == "cf" :
3097
+ # checking the execution time
3098
+ assert t1 > 2
3099
+ assert t2 < 0.5
3050
3100
3051
3101
# checking all directories
3052
3102
assert wf1 .output_dir .exists ()
@@ -3106,9 +3156,11 @@ def test_wf_ndstate_cachelocations_forcererun(plugin, tmpdir):
3106
3156
results2 = wf2 .result ()
3107
3157
assert results2 .output .out == [8 , 82 ]
3108
3158
3109
- # checking execution time
3110
- assert t1 > 3
3111
- assert t2 > 3
3159
+ # for win and dask/slurm the time for dir creation etc. might take much longer
3160
+ if sys .platform .startswith ("win" ) and plugin == "cf" :
3161
+ # checking the execution time
3162
+ assert t1 > 2
3163
+ assert t2 > 2
3112
3164
3113
3165
# checking all directories
3114
3166
assert wf1 .output_dir .exists ()
@@ -3166,9 +3218,11 @@ def test_wf_ndstate_cachelocations_updatespl(plugin, tmpdir):
3166
3218
results2 = wf2 .result ()
3167
3219
assert results2 .output .out == [8 , 82 ]
3168
3220
3169
- # checking execution time
3170
- assert t1 > 3
3171
- assert t2 < 0.5
3221
+ # for win and dask/slurm the time for dir creation etc. might take much longer
3222
+ if sys .platform .startswith ("win" ) and plugin == "cf" :
3223
+ # checking the execution time
3224
+ assert t1 > 2
3225
+ assert t2 < 0.5
3172
3226
3173
3227
# checking all directories
3174
3228
assert wf1 .output_dir .exists ()
@@ -3227,9 +3281,11 @@ def test_wf_ndstate_cachelocations_recompute(plugin, tmpdir):
3227
3281
results2 = wf2 .result ()
3228
3282
assert results2 .output .out == [8 , 10 , 62 , 82 ]
3229
3283
3230
- # checking execution time
3231
- assert t1 > 3
3232
- assert t2 > 3
3284
+ # for win and dask/slurm the time for dir creation etc. might take much longer
3285
+ if sys .platform .startswith ("win" ) and plugin == "cf" :
3286
+ # checking the execution time
3287
+ assert t1 > 2
3288
+ assert t2 > 2
3233
3289
3234
3290
# checking all directories
3235
3291
assert wf1 .output_dir .exists ()
@@ -3254,8 +3310,10 @@ def test_wf_nostate_runtwice_usecache(plugin, tmpdir):
3254
3310
wf1 .inputs .y = 3
3255
3311
wf1 .plugin = plugin
3256
3312
3313
+ t0 = time .time ()
3257
3314
with Submitter (plugin = plugin ) as sub :
3258
3315
sub (wf1 )
3316
+ t1 = time .time () - t0
3259
3317
3260
3318
results1 = wf1 .result ()
3261
3319
assert 8 == results1 .output .out
@@ -3266,14 +3324,22 @@ def test_wf_nostate_runtwice_usecache(plugin, tmpdir):
3266
3324
cache_dir_content = os .listdir (wf1 .cache_dir )
3267
3325
3268
3326
# running workflow the second time
3327
+ t0 = time .time ()
3269
3328
with Submitter (plugin = plugin ) as sub :
3270
3329
sub (wf1 )
3330
+ t2 = time .time () - t0
3271
3331
3272
3332
results1 = wf1 .result ()
3273
3333
assert 8 == results1 .output .out
3274
- # checking if no new directory is not created
3334
+ # checking if no new directory is created
3275
3335
assert cache_dir_content == os .listdir (wf1 .cache_dir )
3276
3336
3337
+ # for win and dask/slurm the time for dir creation etc. might take much longer
3338
+ if sys .platform .startswith ("win" ) and plugin == "cf" :
3339
+ # checking the execution time
3340
+ assert t1 > 2
3341
+ assert t2 < 0.5
3342
+
3277
3343
3278
3344
def test_wf_state_runtwice_usecache (plugin , tmpdir ):
3279
3345
"""
@@ -3291,8 +3357,10 @@ def test_wf_state_runtwice_usecache(plugin, tmpdir):
3291
3357
wf1 .inputs .y = [3 , 30 ]
3292
3358
wf1 .plugin = plugin
3293
3359
3360
+ t0 = time .time ()
3294
3361
with Submitter (plugin = plugin ) as sub :
3295
3362
sub (wf1 )
3363
+ t1 = time .time () - t0
3296
3364
3297
3365
results1 = wf1 .result ()
3298
3366
assert 8 == results1 [0 ].output .out
@@ -3305,14 +3373,21 @@ def test_wf_state_runtwice_usecache(plugin, tmpdir):
3305
3373
cache_dir_content = os .listdir (wf1 .cache_dir )
3306
3374
3307
3375
# running workflow the second time
3376
+ t0 = time .time ()
3308
3377
with Submitter (plugin = plugin ) as sub :
3309
3378
sub (wf1 )
3379
+ t2 = time .time () - t0
3310
3380
3311
3381
results1 = wf1 .result ()
3312
3382
assert 8 == results1 [0 ].output .out
3313
3383
assert 602 == results1 [1 ].output .out
3314
- # checking if no new directory is not created
3384
+ # checking if no new directory is created
3315
3385
assert cache_dir_content == os .listdir (wf1 .cache_dir )
3386
+ # for win and dask/slurm the time for dir creation etc. might take much longer
3387
+ if sys .platform .startswith ("win" ) and plugin == "cf" :
3388
+ # checking the execution time
3389
+ assert t1 > 2
3390
+ assert t2 < 0.5
3316
3391
3317
3392
3318
3393
@pytest .fixture
0 commit comments