Skip to content

Commit

Permalink
Fix output consistency check when there are offsets.
Browse files Browse the repository at this point in the history
  • Loading branch information
hjoliver committed Dec 16, 2024
1 parent 6a4ec1b commit 811699f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
30 changes: 15 additions & 15 deletions cylc/flow/graph_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ class GraphParser:
rf"""
(!)? # suicide mark
({_RE_NODE}) # node name
({_RE_OFFSET})? # cycle point offset
({_RE_QUAL})? # trigger qualifier
({_RE_OPT})? # optional output indicator
""",
Expand Down Expand Up @@ -540,16 +541,12 @@ def _proc_dep_pair(
raise GraphParseError(mismatch_msg.format(right))

# Raise error for cycle point offsets at the end of chains
if '[' in right:
if left and (right in terminals):
# This right hand side is at the end of a chain:
raise GraphParseError(
'Invalid cycle point offsets only on right hand '
'side of a dependency (must be on left hand side):'
f' {left} => {right}')
else:
# This RHS is also a LHS in a chain:
return
if '[' in right and left and (right in terminals):
# This right hand side is at the end of a chain:
raise GraphParseError(
'Invalid cycle point offsets only on right hand '
'side of a dependency (must be on left hand side):'
f' {left} => {right}')

# Split right side on AND.
rights = right.split(self.__class__.OP_AND)
Expand Down Expand Up @@ -887,15 +884,15 @@ def _compute_triggers(
raise ValueError( # pragma: no cover
f"Unexpected graph expression: '{right}'"
)
suicide_char, name, output, opt_char = m.groups()
suicide_char, name, offset, output, opt_char = m.groups()
suicide = (suicide_char == self.__class__.SUICIDE)
optional = (opt_char == self.__class__.OPTIONAL)
if output:
output = output.strip(self.__class__.QUALIFIER)

if name in self.family_map:
fam = True
mems = self.family_map[name]
rhs_mems = self.family_map[name]
if not output:
# (Plain family name on RHS).
# Make implicit success explicit.
Expand All @@ -922,10 +919,13 @@ def _compute_triggers(
else:
# Convert to standard output names if necessary.
output = TaskTrigger.standardise_name(output)
mems = [name]
rhs_mems = [name]
outputs = [output]

for mem in mems:
self._set_triggers(mem, suicide, trigs, expr, orig_expr)
for mem in rhs_mems:
if not offset:
# Nodes with offsets on the RHS do not define triggers.
self._set_triggers(mem, suicide, trigs, expr, orig_expr)
for output in outputs:
# But they must be consistent with output optionality.
self._set_output_opt(mem, output, optional, suicide, fam)
4 changes: 2 additions & 2 deletions tests/unit/test_graph_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -948,8 +948,8 @@ def test_RHS_AND(graph: str, expected_triggers: Dict[str, List[str]]):
param((('a', 'b[-P42M]'), {'b[-P42M]'}), 'Invalid cycle point offset'),
# No error if offset in NON-terminal RHS:
param((('a', 'b[-P42M]'), {}), None),
# Don't check the left hand side if this has a non-terminal RHS:
param((('a &', 'b[-P42M]'), {}), None),
# Check the left hand side if this has a non-terminal RHS:
param((('a &', 'b[-P42M]'), {}), 'Null task name in graph'),
)
)
def test_proc_dep_pair(args, err):
Expand Down

0 comments on commit 811699f

Please sign in to comment.