yacs
yacs copied to clipboard
int -> str is added to allowed casts to overcome int to str incompatibility
Fix for https://github.com/rbgirshick/yacs/issues/26
Great work @InnovArul. @rbgirshick, any ideas when can this branch be merged and pip package updated?
I believe this is a wrong fix for my issue as it won't work in all cases, e.g. value "+2"
will be converted to "2"
in the end, thus losing the +
.
The correct fix in my opinion would be to pass target type into _decode_cfg_value
and don't use eval if target type is str
.
I will try to code it up tomorrow, if I have the time.
Thanks for the heads up with this example. I have changed the _decode_cfg_value
to handle this. Can you check if this handles your scenario?
@InnovArul @Rizhiy, how about you get configuration type from the default config value and then force that on incoming value!
@muzammil360 Such validation is already built-in to yacs with the method _check_and_coerce_cfg_value_type
(here). But the issue is that, every string is passed through literal_eval
(here) which changes +123
to 123
. Now, I have changed the code to not to do literal_eval
if the data type of the input as well as the expected datatype is a string.
Ah i see. Thanks for the clarification.
On Fri, Jan 3, 2020, 11:28 AM Arulkumar [email protected] wrote:
@muzammil360 https://github.com/muzammil360 Such validation is already built-in to yacs with the method _check_and_coerce_cfg_value_type (here https://github.com/rbgirshick/yacs/blob/7b06e280216451b6f8536538548c75b861d9c22c/yacs/config.py#L460). But the issue is that, every string is passed through literal_eval which changes +123 to 123. Now, I have changed the code to not to do literal_eval if the data type of the input as well as the expected datatype is a string.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rbgirshick/yacs/pull/35?email_source=notifications&email_token=AE3S5IKSCTIWTZTT66KTVYTQ33LKFA5CNFSM4KAMLO5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIAMZNQ#issuecomment-570477750, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE3S5INVK7BYP7MIWXN5FILQ33LKFANCNFSM4KAMLO5A .