-
Notifications
You must be signed in to change notification settings - Fork 815
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
[Ready for review] Add explicit max length control for foreach value. #1733
Conversation
metaflow/flowspec.py
Outdated
@@ -529,7 +530,7 @@ def _is_primitive_type(item): | |||
) | |||
|
|||
value = item if _is_primitive_type(item) else reprlib.Repr().repr(item) | |||
return basestring(value) | |||
return basestring(value)[:MAXIMUM_VALUE_CHARACTERS] |
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.
Repr already has a default limit of 30 already - I imagine this change only affects primitives right now. I would recommend setting the value of maxstring
to MAX_CHARS
so that if the value of MAX_CHARS
is modified in the future - you can expect a consistent response if repr
is in action.
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.
Repr doc is ambiguous, the maxstring=30
for Repr means that the string inside the represented result is <=30 (it doesn't truncate the entire representation to maxstring. for example,
reprlib.Repr().repr({"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa": "bbbbbbbbbbbbbbbbbbbbbbb"})
"{'aaaaaaaaaaaa...aaaaaaaaaaaaa': 'bbbbbbbbbbbbbbbbbbbbbbb'}"
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.
LGTM
Add a length control for final result as string. This will prevent us from generating a list of foreach value with crazy long value.