Skip to content

Commit

Permalink
Prevent ill formed set --pre causing scheduler failures.
Browse files Browse the repository at this point in the history
  • Loading branch information
wxtim committed Mar 6, 2024
1 parent 7fd5d72 commit d24c3cc
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 5 deletions.
18 changes: 13 additions & 5 deletions cylc/flow/task_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1715,17 +1715,25 @@ def _standardise_prereqs(self, prereqs: 'List[str]') -> 'List[Tokens]':
msg = self.config.get_taskdef(
pre['task']
).outputs[output][0]
cycle=standardise_point_string(pre['cycle'])
except KeyError:
# The task does not have this output.
LOG.warning(
f"output {pre.relative_id_with_selectors} not found")
continue
_prereqs.append(
pre.duplicate(
task_sel=msg,
cycle=standardise_point_string(pre['cycle'])
except WorkflowConfigError as exc:
# The workflow does not have the task from --pre:
LOG.warning(f'Invalid pre task name set:\n {exc.args[0]}')
except PointParsingError as exc:
# The CP from --pre is invalid:
LOG.warning(f'Invalid pre cycle point set:\n {exc.args[0]}')
else:
_prereqs.append(
pre.duplicate(
task_sel=msg,
cycle=cycle,
)
)
)
return _prereqs

def _standardise_outputs(
Expand Down
34 changes: 34 additions & 0 deletions tests/integration/test_task_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1383,6 +1383,40 @@ async def test_set_prereqs(
assert qux.state.prerequisites_all_satisfied()


async def test_set_bad_prereqs(
flow,
scheduler,
start,
log_filter,
):
"""Check manual setting of prerequisites.
"""
id_ = flow({
'scheduler': {
'allow implicit tasks': 'True',
'cycle point format': '%Y'},
'scheduling': {
'initial cycle point': '2040',
'graph': {'R1': "foo => bar"}},
})
schd = scheduler(id_)

def set_prereqs(prereqs):
"""Shorthand so only varible under test given as arg"""
schd.pool.set_prereqs_and_outputs(
["2040/bar"], None, prereqs, ['all'])

async with start(schd) as log:
# Invalid - task name wildcard:
set_prereqs(["2040/*"])
assert 'Illegal task name' in log.messages[-1]

# Invalid cycle point wildcard.
set_prereqs(["*/foo"])
assert 'Invalid ISO 8601' in log.messages[-1]


async def test_set_outputs_live(
flow,
scheduler,
Expand Down

0 comments on commit d24c3cc

Please sign in to comment.