Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix.no validation of outputs from graph singletons #6583

Draft
wants to merge 5 commits into
base: 8.4.x
Choose a base branch
from
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/6583.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix bug where graph items with undefined outputs were missed at validation if the graph item was not an upstream dependency of another graph item.
24 changes: 20 additions & 4 deletions cylc/flow/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1844,6 +1844,7 @@

triggers = {}
xtrig_labels = set()

for left in left_nodes:
if left.startswith('@'):
xtrig_labels.add(left[1:])
Expand All @@ -1859,10 +1860,6 @@
# Qualifier is a custom task message.
qualifier = outputs[output]
elif output:
if not TaskOutputs.is_valid_std_name(output):
raise WorkflowConfigError(
f"Undefined custom output: {name}:{output}"
)
qualifier = output
else:
# No qualifier specified => use "succeeded".
Expand Down Expand Up @@ -2278,6 +2275,25 @@
for tdef in self.taskdefs.values():
tdef.tweak_outputs()

def check_outputs(self, tasks_and_ouputs):
"""Check that task outputs have been registered with tasks.

TODO - have a bit more of a think about whether the try except is
safe
"""
for task, output in tasks_and_ouputs:
try:
registered_outputs = self.cfg['runtime'][task]['outputs']
except KeyError:
registered_outputs = []

Check warning on line 2288 in cylc/flow/config.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/config.py#L2285-L2288

Added lines #L2285 - L2288 were not covered by tests
if (
not TaskOutputs.is_valid_std_name(output)
and output not in registered_outputs
):
raise WorkflowConfigError(

Check warning on line 2293 in cylc/flow/config.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/config.py#L2293

Added line #L2293 was not covered by tests
f"Undefined custom output: {task}:{output}"
)

def _proc_triggers(self, parser, seq, task_triggers):
"""Define graph edges, taskdefs, and triggers, from graph sections."""
suicides = 0
Expand Down
9 changes: 6 additions & 3 deletions tests/integration/test_dbstatecheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ async def checker(
},
'runtime': {
'bad': {'simulation': {'fail cycle points': '1000'}},
'output': {'outputs': {'trigger': 'message'}}
'output': {'outputs': {
'trigger': 'message',
'custom_output': 'x'
}}
}
})
schd: Scheduler = mod_scheduler(wid, paused_start=False)
Expand Down Expand Up @@ -119,13 +122,13 @@ def test_output(checker):
'output',
'10000101T0000Z',
"{'submitted': 'submitted', 'started': 'started', 'succeeded': "
"'succeeded', 'trigger': 'message'}",
"'succeeded', 'trigger': 'message', 'custom_output': 'x'}",
],
[
'output',
'10010101T0000Z',
"{'submitted': 'submitted', 'started': 'started', 'succeeded': "
"'succeeded', 'trigger': 'message'}",
"'succeeded', 'trigger': 'message', 'custom_output': 'x'}",
],
]
assert result == expect
Expand Down
9 changes: 4 additions & 5 deletions tests/integration/test_optional_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,11 @@ def implicit_completion_config(mod_flow, mod_validate):
},
'runtime': {
'root': {
'outputs': {
'x': 'xxx',
'y': 'yyy',
'z': 'zzz',
}
'outputs': {n: f'{n}{n}{n}' for n in 'abcdefghijklxyz'}
}
}
})

return mod_validate(id_)


Expand All @@ -322,13 +319,15 @@ async def test_implicit_completion_expression(
implicit_completion_config,
task,
condition,
monkeypatch,
):
"""It should generate a completion expression from the graph.

If no completion expression is provided in the runtime section, then it
should auto generate one inferring whether outputs are required or not from
the graph.
"""
# monkeypatch.setattr('cylc.flow.config.WorkflowConfig.check_outputs', lambda *_: None)
completion_expression = get_completion_expression(
implicit_completion_config.taskdefs[task]
)
Expand Down
9 changes: 6 additions & 3 deletions tests/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1175,13 +1175,16 @@ def WorkflowConfig__assert_err_raised():
WorkflowConfig__assert_err_raised()


def test_undefined_custom_output(tmp_flow_config: Callable):
@pytest.mark.parametrize(
'graph', (('foo:x => bar'), ('foo:x'))
)
def test_undefined_custom_output(graph: str, tmp_flow_config: Callable):
"""Test error on undefined custom output referenced in graph."""
id_ = 'custom_out1'
flow_file = tmp_flow_config(id_, """
flow_file = tmp_flow_config(id_, f"""
[scheduling]
[[graph]]
R1 = "foo:x => bar"
R1 = "{graph}"
[runtime]
[[foo, bar]]
""")
Expand Down
Loading