Skip to content

Commit

Permalink
Fix gap in validation of xtrigger sequential argument
Browse files Browse the repository at this point in the history
  • Loading branch information
MetRonnie committed Jun 17, 2024
1 parent f426bc4 commit 587a2b7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
15 changes: 10 additions & 5 deletions cylc/flow/xtrigger_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,16 @@ def _handle_sequential_kwarg(
)
fctx.func_kwargs.setdefault('sequential', sequential_param.default)

elif 'sequential' in fctx.func_kwargs:
# xtrig marked as sequential, so add 'sequential' arg to signature
sig = add_kwarg_to_sig(
sig, 'sequential', fctx.func_kwargs['sequential']
)
if 'sequential' in fctx.func_kwargs:
# xtrig marked as sequential in function call
value = fctx.func_kwargs['sequential']
if not isinstance(value, bool):
raise XtriggerConfigError(
label, fctx.func_name,
f"invalid argument 'sequential={value}' - must be boolean"
)
if not sequential_param:
sig = add_kwarg_to_sig(sig, 'sequential', value)
return sig

@staticmethod
Expand Down
27 changes: 23 additions & 4 deletions tests/integration/test_sequential_xtriggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,8 @@ async def test_sequential_arg_ok(
assert len(list_cycles(schd)) == expected_num_cycles


def test_sequential_arg_bad(
flow, validate
):
"""Test validation of 'sequential' arg for custom xtriggers"""
def test_sequential_arg_bad(flow, validate):
"""Test validation of 'sequential' arg for custom xtrigger function def"""
wid = flow({
'scheduling': {
'xtriggers': {
Expand Down Expand Up @@ -194,6 +192,27 @@ def xtrig2(x, sequential='True'):
) in str(excinfo.value)


def test_sequential_arg_bad2(flow, validate):
"""Test validation of 'sequential' arg for xtrigger calls"""
wid = flow({
'scheduling': {
'initial cycle point': '2000',
'xtriggers': {
'clock': 'wall_clock(sequential=3)',
},
'graph': {
'R1': '@clock => foo',
},
},
})

with pytest.raises(XtriggerConfigError) as excinfo:
validate(wid)
assert (
"invalid argument 'sequential=3' - must be boolean"
) in str(excinfo.value)


@pytest.mark.parametrize('is_sequential', [True, False])
async def test_any_sequential(flow, scheduler, start, is_sequential: bool):
"""Test that a task is marked as sequential if any of its xtriggers are."""
Expand Down

0 comments on commit 587a2b7

Please sign in to comment.