From 37aa99a5467d6319b40838b9dbbca9db6a463897 Mon Sep 17 00:00:00 2001 From: Oliver Sanders Date: Wed, 26 Feb 2025 13:24:41 +0000 Subject: [PATCH 1/2] runahead: handle no sequences within start-stop cycle interval * Closes #6154 * Fix a traceback which can occur in some niche circumstances where there are no sequences left within the `start cycle point` -> `stop cycle point` window after a restart. * This can happen as the result of a graph change. --- cylc/flow/task_pool.py | 7 +++++-- tests/integration/test_task_pool.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/cylc/flow/task_pool.py b/cylc/flow/task_pool.py index 4732f43d58..62886d6abe 100644 --- a/cylc/flow/task_pool.py +++ b/cylc/flow/task_pool.py @@ -408,8 +408,11 @@ def compute_runahead(self, force=False) -> bool: self._prev_runahead_base_point = base_point if count_cycles: - # (len(list) may be less than ilimit due to sequence end) - limit_point = sorted(sequence_points)[:ilimit + 1][-1] + if not sequence_points: + limit_point = base_point + else: + # (len(list) may be less than ilimit due to sequence end) + limit_point = sorted(sequence_points)[:ilimit + 1][-1] else: limit_point = max(sequence_points) diff --git a/tests/integration/test_task_pool.py b/tests/integration/test_task_pool.py index ffb255c0cf..a22c95ccc3 100644 --- a/tests/integration/test_task_pool.py +++ b/tests/integration/test_task_pool.py @@ -1800,6 +1800,35 @@ async def test_compute_runahead_with_no_tasks(flow, scheduler, run): assert schd.pool.get_tasks() == [] +async def test_compute_runahead_with_no_sequences(flow, scheduler, start, run, complete): + """It should handle no sequences within the start-stop cycle range. + + See https://github.com/cylc/cylc-flow/issues/6154 + """ + cfg = { + 'scheduling': { + 'cycling mode': 'integer', + 'initial cycle point': '1', + 'graph': { + 'P1': 'foo[-P1] => foo' + } + } + } + id_ = flow(cfg) + schd = scheduler(id_, paused_start=False) + async with run(schd): + await complete(schd, '2/foo') + + cfg['scheduling']['graph']['R1'] = cfg['scheduling']['graph']['P1'] + cfg['scheduling']['graph'].pop('P1') + flow(cfg, workflow_id=id_) + + schd = scheduler(id_, paused_start=False) + async with start(schd): + schd.pool.compute_runahead() + assert schd.pool.runahead_limit_point == IntegerPoint('3') + + @pytest.mark.parametrize('rhlimit', ['P2D', 'P2']) @pytest.mark.parametrize('compat_mode', ['compat-mode', 'normal-mode']) async def test_runahead_future_trigger( From e9f919a1963671d0f3ef8b0bdb28dd3fa97293ba Mon Sep 17 00:00:00 2001 From: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> Date: Wed, 12 Mar 2025 17:50:24 +0000 Subject: [PATCH 2/2] Changelog --- changes.d/6638.fix.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes.d/6638.fix.md diff --git a/changes.d/6638.fix.md b/changes.d/6638.fix.md new file mode 100644 index 0000000000..14a7e06de0 --- /dev/null +++ b/changes.d/6638.fix.md @@ -0,0 +1 @@ +Fixed possible crash when restarting a workflow after changing the graph.