Skip to content

Commit 5e467f0

Browse files
authored
Merge pull request #6963 from cylc/8.5.x-sync
🤖 Merge 8.5.x-sync into master
2 parents 9b51b5c + 02e3349 commit 5e467f0

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

changes.d/6768.fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a bug causing remote tasks to stay in the preparing state if triggered when the workflow is paused.

cylc/flow/scheduler.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,13 @@ def release_tasks_to_run(self) -> bool:
13501350
pre_prep_tasks.update(self.pool.tasks_to_trigger_now)
13511351
self.pool.tasks_to_trigger_now = set()
13521352

1353-
if not self.is_paused:
1353+
if self.is_paused:
1354+
# finish processing preparing tasks
1355+
pre_prep_tasks.update({
1356+
itask for itask in self.pool.get_tasks()
1357+
if itask.state(TASK_STATUS_PREPARING)
1358+
})
1359+
else:
13541360
# release queued tasks
13551361
pre_prep_tasks.update(self.pool.release_queued_tasks())
13561362
if self.pool.tasks_to_trigger_on_resume:

tests/integration/test_force_trigger.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
from cylc.flow.cycling.integer import IntegerPoint
4040
from cylc.flow.scheduler import Scheduler
4141
from cylc.flow.task_state import (
42+
TASK_STATUS_PREPARING,
4243
TASK_STATUS_FAILED,
4344
TASK_STATUS_RUNNING,
4445
TASK_STATUS_SUBMITTED,
@@ -758,6 +759,33 @@ async def test_trigger_with_sequential_task(flow, scheduler, run, log_filter):
758759
await asyncio.sleep(0)
759760

760761

762+
async def test_trigger_whilst_paused_preparing(flow, scheduler, run, complete):
763+
"""It should run "preparing" tasks even if the workflow is paused.
764+
765+
Remote init leaves tasks as preparing for a while. These must still be
766+
pushed through to running, even if triggered while the workflow is paused.
767+
768+
See https://github.com/cylc/cylc-flow/pull/6768
769+
770+
"""
771+
id_ = flow(
772+
{
773+
'scheduling': {
774+
'graph': {'R1': 'a'},
775+
},
776+
}
777+
)
778+
schd = scheduler(id_)
779+
async with run(schd):
780+
781+
# Instead of triggering, artificially set it as preparing.
782+
a = schd.pool.get_tasks()[0]
783+
a.state_reset(TASK_STATUS_PREPARING)
784+
785+
# 1/a should run even though the workflow is paused.
786+
await complete(schd, '1/a', allow_paused=True, timeout=1)
787+
788+
761789
async def test_trigger_with_task_selector(flow, scheduler, start, monkeypatch):
762790
"""Test task matching with the trigger command.
763791

0 commit comments

Comments
 (0)