-
Notifications
You must be signed in to change notification settings - Fork 94
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 ICP bug. #4227
Fix ICP bug. #4227
Conversation
if orig_icp is None: | ||
if self.cfg['scheduling']['cycling mode'] == INTEGER_CYCLING_TYPE: | ||
orig_icp = '1' | ||
if self.cycling_type == INTEGER_CYCLING_TYPE: |
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.
@hjoliver I think I saw cycling_type
in the debugger, and it was None
? But there was a cycling mode
in the cfg['scheduling']
that had the integer
value. Not sure if that's helpful/important for this issue 👍
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.
self.cycling_type
is initialized in WorkflowConfig.__init__()
. It shouldn't be None
, but I'll take another look...
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.
Unfortunately self.cfg['scheduling']['cycling mode']
was being used incorrectly here. In the integer case it is equal to INTEGER_CYCLING_TYPE
but in the date-time case it is equal to the calendar mode, not to ISO8601_CYCLING_TYPE
.
Unit tests added. |
(Pushed small tweak with skip-ci; all tests passed on previous commit, except patch coverage 83%) |
tests/unit/conftest.py
Outdated
def cycling_type(monkeypatch): | ||
"""Set the Cylc cycling type and return its value.""" | ||
def _cycling_type(integer=True): | ||
ctype = INTEGER_CYCLING_TYPE if integer else ISO8601_CYCLING_TYPE |
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.
I hadn't realised the difference between cycling type and mode. If I understand correctly:
- Type is either
integer
oriso8601
- Mode is either
integer
,gregorian
,360day
,365day
etc
Btw, just a heads up this is going to conflict with my PR #4213 - https://github.com/cylc/cylc-flow/pull/4213/files#diff-0cae8a7ee2d37098b1ad84b543d17cfc1e8535eed5fd6abac88c668bfe354cbb
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.
That's correct, I had forgotten the distinction myself.
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.
Btw, just a heads up this is going to conflict with my PR
And unfortunately (for me!) I just merged that PR 😬
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.
Deconflicted. And I've attempted to straighten out the cycling type vs mode stuff in the process.
def _cycling_type( | ||
mode: str = 'integer', time_zone: Optional[str] = None | ||
) -> str: | ||
if mode == 'integer': | ||
ctype = INTEGER_CYCLING_TYPE | ||
else: | ||
ctype = ISO8601_CYCLING_TYPE |
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.
In a parametrized test, I think it's clearer to specify a parameter as cycling_type = 'integer'
vs 'iso8601'
rather than 'integer'
vs ''
def _cycling_type( | |
mode: str = 'integer', time_zone: Optional[str] = None | |
) -> str: | |
if mode == 'integer': | |
ctype = INTEGER_CYCLING_TYPE | |
else: | |
ctype = ISO8601_CYCLING_TYPE | |
def _cycling_type( | |
ctype: str = INTEGER_CYCLING_TYPE, time_zone: Optional[str] = None | |
) -> 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.
True, but I was trying to maintain the distinction between the cycling mode
user config item, and cycling type
, which is internal. And your parameterized tests mostly do this via a mocked config dict, so they should really specify cycling mode, not type ... and then this fixture sets the internal type according to the mode. Finally, the gregorian
cycling mode is the default, so I set those values to empty string rather than hard-wiring another magic value.
So how about we leave this PR as-is, and as a low priority follow-up we could refactor the tests to specify cycling type directly, but separately from the mocked config?
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.
I have deconflicted the changelog
These changes close #4225
Requirements check-list
CONTRIBUTING.md
and added my name as a Code Contributor.