1

I have a log of grpc messages for a TensorflowServing system looking like this:

model_spec:{name:"model_name"}  inputs:{key:"args_0"  value:{dtype:DT_STRING  tensor_shape:{dim:{size:1}}  string_val:"example input"}}  inputs:{key:"args_1"  value:{dtype:DT_STRING  tensor_shape:{dim:{size:1}}  string_val:"another example input"}}  inputs:{key:"args_3"  value:{dtype:DT_FLOAT  tensor_shape:{dim:{size:1}}  float_val:374969}}

I suspect this is a protobuf format string (but I might be wrong) and I would like to turn it into a python dictionary (something like this but I am flexible):

{
  "model_spec":{"name":"model_name"},
  "inputs":{
    "args_0": "example input",
    "args_1": "another example input",
    "args_3": 374969
  }
}

Are there any libraries that can help me here? My problem is that I don't have any schema for this message (as required in this stackoverflow question). I tried parsing this with regular expressions but I hope there might be a better way.

1
  • 1
    I'm entirely unfamiliar with Tensorflow (Serving) but, your example looks to be a PredictRequest (that's the schema). You'll need to have an instance of the Protobuf message and should then be able to json_format.MessageToJson(message) it. You don't need the schema if you can get an instance of the Python Protobuf message. Commented Jun 7, 2023 at 17:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.