Skip to content

Commit 587a2b7

Browse files
committed
Fix gap in validation of xtrigger sequential argument
1 parent f426bc4 commit 587a2b7

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

cylc/flow/xtrigger_mgr.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,16 @@ def _handle_sequential_kwarg(
325325
)
326326
fctx.func_kwargs.setdefault('sequential', sequential_param.default)
327327

328-
elif 'sequential' in fctx.func_kwargs:
329-
# xtrig marked as sequential, so add 'sequential' arg to signature
330-
sig = add_kwarg_to_sig(
331-
sig, 'sequential', fctx.func_kwargs['sequential']
332-
)
328+
if 'sequential' in fctx.func_kwargs:
329+
# xtrig marked as sequential in function call
330+
value = fctx.func_kwargs['sequential']
331+
if not isinstance(value, bool):
332+
raise XtriggerConfigError(
333+
label, fctx.func_name,
334+
f"invalid argument 'sequential={value}' - must be boolean"
335+
)
336+
if not sequential_param:
337+
sig = add_kwarg_to_sig(sig, 'sequential', value)
333338
return sig
334339

335340
@staticmethod

tests/integration/test_sequential_xtriggers.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,8 @@ async def test_sequential_arg_ok(
159159
assert len(list_cycles(schd)) == expected_num_cycles
160160

161161

162-
def test_sequential_arg_bad(
163-
flow, validate
164-
):
165-
"""Test validation of 'sequential' arg for custom xtriggers"""
162+
def test_sequential_arg_bad(flow, validate):
163+
"""Test validation of 'sequential' arg for custom xtrigger function def"""
166164
wid = flow({
167165
'scheduling': {
168166
'xtriggers': {
@@ -194,6 +192,27 @@ def xtrig2(x, sequential='True'):
194192
) in str(excinfo.value)
195193

196194

195+
def test_sequential_arg_bad2(flow, validate):
196+
"""Test validation of 'sequential' arg for xtrigger calls"""
197+
wid = flow({
198+
'scheduling': {
199+
'initial cycle point': '2000',
200+
'xtriggers': {
201+
'clock': 'wall_clock(sequential=3)',
202+
},
203+
'graph': {
204+
'R1': '@clock => foo',
205+
},
206+
},
207+
})
208+
209+
with pytest.raises(XtriggerConfigError) as excinfo:
210+
validate(wid)
211+
assert (
212+
"invalid argument 'sequential=3' - must be boolean"
213+
) in str(excinfo.value)
214+
215+
197216
@pytest.mark.parametrize('is_sequential', [True, False])
198217
async def test_any_sequential(flow, scheduler, start, is_sequential: bool):
199218
"""Test that a task is marked as sequential if any of its xtriggers are."""

0 commit comments

Comments
 (0)