Skip to content

Commit

Permalink
Stop task proxy clock trigger time being cached to prevent
Browse files Browse the repository at this point in the history
all clock triggers being the same.
  • Loading branch information
wxtim committed Oct 25, 2023
1 parent 8a0b98e commit 860f7eb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
29 changes: 16 additions & 13 deletions cylc/flow/task_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)."""
Expand Down
1 change: 1 addition & 0 deletions cylc/flow/xtrigger_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 860f7eb

Please sign in to comment.