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

Spawn parentless sequential xtriggered task on set outputs #6448

Merged
Merged
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/6448.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix the non-spawning of parentless sequential xtriggered tasks when outputs are set.
58 changes: 23 additions & 35 deletions cylc/flow/task_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1948,6 +1948,9 @@ def set_prereqs_and_outputs(
if prereqs:
self._set_prereqs_itask(itask, prereqs, flow_nums)
else:
# Spawn as if seq xtrig of parentless task was satisfied,
# with associated task producing these outputs.
self.check_spawn_psx_task(itask)
self._set_outputs_itask(itask, outputs)

# Spawn and set inactive tasks.
Expand Down Expand Up @@ -2071,21 +2074,7 @@ def remove_tasks(self, items):
itasks, _, bad_items = self.filter_task_proxies(items)
for itask in itasks:
# Spawn next occurrence of xtrigger sequential task.
if (
itask.is_xtrigger_sequential
and (
itask.identity not in
self.xtrigger_mgr.sequential_has_spawned_next
)
):
self.xtrigger_mgr.sequential_has_spawned_next.add(
itask.identity
)
self.spawn_to_rh_limit(
itask.tdef,
itask.tdef.next_point(itask.point),
itask.flow_nums
)
self.check_spawn_psx_task(itask)
self.remove(itask, 'request')
if self.compute_runahead():
self.release_runahead_tasks()
Expand Down Expand Up @@ -2134,26 +2123,12 @@ def _force_trigger(self, itask):
itask.tdef.next_point(itask.point),
itask.flow_nums
)
# Task may be set running before xtrigger is satisfied,
# if so check/spawn if xtrigger sequential.
elif (
itask.is_xtrigger_sequential
and (
itask.identity not in
self.xtrigger_mgr.sequential_has_spawned_next
)
):
self.xtrigger_mgr.sequential_has_spawned_next.add(
itask.identity
)
self.spawn_to_rh_limit(
itask.tdef,
itask.tdef.next_point(itask.point),
itask.flow_nums
)
else:
# De-queue it to run now.
self.task_queue_mgr.force_release_task(itask)
# Task may be set running before xtrigger is satisfied,
# if so check/spawn if xtrigger sequential.
self.check_spawn_psx_task(itask)

def force_trigger_tasks(
self, items: Iterable[str],
Expand Down Expand Up @@ -2237,10 +2212,23 @@ def spawn_parentless_sequential_xtriggers(self):
"""Spawn successor(s) of parentless wall clock satisfied tasks."""
while self.xtrigger_mgr.sequential_spawn_next:
taskid = self.xtrigger_mgr.sequential_spawn_next.pop()
self.xtrigger_mgr.sequential_has_spawned_next.add(taskid)
itask = self._get_task_by_id(taskid)
# Will spawn out to RH limit or next parentless clock trigger
# or non-parentless.
self.check_spawn_psx_task(itask)

def check_spawn_psx_task(self, itask: 'TaskProxy') -> None:
"""Check and spawn parentless sequential xtriggered task (psx)."""
# Will spawn out to RH limit or next parentless clock trigger
# or non-parentless.
if (
itask.is_xtrigger_sequential
and (
itask.identity not in
self.xtrigger_mgr.sequential_has_spawned_next
)
):
self.xtrigger_mgr.sequential_has_spawned_next.add(
itask.identity
)
self.spawn_to_rh_limit(
itask.tdef,
itask.tdef.next_point(itask.point),
Expand Down
20 changes: 20 additions & 0 deletions tests/integration/test_sequential_xtriggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,26 @@ async def test_trigger(sequential, start):
assert list_cycles(sequential) == ['2000', '2001']


async def test_set(sequential, start):
"""It should spawn its next instance if outputs are set ahead of time.

If you set outputs of a sequentially spawned task before its xtriggers
have become satisfied, then the sequential spawning chain is broken.

The task pool should defend against this to ensure that setting outputs
doesn't cancel it's future instances and their downstream tasks.
"""
async with start(sequential):
assert list_cycles(sequential) == ['2000']

foo = sequential.pool.get_task(ISO8601Point('2000'), 'foo')
# set foo:succeeded it should spawn next instance
sequential.pool.set_prereqs_and_outputs(
["2000/foo"], ["succeeded"], None, ['all'])

assert list_cycles(sequential) == ['2001']


async def test_reload(sequential, start):
"""It should set the is_xtrigger_sequential flag on reload.

Expand Down
Loading