-
Notifications
You must be signed in to change notification settings - Fork 13
Fix for protobuf 3.2 #31
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
Conversation
Could I get a review on this? @borntyping |
value = dict(((a.key, a.value) for a in value)) | ||
elif descriptor.type == \ | ||
google.protobuf.descriptor.FieldDescriptor.TYPE_FLOAT: | ||
value = round(value, 1) |
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.
Why the special case for float values?
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.
It seems like rounding here made the tests pass, as the test value "11.1" has some float encoding precision loss.
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.
Might be better to remove the test this breaks - I'm a little worried that this could break things in suprising ways for other users.
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.
The test is still good, but maybe some thought should be put into what the precision of a text float should be (then instead of comparing things non-representable accurately by a python float, it can be compared via epsilon, e.g. | a - b | < some_small_value).
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 would be fine (alternatively move the round()
call to the test instead).
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.
Using the C++ backend for protobuf results in floating point precision loss. Applications should be able to tolerate the IEEE 754 FP spec essentially.
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'll spend some time polishing the tests.
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've pushed a PR that should fix this (and makes some needed changes anyway) here: #33. I'm merge it after this PR if you don't have any further changes, or close it if not needed.
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.
This seems much better!
This looks great, thanks for all your work! My only issue is the float conversion mentioned above - if this is correct it could definitely use a comment explaining why in the code. |
This library currently conflicts with the protobuf requirement of gRPC (which requires >=3.2.0). This seems like a good solution. Any chance this could move forward? |
protobuf = 'protobuf>=3.0.0b2,<4.0.0' | ||
protobuf = 'protobuf>=3.2.0,<4.0.0' | ||
else: | ||
protobuf = 'protobuf>=2.3.0,<4.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.
Need to bump this 3.2 as well, I was testing with python2.7 and 3.2+ only
Thanks @srikiraju and @efritz! This has been released as 6.5.0, along with the changes in #33. |
This PR tolerates protobuf 3.2+. Protobuf classes are supposed to end with _pb2 or protobuf may break in weird ways.
Additionally, the C++(cython?) implementation of protobuf behaves slightly differently from the python implementation(float handling). It seems that pip is allowed to pull whichever version it wants from pypi depending on the system.
Also fixes some tox environment issues.