tensorflow / model-analysis

Model analysis tools for TensorFlow
Apache License 2.0
1.26k stars 281 forks source link

[Bug] Python 3.11 Support #185

Open smokestacklightnin opened 2 months ago

smokestacklightnin commented 2 months ago

System information

Describe the problem

There seems to be an issue with Python 3.11 support. For Python 3.11, protobuf 4.25.2 is installed, but the tfma protobuf modules seem to require protobuf 3.19 or earlier. This causes tfma to crash on import (shown below).

Source code / logs

$ python -c "import tensorflow_model_analysis as tfma"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/tmp.PTkD1g2WBK/model-analysis/tensorflow_model_analysis/__init__.py", line 30, in <module>
    from tensorflow_model_analysis.sdk import *
  File "/tmp/tmp.PTkD1g2WBK/model-analysis/tensorflow_model_analysis/sdk.py", line 60, in <module>
    from tensorflow_model_analysis.proto.config_pb2 import AggregationOptions
  File "/tmp/tmp.PTkD1g2WBK/model-analysis/tensorflow_model_analysis/proto/config_pb2.py", line 35, in <module>
    _descriptor.EnumValueDescriptor(
  File "/tmp/tmp.PTkD1g2WBK/model-analysis/.venv/lib/python3.11/site-packages/google/protobuf/descriptor.py", line 789, 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