@@ -1989,11 +1989,11 @@ def test_wf_nostate_cachelocations_forcererun(plugin, tmpdir):
1989
1989
1990
1990
1991
1991
@pytest .mark .parametrize ("plugin" , Plugins )
1992
- def test_wf_nostate_cachelocations_wftaskrerun (plugin , tmpdir ):
1992
+ def test_wf_nostate_cachelocations_wftaskrerun_propagateTrue (plugin , tmpdir ):
1993
1993
"""
1994
- Two identical wfs with provided cache_dir;
1995
- the second wf has cache_locations and rerun=True,
1996
- so everything should be rerun even if Submitter doesn't have rerun
1994
+ Two identical wfs with provided cache_dir and cache_locations for the second one ;
1995
+ submitter doesn't have rerun, but the second wf has rerun=True,
1996
+ propagate_rerun is True as default, so everything should be rerun
1997
1997
"""
1998
1998
cache_dir1 = tmpdir .mkdir ("test_wf_cache3" )
1999
1999
cache_dir2 = tmpdir .mkdir ("test_wf_cache4" )
@@ -2019,7 +2019,7 @@ def test_wf_nostate_cachelocations_wftaskrerun(plugin, tmpdir):
2019
2019
input_spec = ["x" , "y" ],
2020
2020
cache_dir = cache_dir2 ,
2021
2021
cache_locations = cache_dir1 ,
2022
- rerun = True , # wh has to be rerun
2022
+ rerun = True , # wh has to be rerun (default for propagate_rerun is True)
2023
2023
)
2024
2024
wf2 .add (multiply (name = "mult" , x = wf2 .lzin .x , y = wf2 .lzin .y ))
2025
2025
wf2 .add (add2_wait (name = "add2" , x = wf2 .mult .lzout .out ))
@@ -2048,11 +2048,12 @@ def test_wf_nostate_cachelocations_wftaskrerun(plugin, tmpdir):
2048
2048
2049
2049
2050
2050
@pytest .mark .parametrize ("plugin" , Plugins )
2051
- def test_wf_nostate_cachelocations_taskrerun_noeffect (plugin , tmpdir ):
2051
+ def test_wf_nostate_cachelocations_wftaskrerun_propagateFalse (plugin , tmpdir ):
2052
2052
"""
2053
- Two identical wfs with provided cache_dir;
2054
- submitter doesn't have rerun and wf doesn't have rerun,
2055
- so even if the task has rerun=True, nothing will be rerun (wf will read the result)
2053
+ Two identical wfs with provided cache_dir and cache_locations for the second one;
2054
+ submitter doesn't have rerun, but the second wf has rerun=True,
2055
+ propagate_rerun is set to False, so wf will be triggered,
2056
+ but tasks will not have rerun, so will use the previous results
2056
2057
"""
2057
2058
cache_dir1 = tmpdir .mkdir ("test_wf_cache3" )
2058
2059
cache_dir2 = tmpdir .mkdir ("test_wf_cache4" )
@@ -2078,10 +2079,11 @@ def test_wf_nostate_cachelocations_taskrerun_noeffect(plugin, tmpdir):
2078
2079
input_spec = ["x" , "y" ],
2079
2080
cache_dir = cache_dir2 ,
2080
2081
cache_locations = cache_dir1 ,
2082
+ rerun = True , # wh has to be rerun
2083
+ propagate_rerun = False , # but rerun doesn't propagate to the tasks
2081
2084
)
2082
2085
wf2 .add (multiply (name = "mult" , x = wf2 .lzin .x , y = wf2 .lzin .y ))
2083
- # rerun on the task level will not have any effect if the wf doesn't start rerun
2084
- wf2 .add (add2_wait (name = "add2" , x = wf2 .mult .lzout .out , rerun = True ))
2086
+ wf2 .add (add2_wait (name = "add2" , x = wf2 .mult .lzout .out ))
2085
2087
wf2 .set_output ([("out" , wf2 .add2 .lzout .out )])
2086
2088
wf2 .inputs .x = 2
2087
2089
wf2 .inputs .y = 3
@@ -2095,24 +2097,23 @@ def test_wf_nostate_cachelocations_taskrerun_noeffect(plugin, tmpdir):
2095
2097
results2 = wf2 .result ()
2096
2098
assert 8 == results2 .output .out
2097
2099
2098
- # checking if the second wf doesn't runs again
2100
+ # checking if the second wf runs again
2099
2101
assert wf1 .output_dir .exists ()
2100
- assert not wf2 .output_dir .exists ()
2101
- # should be fast
2102
+ assert wf2 .output_dir .exists ()
2103
+
2104
+ # tasks should not be recomputed
2105
+ assert len (list (Path (cache_dir1 ).glob ("F*" ))) == 2
2106
+ assert len (list (Path (cache_dir2 ).glob ("F*" ))) == 0
2102
2107
assert t1 > 3
2103
2108
assert t2 < 1
2104
2109
2105
2110
2106
2111
@pytest .mark .parametrize ("plugin" , Plugins )
2107
- def test_wf_nostate_cachelocations_taskrerun_wfmodif (plugin , tmpdir ):
2112
+ def test_wf_nostate_cachelocations_taskrerun_wfrerun_propagateFalse (plugin , tmpdir ):
2108
2113
"""
2109
- Two identical wfs with provided cache_dir;
2110
- the second wf has cache_locations,
2111
- the second task has rerun=True, but because wf and submitter doesn't have rerun
2112
- it wouldn't rerun anyway (see previous test),
2113
- so wf inputs has to be modified to force wf to start rerunning,
2114
- the first task will read the result (doesn't have rerun),
2115
- but the second will be rerun
2114
+ Two identical wfs with provided cache_dir, and cache_locations for teh second wf;
2115
+ submitter doesn't have rerun, but wf has rerun=True,
2116
+ since propagate_rerun=False, only tasks that have rerun=True will be rerun
2116
2117
"""
2117
2118
cache_dir1 = tmpdir .mkdir ("test_wf_cache3" )
2118
2119
cache_dir2 = tmpdir .mkdir ("test_wf_cache4" )
@@ -2135,18 +2136,18 @@ def test_wf_nostate_cachelocations_taskrerun_wfmodif(plugin, tmpdir):
2135
2136
2136
2137
wf2 = Workflow (
2137
2138
name = "wf" ,
2138
- input_spec = ["x" , "y" , "fake" ],
2139
+ input_spec = ["x" , "y" ],
2139
2140
cache_dir = cache_dir2 ,
2140
2141
cache_locations = cache_dir1 ,
2142
+ rerun = True ,
2143
+ propagate_rerun = False , # rerun will not be propagated to each task
2141
2144
)
2142
2145
wf2 .add (multiply (name = "mult" , x = wf2 .lzin .x , y = wf2 .lzin .y ))
2143
- # when wf starts rerun, this task will be rerun
2146
+ # rerun on the task level needed (wf.propagate_rerun is False)
2144
2147
wf2 .add (add2_wait (name = "add2" , x = wf2 .mult .lzout .out , rerun = True ))
2145
2148
wf2 .set_output ([("out" , wf2 .add2 .lzout .out )])
2146
2149
wf2 .inputs .x = 2
2147
2150
wf2 .inputs .y = 3
2148
- # adding a fake input, just to start wf rerun
2149
- wf2 .inputs .fake = "whatever"
2150
2151
wf2 .plugin = plugin
2151
2152
2152
2153
t0 = time .time ()
@@ -2157,11 +2158,10 @@ def test_wf_nostate_cachelocations_taskrerun_wfmodif(plugin, tmpdir):
2157
2158
results2 = wf2 .result ()
2158
2159
assert 8 == results2 .output .out
2159
2160
2160
- # checking if the second wf runs again
2161
+ # checking if the second wf doesn't runs again
2161
2162
assert wf1 .output_dir .exists ()
2162
2163
assert wf2 .output_dir .exists ()
2163
-
2164
- # the first task shouldn't be recomputed, but the second one should be
2164
+ # the second task should be recomputed
2165
2165
assert len (list (Path (cache_dir1 ).glob ("F*" ))) == 2
2166
2166
assert len (list (Path (cache_dir2 ).glob ("F*" ))) == 1
2167
2167
assert t1 > 3
0 commit comments