From 860f7eb1fc654fc7ba5a03204fd6ac70f01fece4 Mon Sep 17 00:00:00 2001 From: Tim Pillinger <26465611+wxtim@users.noreply.github.com> Date: Wed, 25 Oct 2023 15:26:12 +0100 Subject: [PATCH] Stop task proxy clock trigger time being cached to prevent all clock triggers being the same. --- cylc/flow/task_proxy.py | 29 ++++++++++++++++------------- cylc/flow/xtrigger_mgr.py | 1 + 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/cylc/flow/task_proxy.py b/cylc/flow/task_proxy.py index 271049126fd..0e0317aac9a 100644 --- a/cylc/flow/task_proxy.py +++ b/cylc/flow/task_proxy.py @@ -355,25 +355,28 @@ def get_point_as_seconds(self): self.point_as_seconds += utc_offset_in_seconds return self.point_as_seconds - def get_clock_trigger_time(self, offset_str): - """Compute, cache, and return trigger time relative to cycle point. + @staticmethod + def get_clock_trigger_time( + point: 'PointBase', offset_str: Optional[str] = None + ) -> int: + """Compute and return trigger time relative to cycle point. Args: - offset_str: ISO8601Interval string, e.g. "PT2M". - Can be None for zero offset. + point: String representing itask string. + offset_str: + ISO8601Interval string, e.g. "PT2M". + Can be None for zero offset. Returns: Absolute trigger time in seconds since Unix epoch. """ - if self.clock_trigger_time is None: - if offset_str is None: - trigger_time = self.point - else: - trigger_time = self.point + ISO8601Interval(offset_str) - self.clock_trigger_time = int( - point_parse(str(trigger_time)).seconds_since_unix_epoch - ) - return self.clock_trigger_time + if offset_str is None: + trigger_time = point + else: + trigger_time = point + ISO8601Interval(offset_str) + + return int( + point_parse(str(trigger_time)).seconds_since_unix_epoch) def get_try_num(self): """Return the number of automatic tries (try number).""" diff --git a/cylc/flow/xtrigger_mgr.py b/cylc/flow/xtrigger_mgr.py index 4512d97b7c8..35b8e88b36c 100644 --- a/cylc/flow/xtrigger_mgr.py +++ b/cylc/flow/xtrigger_mgr.py @@ -388,6 +388,7 @@ def get_xtrig_ctx(self, itask: TaskProxy, label: str) -> SubFuncContext: # External (clock xtrigger): convert offset to trigger_time. # Datetime cycling only. kwargs["trigger_time"] = itask.get_clock_trigger_time( + itask.point, ctx.func_kwargs["offset"] ) else: