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? |
c0c0n3
left a comment
There was a problem hiding this comment.
@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.
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| # 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.
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
xin the boxes that applyfunctionality to not work as expected)
Checklist
Put an
xin 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