Skip to content

Commit d1fe94d

Browse files
runahead: handle no sequences within start-stop cycle interval (#6638)
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. --------- Co-authored-by: Ronnie Dutta <[email protected]>
1 parent 07cca5f commit d1fe94d

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

changes.d/6638.fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed possible crash when restarting a workflow after changing the graph.

cylc/flow/task_pool.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,11 @@ def compute_runahead(self, force=False) -> bool:
409409
self._prev_runahead_base_point = base_point
410410

411411
if count_cycles:
412-
# (len(list) may be less than ilimit due to sequence end)
413-
limit_point = sorted(sequence_points)[:ilimit + 1][-1]
412+
if not sequence_points:
413+
limit_point = base_point
414+
else:
415+
# (len(list) may be less than ilimit due to sequence end)
416+
limit_point = sorted(sequence_points)[:ilimit + 1][-1]
414417
else:
415418
limit_point = max(sequence_points)
416419

tests/integration/test_task_pool.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,6 +1805,35 @@ async def test_compute_runahead_with_no_tasks(flow, scheduler, run):
18051805
assert schd.pool.get_tasks() == []
18061806

18071807

1808+
async def test_compute_runahead_with_no_sequences(flow, scheduler, start, run, complete):
1809+
"""It should handle no sequences within the start-stop cycle range.
1810+
1811+
See https://github.com/cylc/cylc-flow/issues/6154
1812+
"""
1813+
cfg = {
1814+
'scheduling': {
1815+
'cycling mode': 'integer',
1816+
'initial cycle point': '1',
1817+
'graph': {
1818+
'P1': 'foo[-P1] => foo'
1819+
}
1820+
}
1821+
}
1822+
id_ = flow(cfg)
1823+
schd = scheduler(id_, paused_start=False)
1824+
async with run(schd):
1825+
await complete(schd, '2/foo')
1826+
1827+
cfg['scheduling']['graph']['R1'] = cfg['scheduling']['graph']['P1']
1828+
cfg['scheduling']['graph'].pop('P1')
1829+
flow(cfg, workflow_id=id_)
1830+
1831+
schd = scheduler(id_, paused_start=False)
1832+
async with start(schd):
1833+
schd.pool.compute_runahead()
1834+
assert schd.pool.runahead_limit_point == IntegerPoint('3')
1835+
1836+
18081837
@pytest.mark.parametrize('rhlimit', ['P2D', 'P2'])
18091838
@pytest.mark.parametrize('compat_mode', ['compat-mode', 'normal-mode'])
18101839
async def test_runahead_future_trigger(

0 commit comments

Comments
 (0)