Skip to content

Commit

Permalink
Fix C7 back-compat task removal.
Browse files Browse the repository at this point in the history
  • Loading branch information
hjoliver committed Dec 15, 2023
1 parent ad6e5d7 commit 06fbdea
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions cylc/flow/task_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,8 @@ def spawn_on_output(self, itask, output, forced=False):
def remove_if_complete(self, itask: TaskProxy) -> bool:
"""Remove a finished task if required outputs are complete.
Return True if removed else False.
Cylc 8:
- if complete:
- remove task and recompute runahead
Expand All @@ -1363,39 +1365,41 @@ def remove_if_complete(self, itask: TaskProxy) -> bool:
(C7 failed tasks don't count toward runahead limit)
"""
ret = False

if not itask.state(*TASK_STATUSES_FINAL):
return ret
return False

if itask.identity == self.stop_task_id:
self.stop_task_finished = True

Check warning on line 1372 in cylc/flow/task_pool.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/task_pool.py#L1372

Added line #L1372 was not covered by tests

if cylc.flow.flags.cylc7_back_compat:
ret = False

Check warning on line 1375 in cylc/flow/task_pool.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/task_pool.py#L1375

Added line #L1375 was not covered by tests
if not itask.state(TASK_STATUS_FAILED, TASK_OUTPUT_SUBMIT_FAILED):
self.remove(itask)
ret = True

Check warning on line 1378 in cylc/flow/task_pool.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/task_pool.py#L1377-L1378

Added lines #L1377 - L1378 were not covered by tests
# Recompute runhead either way; failed tasks don't count in C7.
if self.compute_runahead():
self.release_runahead_tasks()
return ret

Check warning on line 1382 in cylc/flow/task_pool.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/task_pool.py#L1382

Added line #L1382 was not covered by tests

if itask.state(TASK_STATUS_EXPIRED):
reason = "expired"
else:
incomplete = itask.state.outputs.get_incomplete()
if incomplete:
# Retain as an incomplete task.
LOG.warning(
f"[{itask}] did not complete required outputs:"
f" {incomplete}"
)
return ret
reason = None
self.remove(itask, "expired")
if self.compute_runahead():
self.release_runahead_tasks()

Check warning on line 1387 in cylc/flow/task_pool.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/task_pool.py#L1387

Added line #L1387 was not covered by tests
return True

if itask.identity == self.stop_task_id:
self.stop_task_finished = True
incomplete = itask.state.outputs.get_incomplete()
if incomplete:
# Retain as an incomplete task.
LOG.warning(
f"[{itask}] did not complete required outputs:"
f" {incomplete}"
)
return False

self.remove(itask, reason)
ret = True
self.remove(itask)
if self.compute_runahead():
self.release_runahead_tasks()

return ret
return True

def spawn_on_all_outputs(
self, itask: TaskProxy, completed_only: bool = False
Expand Down

0 comments on commit 06fbdea

Please sign in to comment.