-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix CPF wall_clock offset precision constraint #6431
Conversation
Presumably not, as we've been living with the bug? |
Well coverage is 100%, and trigger offsets are tested ... But I could add a test that has CPF at lower resolution than offset |
Yeah worth doing that I think. |
Good thing I tried.. Found a way to break my solution, and have been working on various solutions all afternoon.. |
07ba5de
to
c89c34f
Compare
Tests added.. The solution had to ensure |
806fe1f
to
3f009c1
Compare
@@ -0,0 +1 @@ | |||
The `cycle point format` was imposing an undesirable constraint on `wall_clock` offsets, this has been fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The `cycle point format` was imposing an undesirable constraint on `wall_clock` offsets, this has been fixed. | |
Allowed `wall_clock` offsets to use smaller precision than the `cycle point format` (e.g. `wall_clock(offset="PT1M")` in combination with `cycle point format = CCYY`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well technically they were capable of it before (the last 10 years in Cylc7 at least), but some change broke it causing this constraint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved, but I prefer @oliver-sanders wording here, in terms of clarity for users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested 👍 Can actually be even simpler
cylc/flow/task_proxy.py
Outdated
point_time = point_parse(str(point)) | ||
if offset_str == 'P0Y': | ||
trigger_time = point | ||
trigger_time = point_time | ||
else: | ||
trigger_time = point + ISO8601Interval(offset_str) | ||
|
||
offset = int( | ||
point_parse(str(trigger_time)).seconds_since_unix_epoch) | ||
self.clock_trigger_times[offset_str] = offset | ||
trigger_time = ( | ||
point_parse( | ||
point_time.__str__(strftime_format='%Y%m%dT%H%M%S'), | ||
'%Y%m%dT%H%M%S' | ||
) | ||
+ interval_parse(offset_str) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to mess with the strftime_format:
point_time = point_parse(str(point)) | |
if offset_str == 'P0Y': | |
trigger_time = point | |
trigger_time = point_time | |
else: | |
trigger_time = point + ISO8601Interval(offset_str) | |
offset = int( | |
point_parse(str(trigger_time)).seconds_since_unix_epoch) | |
self.clock_trigger_times[offset_str] = offset | |
trigger_time = ( | |
point_parse( | |
point_time.__str__(strftime_format='%Y%m%dT%H%M%S'), | |
'%Y%m%dT%H%M%S' | |
) | |
+ interval_parse(offset_str) | |
) | |
# Convert ISO8601Point into metomi-isodatetime TimePoint at full | |
# second precision (N.B. it still dumps at the same precision | |
# as workflow cycle point format): | |
point_time = point_parse(str(point)) | |
if offset_str == 'P0Y': | |
trigger_time = point_time | |
else: | |
trigger_time = point_time + interval_parse(offset_str) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No way! shocking .. Just tested this and it worked..
Ah I think I know where my confusion was ... I was originally converting these objects back to ISO8601Point
and ISO8601Interval
adding them together then parsing them again (with the string of the result) but you get a dump format and epoc seconds the same as the CPF (trimmed to that precision)...
The TimePoint object also has dump format I assumed they behaved the same and/or this was inherited. Which the dump format was the same, but obviously your suggestion shows the epoc seconds aren't truncated... Doh!
Reverting things to this.. Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(p.s. sorry, should have merged yours in first then rebased)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I stuck a breakpoint in there and got confused by the dump format precision for a while 😄 Hopefully the comment I included makes it clear for people debugging in the future
cylc/flow/cycling/iso8601.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to change this file actually, see above comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted above! thanks again
3f009c1
to
a63553f
Compare
a63553f
to
01d15b5
Compare
closes #6423
Check List
CONTRIBUTING.md
and added my name as a Code Contributor.setup.cfg
(andconda-environment.yml
if present).?.?.x
branch.