Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes.d/6772.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Xtriggers with an OR operator (`|`) between them now correctly fails validation as Cylc does not support this.
12 changes: 11 additions & 1 deletion cylc/flow/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1841,6 +1841,7 @@ def generate_edges(self, lexpr, orig_lexpr, left_nodes, right, seq,
# Right is a lone node.
self.edges[seq].add((right, None, suicide, conditional))

conditional_xtriggers = []
for left in left_nodes:
# if left is None:
# continue
Expand All @@ -1856,7 +1857,16 @@ def generate_edges(self, lexpr, orig_lexpr, left_nodes, right, seq,
LOG.error(f"{orig_lexpr} => {right}")
raise WorkflowConfigError(
f"self-edge detected: {left} => {right}")
self.edges[seq].add((left, right, suicide, conditional))
if left.startswith('@') and conditional:
conditional_xtriggers.append(f'{lexpr} => {right}')
else:
self.edges[seq].add((left, right, suicide, conditional))
if conditional_xtriggers:
raise WorkflowConfigError(
'Xtriggers cannot be used in conditional graph'
' expressions:\n' +
'\n * '.join(conditional_xtriggers)
)

def generate_taskdef(self, orig_expr, node):
"""Generate task definition for node."""
Expand Down
39 changes: 39 additions & 0 deletions tests/integration/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from cylc.flow.pathutil import get_workflow_run_pub_db_path

Fixture = Any
param = pytest.param


@pytest.mark.parametrize(
Expand Down Expand Up @@ -488,6 +489,44 @@ def test_xtrig_signature_validation(
validate(id_)


@pytest.mark.parametrize(
'left',
(
param('@xrandom | @echo', id='xtrig-or-xtrig'),
param('@xrandom | task', id='xtrig-or-task'),
param('task | @echo', id='task-or-xtrig'),
param('@xrandom | foo & bar', id='xtrig-or-complex'),
param('@xrandom & bar | foo', id='complex-or-xtrig'),
)
)
def test_xtrig_or_fails_validation(
flow: "Fixture",
validate: "Fixture",
left: str
):
"""Xtriggers cannot be chained with the 'or'

https://github.com/cylc/cylc-flow/issues/6771
https://github.com/cylc/cylc-flow/issues/2712
"""
id_ = flow(
{
"scheduling": {
"initial cycle point": "2024",
"xtriggers": {
"xrandom": "xrandom(100)",
"echo": "echo(succeed=True)"
},
"graph": {"R1": f"{left} => fin"},
}
}
)
expected_msg = (
"Xtriggers cannot be used in conditional graph expressions:\n")
with pytest.raises(WorkflowConfigError, match=expected_msg):
validate(id_)


def test_special_task_non_word_names(flow: Fixture, validate: Fixture):
"""Test validation of special tasks names with non-word characters"""
wid = flow({
Expand Down
Loading