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
feat: support proto 3 #1078
feat: support proto 3 #1078
Conversation
Signed-off-by: samsja <sami.jaghouar@hotmail.fr>
Signed-off-by: samsja <sami.jaghouar@hotmail.fr>
Signed-off-by: samsja <sami.jaghouar@hotmail.fr>
Signed-off-by: samsja <sami.jaghouar@hotmail.fr>
📝 Docs are deployed on https://ft-feat-support-proto-3--jina-docs.netlify.app 🎉 |
if __pb__version__.startswith('4'): | ||
from docarray.proto.pb.docarray_pb2 import ( | ||
DocumentArrayProto, | ||
DocumentArrayStackedProto, | ||
DocumentProto, | ||
NdArrayProto, | ||
NodeProto, | ||
UnionArrayProto, | ||
) | ||
else: | ||
from docarray.proto.pb2.docarray_pb2 import ( | ||
DocumentArrayProto, | ||
DocumentArrayStackedProto, | ||
DocumentProto, | ||
NdArrayProto, | ||
NodeProto, | ||
UnionArrayProto, | ||
) |
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.
aren't these two exactly the same? or am I blind? 😅
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.
Oh i see the difference now, nevermind
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 PR should be named "spot the difference"
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.
nerd version of "where is waldo?"
Context
the goal of this pr is to support both proto 3 and proto 4. Atm we only support proto 3.
details.
protobuf>= 3.19.0
instead ofprotobuf>=4.21
protoc 3 and 4 does not generate the same python code. Therefore if we use proto 3 to generate the
docarray_pb2.py
it will break when using proto 4 and vice versa.The solution to this problem is to generate the
docarray_pb2.py
from the proto two times. One with protoc3 and one with protoc4. Then the trick is to check which version of protobuf is installed during import of the proto file. And we serve the correct version