18
18
import asyncio
19
19
from pathlib import Path
20
20
from textwrap import dedent
21
+ from typing import Set
21
22
22
23
from cylc .flow .pathutil import get_workflow_run_dir
24
+ from cylc .flow .scheduler import Scheduler
25
+
26
+
27
+ def get_task_ids (schd : Scheduler ) -> Set [str ]:
28
+ return {task .identity for task in schd .pool .get_tasks ()}
23
29
24
30
25
31
async def test_2_xtriggers (flow , start , scheduler , monkeypatch ):
@@ -38,9 +44,6 @@ async def test_2_xtriggers(flow, start, scheduler, monkeypatch):
38
44
lambda : ten_years_ahead - 1
39
45
)
40
46
id_ = flow ({
41
- 'scheduler' : {
42
- 'allow implicit tasks' : True
43
- },
44
47
'scheduling' : {
45
48
'initial cycle point' : '2020-05-05' ,
46
49
'xtriggers' : {
@@ -72,31 +75,19 @@ async def test_2_xtriggers(flow, start, scheduler, monkeypatch):
72
75
}
73
76
74
77
75
- async def test_1_xtrigger_2_tasks (flow , start , scheduler , monkeypatch , mocker ):
78
+ async def test_1_xtrigger_2_tasks (flow , start , scheduler , mocker ):
76
79
"""
77
80
If multiple tasks depend on the same satisfied xtrigger, the DB mgr method
78
- put_xtriggers should only be called once - when the xtrigger gets satisfied.
81
+ put_xtriggers should only be called once - when the xtrigger gets satisfied
79
82
80
83
See [GitHub #5908](https://github.com/cylc/cylc-flow/pull/5908)
81
84
82
85
"""
83
- task_point = 1588636800 # 2020-05-05
84
- ten_years_ahead = 1904169600 # 2030-05-05
85
- monkeypatch .setattr (
86
- 'cylc.flow.xtriggers.wall_clock.time' ,
87
- lambda : ten_years_ahead - 1
88
- )
89
86
id_ = flow ({
90
- 'scheduler' : {
91
- 'allow implicit tasks' : True
92
- },
93
87
'scheduling' : {
94
- 'initial cycle point' : '2020-05-05' ,
95
- 'xtriggers' : {
96
- 'clock_1' : 'wall_clock()' ,
97
- },
88
+ 'initial cycle point' : '2020' ,
98
89
'graph' : {
99
- 'R1' : '@clock_1 => foo & bar'
90
+ 'R1' : '@wall_clock => foo & bar'
100
91
}
101
92
}
102
93
})
@@ -112,7 +103,7 @@ async def test_1_xtrigger_2_tasks(flow, start, scheduler, monkeypatch, mocker):
112
103
schd .xtrigger_mgr .call_xtriggers_async (task )
113
104
114
105
# It should now be satisfied.
115
- assert task .state .xtriggers == {'clock_1 ' : True }
106
+ assert task .state .xtriggers == {'wall_clock ' : True }
116
107
117
108
# Check one put_xtriggers call only, not two.
118
109
assert spy .call_count == 1
@@ -128,9 +119,6 @@ async def test_xtriggers_restart(flow, start, scheduler, db_select):
128
119
"""It should write xtrigger results to the DB and load them on restart."""
129
120
# define a workflow which uses a custom xtrigger
130
121
id_ = flow ({
131
- 'scheduler' : {
132
- 'allow implicit tasks' : 'True'
133
- },
134
122
'scheduling' : {
135
123
'xtriggers' : {
136
124
'mytrig' : 'mytrig()'
@@ -194,9 +182,6 @@ async def test_error_in_xtrigger(flow, start, scheduler):
194
182
"""Failure in an xtrigger is handled nicely.
195
183
"""
196
184
id_ = flow ({
197
- 'scheduler' : {
198
- 'allow implicit tasks' : 'True'
199
- },
200
185
'scheduling' : {
201
186
'xtriggers' : {
202
187
'mytrig' : 'mytrig()'
@@ -231,3 +216,36 @@ def mytrig(*args, **kwargs):
231
216
error = log .messages [- 1 ].split ('\n ' )
232
217
assert error [- 2 ] == 'Exception: This Xtrigger is broken'
233
218
assert error [0 ] == 'ERROR in xtrigger mytrig()'
219
+
220
+
221
+ async def test_1_seq_clock_trigger_2_tasks (flow , start , scheduler ):
222
+ """Test that all tasks dependent on a sequential clock trigger continue to
223
+ spawn after the first cycle.
224
+
225
+ See https://github.com/cylc/cylc-flow/issues/6204
226
+ """
227
+ id_ = flow ({
228
+ 'scheduler' : {
229
+ 'cycle point format' : 'CCYY' ,
230
+ },
231
+ 'scheduling' : {
232
+ 'initial cycle point' : '1990' ,
233
+ 'graph' : {
234
+ 'P1Y' : '@wall_clock => foo & bar' ,
235
+ },
236
+ },
237
+ })
238
+ schd : Scheduler = scheduler (id_ )
239
+
240
+ async with start (schd ):
241
+ start_task_pool = get_task_ids (schd )
242
+ assert start_task_pool == {'1990/foo' , '1990/bar' }
243
+
244
+ for _ in range (3 ):
245
+ await schd ._main_loop ()
246
+
247
+ assert get_task_ids (schd ) == start_task_pool .union (
248
+ f'{ year } /{ name } '
249
+ for year in range (1991 , 1994 )
250
+ for name in ('foo' , 'bar' )
251
+ )
0 commit comments