Skip to content

Update Protobuf Version for Compatibility #30

@hesic73

Description

@hesic73

We currently build Deoxys using Protobuf 3. However, using a newer version of Protobuf in Python (e.g., protobuf==5.28.3) causes compatibility issues.

git checkout v3.13.0

$ python examples/run_deoxys_with_space_mouse.py 
Traceback (most recent call last):
  File "examples/run_deoxys_with_space_mouse.py", line 4, in <module>
    from deoxys.franka_interface import FrankaInterface
  File "/home/abrar/hsc/deoxys_control/deoxys/deoxys/franka_interface/__init__.py", line 1, in <module>
    from .franka_interface import FrankaInterface
  File "/home/abrar/hsc/deoxys_control/deoxys/deoxys/franka_interface/franka_interface.py", line 10, in <module>
    import deoxys.proto.franka_interface.franka_controller_pb2 as franka_controller_pb2
  File "/home/abrar/hsc/deoxys_control/deoxys/deoxys/proto/franka_interface/franka_controller_pb2.py", line 36, in <module>
    _descriptor.EnumValueDescriptor(
  File "/home/abrar/miniconda3/envs/hsc/lib/python3.8/site-packages/google/protobuf/descriptor.py", line 920, in __new__
    _message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot be created directly.
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.
If you cannot immediately regenerate your protos, some other possible workarounds are:
 1. Downgrade the protobuf package to 3.20.x or lower.
 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates

For now, I regenerate the Python files using protoc, which seems to resolve the issue. Here’s the command I use:

python -m grpc_tools.protoc -I=proto --python_out=deoxys/proto --grpc_python_out=deoxys/proto/ proto/franka-interface/*.proto
python -m grpc_tools.protoc -I=proto --python_out=deoxys/proto --grpc_python_out=deoxys/proto proto/*.proto

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions