eWaterCycle / grpc4bmi

gRPC wrapper for model with a Basic modeling interface
https://grpc4bmi.readthedocs.io
Apache License 2.0
5 stars 4 forks source link

Upgrade to protobuf v4 #115

Closed sverhoeven closed 1 year ago

sverhoeven commented 1 year ago

A major version of protobuf was released see https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates . We should check if we can upgrade to 4

Protobuf is used by grpc which is used as

  1. client, in eWaterCycle
  2. server, inside container images of Hydrological models.

We should make sure that server using protobuf v3 can talk to client with protobuf v3. If not we need to rebuild all container images.

When using v4 of protobuf to run tests in grpc4bmi v0.2.14 you get following error:

test/test_docker.py:6: in <module>
    from grpc4bmi.bmi_client_docker import BmiClientDocker
grpc4bmi/bmi_client_docker.py:9: in <module>
    from grpc4bmi.bmi_grpc_client import BmiClient
grpc4bmi/bmi_grpc_client.py:13: in <module>
    from . import bmi_pb2, bmi_pb2_grpc
grpc4bmi/bmi_pb2.py:28: in <module>
    _EMPTY = _descriptor.Descriptor(
/opt/hostedtoolcache/Python/3.10.7/x64/lib/python3.10/site-packages/google/protobuf/descriptor.py:313: in __new__
    _message.Message._CheckCalledFromGeneratedFile()
E   TypeError: Descriptors cannot not be created directly.
E   If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
E   If you cannot immediately regenerate your protos, some other possible workarounds are:
E    1. Downgrade the protobuf package to 3.20.x or lower.
E    2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
E   
E   More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
sverhoeven commented 1 year ago

Tests of #126 concluded that upgrading to latest protobuf does not break anything