Skip to content

Commit

Permalink
fix CPF wall_clock offset precision constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
dwsutherland committed Oct 17, 2024
1 parent 0ccff88 commit 07ba5de
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
18 changes: 11 additions & 7 deletions cylc/flow/cycling/iso8601.py
Original file line number Diff line number Diff line change
Expand Up @@ -952,28 +952,32 @@ def _interval_parse(interval_string):
return WorkflowSpecifics.interval_parser.parse(interval_string)


def point_parse(point_string: str) -> 'TimePoint':
"""Parse a point_string into a proper TimePoint object."""
def point_parse(
point_string: str, dump_format: Optional[str] = None
) -> 'TimePoint':
"""Parse a point_string into a proper format specific TimePoint object."""
if dump_format is None:
dump_format = WorkflowSpecifics.DUMP_FORMAT
return _point_parse(
point_string,
WorkflowSpecifics.DUMP_FORMAT,
dump_format,
WorkflowSpecifics.ASSUMED_TIME_ZONE
)


@lru_cache(10000)
def _point_parse(point_string: str, _dump_fmt, _tz) -> 'TimePoint':
def _point_parse(point_string: str, dump_fmt, _tz) -> 'TimePoint':
"""Parse a point_string into a proper TimePoint object.
Args:
point_string: The string to parse.
_dump_fmt: Dump format (only used to avoid invalid cache hits).
dump_fmt: Dump format (used to avoid invalid cache hits).
_tz: Cycle point time zone (only used to avoid invalid cache hits).
"""
if "%" in WorkflowSpecifics.DUMP_FORMAT:
if "%" in dump_fmt:
# May be a custom not-quite ISO 8601 dump format.
with contextlib.suppress(IsodatetimeError):
return WorkflowSpecifics.point_parser.strptime(
point_string, WorkflowSpecifics.DUMP_FORMAT)
point_string, dump_fmt)
# Attempt to parse it in ISO 8601 format.
return WorkflowSpecifics.point_parser.parse(point_string)
15 changes: 10 additions & 5 deletions cylc/flow/task_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
from cylc.flow.cycling.iso8601 import (
point_parse,
interval_parse,
ISO8601Interval
)

if TYPE_CHECKING:
Expand Down Expand Up @@ -427,11 +426,17 @@ def get_clock_trigger_time(
if offset_str == 'P0Y':
trigger_time = point
else:
trigger_time = point + ISO8601Interval(offset_str)
trigger_time = (
point_parse(str(point), '%Y%m%dT%H%M%S')
+ interval_parse(offset_str)
)

offset = int(
point_parse(str(trigger_time)).seconds_since_unix_epoch)
self.clock_trigger_times[offset_str] = offset
self.clock_trigger_times[offset_str] = int(
point_parse(
str(trigger_time),
'%Y%m%dT%H%M%S'
).seconds_since_unix_epoch
)
return self.clock_trigger_times[offset_str]

def get_try_num(self):
Expand Down

0 comments on commit 07ba5de

Please sign in to comment.