My current task requires me to use the BigQuery Storage Write API. I have
created a .proto file and was able to use protoc to generate a Python
message class. I am seeing this exception when creating an instance of that
class:
*TypeError: Message must be initialized with a dict: combocurve.Measurement*
*File "/google/api_core/grpc_helpers.py", line 162, in
error_remapped_callable*
Here is my .proto file:
syntax = "proto2";
package combocurve;
import "google/protobuf/timestamp.proto";
import "google/type/date.proto";
message Measurement {
required string device_id = 1;
required google.type.Date last_service_date = 2;
optional double temperature = 3;
optional double pressure = 4;
optional google.protobuf.Timestamp created_at = 5;
}
Here is the code that is raising the exception:
measurement = Measurement(
device_id='ABC123',
last_service_date=date_pb2.Date(
year=last_service_date.year,
month=last_service_date.month,
day=last_service_date.day),
temperature=10.0,
pressure=20.0,
created_at=int(created_at.timestamp() * 1e6)
)
Please let me know if you have any ideas as to what is causing this
exception.
Thanks in advance for your help!
-Tony
--
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/protobuf/2c29392c-a846-45d6-91bb-36d668a53d62n%40googlegroups.com.