From 3ee6378f4a29007237cf76c6451b1df9cd97ae2a Mon Sep 17 00:00:00 2001
From: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com>
Date: Mon, 9 Jan 2023 10:34:03 +0000
Subject: [PATCH 1/4] Tidy
---
cylc/flow/cycling/__init__.py | 5 +++-
cylc/flow/task_job_mgr.py | 48 ++++++++++++++---------------------
cylc/flow/task_proxy.py | 2 +-
3 files changed, 24 insertions(+), 31 deletions(-)
diff --git a/cylc/flow/cycling/__init__.py b/cylc/flow/cycling/__init__.py
index 8fb08866607..1bb60f916dc 100644
--- a/cylc/flow/cycling/__init__.py
+++ b/cylc/flow/cycling/__init__.py
@@ -250,10 +250,13 @@ def sub(self, other):
def is_null(self):
return (self == self.get_null())
- def __str__(self):
+ def __str__(self) -> str:
# Stringify.
return self.value
+ def __repr__(self) -> str:
+ return f"<{type(self).__name__} {self}>"
+
def __add__(self, other):
# Add other (point or interval) to self.
if self.TYPE != other.TYPE:
diff --git a/cylc/flow/task_job_mgr.py b/cylc/flow/task_job_mgr.py
index f8e1db52fb6..50203388e0e 100644
--- a/cylc/flow/task_job_mgr.py
+++ b/cylc/flow/task_job_mgr.py
@@ -36,7 +36,7 @@
)
from shutil import rmtree
from time import time
-from typing import TYPE_CHECKING
+from typing import TYPE_CHECKING, Optional
from cylc.flow import LOG
from cylc.flow.job_runner_mgr import JobPollContext
@@ -947,38 +947,29 @@ def _run_job_cmd(
)
@staticmethod
- def _set_retry_timers(itask, rtconfig=None, retry=True):
+ def _set_retry_timers(
+ itask: 'TaskProxy',
+ rtconfig: Optional[dict] = None
+ ) -> None:
"""Set try number and retry delays."""
if rtconfig is None:
rtconfig = itask.tdef.rtconfig
- if (
- itask.tdef.run_mode + ' mode' in rtconfig and
- 'disable retries' in rtconfig[itask.tdef.run_mode + ' mode']
- ):
- retry = False
- if retry:
- if rtconfig['submission retry delays']:
- submit_delays = rtconfig['submission retry delays']
- else:
- submit_delays = itask.platform['submission retry delays']
+ submit_delays = (
+ rtconfig['submission retry delays']
+ or itask.platform['submission retry delays']
+ )
- for key, delays in [
- (
- TimerFlags.SUBMISSION_RETRY,
- submit_delays
- ),
- (
- TimerFlags.EXECUTION_RETRY,
- rtconfig['execution retry delays']
- )
- ]:
- if delays is None:
- delays = []
- try:
- itask.try_timers[key].set_delays(delays)
- except KeyError:
- itask.try_timers[key] = TaskActionTimer(delays=delays)
+ for key, delays in [
+ (TimerFlags.SUBMISSION_RETRY, submit_delays),
+ (TimerFlags.EXECUTION_RETRY, rtconfig['execution retry delays'])
+ ]:
+ if delays is None:
+ delays = []
+ try:
+ itask.try_timers[key].set_delays(delays)
+ except KeyError:
+ itask.try_timers[key] = TaskActionTimer(delays=delays)
def _simulation_submit_task_jobs(self, itasks, workflow):
"""Simulation mode task jobs submission."""
@@ -1168,7 +1159,6 @@ def _prep_submit_task_job(
itask.summary['platforms_used'][itask.submit_num] = ''
# Retry delays, needed for the try_num
self._create_job_log_path(workflow, itask)
- self._set_retry_timers(itask, rtconfig, False)
self._prep_submit_task_job_error(
workflow, itask, '(platform not defined)', exc)
return False
diff --git a/cylc/flow/task_proxy.py b/cylc/flow/task_proxy.py
index b5511ffb188..7f82898d5c2 100644
--- a/cylc/flow/task_proxy.py
+++ b/cylc/flow/task_proxy.py
@@ -409,7 +409,7 @@ def is_waiting_prereqs_done(self):
"""Are ALL prerequisites satisfied?"""
return (
all(pre.is_satisfied() for pre in self.state.prerequisites)
- and all(tri for tri in self.state.external_triggers.values())
+ and self.state.external_triggers_all_satisfied()
and self.state.xtriggers_all_satisfied()
)
From 1106c8b4054922a0fecfa194e6ffe8ff276efebd Mon Sep 17 00:00:00 2001
From: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com>
Date: Tue, 3 Jan 2023 16:54:12 +0000
Subject: [PATCH 2/4] Add test for clock trigger retry bug
---
.../special/08-clock-trigger-retry.t | 49 +++++++++++++++++++
1 file changed, 49 insertions(+)
create mode 100644 tests/functional/special/08-clock-trigger-retry.t
diff --git a/tests/functional/special/08-clock-trigger-retry.t b/tests/functional/special/08-clock-trigger-retry.t
new file mode 100644
index 00000000000..d4f591d4870
--- /dev/null
+++ b/tests/functional/special/08-clock-trigger-retry.t
@@ -0,0 +1,49 @@
+#!/usr/bin/env bash
+# THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE.
+# Copyright (C) NIWA & British Crown (Met Office) & Contributors.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+#-------------------------------------------------------------------------------
+# Old-style clock trigger should only go ahead if xtriggers are satisfied
+# https://github.com/cylc/cylc-flow/issues/5217
+
+. "$(dirname "$0")/test_header"
+set_test_number 4
+
+init_workflow "${TEST_NAME_BASE}" << __FLOW__
+[scheduling]
+ initial cycle point = 2015
+ final cycle point = PT1S
+ [[special tasks]]
+ clock-trigger = foo(PT1H)
+ [[graph]]
+ T00 = foo
+
+[runtime]
+ [[foo]]
+ execution retry delays = PT5S # hopefully enough time to check task doesn't resubmit immediately
+ script = ((CYLC_TASK_TRY_NUMBER > 1))
+__FLOW__
+
+run_ok "${TEST_NAME_BASE}-validate" cylc validate "$WORKFLOW_NAME"
+
+workflow_run_ok "${TEST_NAME_BASE}-run" cylc play --no-detach "$WORKFLOW_NAME"
+
+log_scan "${TEST_NAME_BASE}-log-scan" \
+ "${WORKFLOW_RUN_DIR}/log/scheduler/log" 2 1 \
+ "\[20150101.*/foo .* job:01 .* retrying in PT5S" \
+ "xtrigger satisfied: _cylc_retry_20150101"
+# (if task resubmits immediately instead of waiting PT5S, xtrigger msg will not appear)
+
+purge
From ab72c38046cb111468cd5076b2cac3cf7ae49890 Mon Sep 17 00:00:00 2001
From: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com>
Date: Tue, 3 Jan 2023 17:01:31 +0000
Subject: [PATCH 3/4] Fix clock trigger retry bug
---
cylc/flow/scheduler.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/cylc/flow/scheduler.py b/cylc/flow/scheduler.py
index 4c6902eb195..de56585f0e3 100644
--- a/cylc/flow/scheduler.py
+++ b/cylc/flow/scheduler.py
@@ -1591,11 +1591,11 @@ async def main_loop(self) -> None:
):
self.pool.queue_task(itask)
+ # Old-style clock-trigger tasks:
if (
itask.tdef.clocktrigger_offset is not None
- and itask.is_waiting_clock_done()
+ and all(itask.is_ready_to_run())
):
- # Old-style clock-trigger tasks.
self.pool.queue_task(itask)
if housekeep_xtriggers:
From 21e97a6105dc064ebc7a01f501c55facf73d9733 Mon Sep 17 00:00:00 2001
From: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com>
Date: Wed, 4 Jan 2023 16:33:44 +0000
Subject: [PATCH 4/4] Update changelog
---
CHANGES.md | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/CHANGES.md b/CHANGES.md
index b85c74e07d3..434f396a9bf 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -41,6 +41,11 @@ gets logged at "INFO" level in scheduler logs.
[#5259](https://github.com/cylc/cylc-flow/pull/5259) - Add flow_nums
to task_jobs table in the workflow database.
+### Fixes
+
+[#5286](https://github.com/cylc/cylc-flow/pull/5286) - Fix bug where
+`[scheduling][special tasks]clock-trigger` would skip execution retry delays.
+
-------------------------------------------------------------------------------
## __cylc-8.0.4 (Released 2022-12-14)__