Questions tagged [protobuf-python]

64 questions
2
votes
1 answer

Python Dict -> Protobuf Message Parse Error: Timestamp

I have a protobuf timestamp message that I'm trying to parse from a Python dictionary. The target Protobuf message looks like this: message LogStatusSnapshot { google.protobuf.Timestamp time = 1; LogStatus.LogStatusEnum status = 2; …
2
votes
1 answer

How can I check if a protobuf message has a field defined

I'm working with a protobuf message that has some of the fields marked for deprecation with [deprecated = true]. To my understanding the field can still be used by some part of the code (maybe with a warning). I want to make sure that my code is…
Amir
  • 421
  • 1
  • 4
  • 14
2
votes
0 answers

How to parse a .proto file into a JSON/Python structure?

I have a .proto file, describing a given schema and following proto2 syntax. I would like to read this file in python, and generate a structure that I can then manipulate (can be JSON, a python data structure, a proto-specific structure, w/e), in…
Kestemont Max
  • 1,302
  • 2
  • 8
  • 10
2
votes
1 answer

How to get header from grpc responce with python

I am trying to get header of the gRPC response with the following code, and it doesn't work: response = stub.GetAccounts(users_pb2.GetAccountsRequest(), metadata=metadata) header = response.header() This is what this header looks like in Kreya,…
2
votes
2 answers

Implicit relative imports inside of Protobuf-generated Python package make importing from outside impossible

I have a package that looks like this: setup.py requirements.txt alphausblue/ api/ ripple/ org_pb2.py org/ v1/ org_pb2_grpc.py In org_pb2_grpc.py I have the following import line: from api.ripple…
Woody1193
  • 7,252
  • 5
  • 40
  • 90
2
votes
1 answer

Protocol Buffer ParseFromString function not reading complete binary file in Python

I am testing out Protocol buffers and trying to read a csv file, serialize it and write the output to a binary file and then read the binary file using ParseFromString. I am able to serialize and write the binary file however on reading it gives an…
Code_Jamer
  • 913
  • 2
  • 9
  • 21
2
votes
3 answers

Using python compiled protobuf pb2 as key and value serializer

I am trying to read data from a kafka topiv which has been serialized using google's protobuf. I compiled the proto files using protoc which generated pb2 files. Now i am trying to use faust and create a stream processor but i can't find the correct…
1
vote
0 answers

Different libraries require different version of Protobuf (dependency conflict)

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. google-api-core 2.11.0 requires…
1
vote
1 answer

Protobuf file not generating correct Python code with 'protoc --python_out' command

I have a .proto file defining a message called 'DeviationCreate'. syntax = "proto3"; package proto; option go_package = "proto"; option java_package = "deviationalert"; message DeviationCreate { int64 alertKey = 1; } I'm trying to generate…
Mohsen
  • 11
  • 1
1
vote
1 answer

How to get type of a protobuf message from a raw protobuf buffer and the .proto files?

Let's say that I have dumped a protobuf message to a file called packet.bin . Let's also say that I have the .proto files which describes many message types of which one is the type of the dumped message. How can I determine which type of message…
1
vote
1 answer

How to convert or deserialize byte octets to string in python

I get a message from rocket mq, it's like the string show in the pic above or the below: b'\x08\xd2\t\x12\x03Tim\x1a(\x08\x04\x12\x18Test ProtoBuf for Python\x1a\n31.10.2019' The message from rocket mq also has a similar process show in the pic…
Steve
  • 59
  • 5
1
vote
1 answer

Protoc.py compiles files differently depending on where it is called from

If protoc.py is called from powershell, the compiled file is missing about half of the code as opposed to when protoc.py is called from natively from python. I have a powershell script and a python script. My aim is to remove the python script so I…
1
vote
1 answer

Is there a Protostuff-equivalent Protobuff library for Python?

In Java, libraries like protostuff allow you to generate buffers from a Java POJO approximately like so: Schema schema = RuntimeSchema.getSchema(Foo.class); ... protostuff = ProtostuffIOUtil.toByteArray(foo, schema, buffer); I've been trying…
zerohedge
  • 3,185
  • 4
  • 28
  • 63
1
vote
1 answer

Protobuf: ParseFromString method gives error "raise message_mod.DecodeError('Field number 0 is illegal.')" for message with oneof field

I have a kafka topic that has protobuf message of format: message CreditTransaction { string date = 1; float amount = 2; } message DebitTransaction { string date = 1; float amount = 2; } ... .. # other message definitions message…
aiman
  • 1,049
  • 19
  • 57
1
vote
2 answers

gRPC/protobuf generated Python files use incorrect import statements

I have a grpc repo included in a python project repo as a submodule at src/grpc/protobuf with the following example structure: protobuf/ | |-data_structs/ | |-example_structA.proto | |-example_structB.proto | |-messages/ | …
cma0014
  • 1,517
  • 3
  • 11
  • 9