-
Notifications
You must be signed in to change notification settings - Fork 49
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 for Issue#518 #573
base: master
Are you sure you want to change the base?
Fix for Issue#518 #573
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ |
@chicco785 Gentle Reminder for merging!! |
hi @daminichopra, thanks for this. I've just looked at the crate docs where they explicitly mention the backoff factor should be between 0 and 120. So we need to output a config error not a warning. I suggest we change this PR as follows:
This way we get to reuse the validation code in the future if we have similar env vars. What do you think? Does it make any sense? |
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.
@daminichopra thanks for your commits, if you could improve the code just slightly so we can reuse it for other range variables going forward---i.e. not just for the range [0, 120]
. I sketched out in the review comments how we could do that. Also, we need to add unit tests for the new class FloatRangeVar
similar to what we have already in utils/tests/test_cfgreader
. Thank you soooo much!!
raise ValueError('value out of range: {}'.format(backoff_factor)) | ||
return float(rep) | ||
|
||
|
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.
Can we make this class more generic so it works for any range, not just the 0-120 range?
e.g.
class FloatRangeVar(EVar):
def __init__(var_name, default_value, mask_value, lo, hi):
# super(var_name, default_value, mask_value)
# ...check lo <= hi
def _do_read(self, rep: str) -> float:
value = float(rep)
if value not in range(self.lo, self.hi):
raise ValueError(...)
return value
@@ -58,7 +59,7 @@ def setup(self): | |||
# Added backoff_factor for retry interval between attempt of | |||
# consecutive retries | |||
backoff_factor = EnvReader(log=logging.getLogger(__name__).debug) \ | |||
.read(FloatVar('CRATE_BACKOFF_FACTOR', 0.0)) | |||
.read(FloatRangeVar('CRATE_BACKOFF_FACTOR', 0.0)) |
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.
If we make FloatRangeVar
generic (see comment below) then I think this line should be
.read(FloatRangeVar(var_name='CRATE_BACKOFF_FACTOR', default_value=0.0, lo=0.0, hi=120.0)
Proposed changes
Inserted a start check to verify that crate back off factor
Types of changes
What types of changes does your code introduce to the project: Put
an
x
in the boxes that applyfunctionality to not work as expected)
Checklist
Put an
x
in the boxes that apply. You can also fill these out aftercreating the PR. If you're unsure about any of them, don't hesitate to
ask. We're here to help! This is simply a reminder of what we are going
to look for before merging your code.
feature works
downstream modules
Further comments
Fix for Issue