Questions tagged [protobuf-python]

64 questions
21
votes
1 answer

Relative imports with ProtoBuf: Generating Python classes with ProtoBuf gives ModuleNotFoundError

Does protobuf support relative imports for python? I have been unsuccessful in creating a protobuf build script that supports this. When generating python-classes from my .proto-files, I am only able to import the python-modules if I launch python…
ViggoTW
  • 696
  • 2
  • 7
  • 19
13
votes
0 answers

PySpark and Protobuf Deserialization UDF Problem

I'm getting this error Can't pickle : it's not found as google.protobuf.pyext._message.CMessage when I try to create a UDF in PySpark. Apparently, it uses CloudPickle to serialize the command…
Marc Vitalis
  • 2,129
  • 4
  • 24
  • 36
10
votes
1 answer

protobuf and python: can protoc generate __init__.py files?

Is there a way to ask protoc to generate empty __init__.py files in the directories that it uses to generated the .py files so that they can be used as modules?
eftshift0
  • 26,375
  • 3
  • 36
  • 60
4
votes
1 answer

Reverse engineering .proto files from pb2.py generated with protoc

Is it possible to get proto files from generated pb2.py with protoc? Will be the same reverse engineering possible for gRPC?
4
votes
1 answer

Trouble saving repeated protobuf object to file (Python)

I'm new to protobuf, so I don't know how to frame the question correctly. Anyways, I'm using this Model Config proto file. I converted it into python using this command protoc -I=. --python_out=. ./model_server_config.proto from Protocol Buffer…
krxat
  • 513
  • 4
  • 16
4
votes
0 answers

Why is the creation of Python protobuf messages so slow?

Say I have a message defined in test.proto as: message TestMessage { int64 id = 1; string title = 2; string subtitle = 3; string description = 4; } And I use protoc to convert it to Python like so: protoc --python_out=.…
Brendan Martin
  • 561
  • 6
  • 17
4
votes
1 answer

Is it possible to run multiple instances of same service on single GRPC server?

I was trying to see if it's possible to run different instances of the same service on a single GRPC server, but it looks like I'm not able to do so. So I was wondering if I was doing anything wrong with my test, or if it's not possible at all. My…
fedexist
  • 155
  • 2
  • 12
3
votes
2 answers

Python class generated by protoc cannot be imported in the code because of unresolved references (Mac OS)

I tried to use protocol buffers on my project and the problem I have is that when I use protoc to generate the python class. The file that's generated looks nothing like in the example provided by Google and cannot be imported in any file because…
3
votes
2 answers

Latest Google protobuf not working on app engine

For my GAE app, I was updating the libs in my requirements.txt, and after doing so, I get error messages relating to protobuf. TypeError: Descriptors cannot not be created directly. If this call came from a _pb2.py file, your generated code is out…
new name
  • 15,861
  • 19
  • 68
  • 114
3
votes
1 answer

How to use Value in the python implementation of protobuf

I have a proto file defined as: syntax = "proto3"; import "google/protobuf/struct.proto"; package generic.name; message Message { uint32 increment = 1; google.protobuf.Value payload = 2; } I have figured out how to make this work if I swap…
3
votes
1 answer

Can you assign multiple different value types to one field in a repeated Protobuf message?

I'm trying to reverse engineer a client that uploads an audio file to a server, and then uploads the file's metadata in a separate request afterwards. The metadata is serialized in Protobuf, and it uses a fairly simple and readable structure. Here's…
3
votes
0 answers

How can I properly import one .proto file into another?

I'm trying to import a message defined in one .proto (ndarray.proto) file into another (image.proto). My folder structure is: proto/ | |-- image.proto | |-- numproto/ | | | |-- protobuf | | | |-- ndarray_pb2.py | …
Alex Cavanaugh
  • 415
  • 1
  • 5
  • 16
3
votes
3 answers

Python Implementing protobuf --decode-raw in python

I am dealing with the protobuf protocol and I encounter the need of decoding messages of unknown fields and types. I know protoc --decode_raw does a good job at that (alas not precise but good enough). I was thinking about running protoc…
toothpick
  • 113
  • 18
3
votes
0 answers

What is the most elegant way to make changes to the elements of a protobuf object in python?

Here is a config file that represents a protobuf object: model { faster_rcnn { num_classes: 37 image_resizer { keep_aspect_ratio_resizer { min_dimension: 600 max_dimension: 1024 } } ... I wish to use…
Alex Ryan
  • 3,719
  • 5
  • 25
  • 41
2
votes
1 answer

How to collate several protobuf messages into one object

I have a a protobuf message in the form of: message CustomMessage { SubMessageTypeA a_msg = 1; SubMessageTypeB b_msg = 2; SubMessageTypeC c_msg = 3; } I have several objects (assume 3) of this type that each have one of their…
Amir
  • 421
  • 1
  • 4
  • 14
1
2 3 4 5