Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python: protobuf==4.21.0rc1 adds dependency on grpcio-tools #9954

Closed
parthea opened this issue May 12, 2022 · 6 comments
Closed

Python: protobuf==4.21.0rc1 adds dependency on grpcio-tools #9954

parthea opened this issue May 12, 2022 · 6 comments
Assignees

Comments

@parthea
Copy link

parthea commented May 12, 2022

What version of protobuf and what language are you using?
Version: 4.21.0rc1
Language: Python

What operating system (Linux, Windows, ...) and version?
Ubuntu 20.04.4 LTS

What runtime / compiler are you using (e.g., python version or gcc version)
Python 3.9.12

python -m grpc_tools.protoc --version
libprotoc 3.19.4

What did you do?
Steps to reproduce the behavior:

  1. Run pip install googleapis-common-protos
  2. In python shell, run >>> from google.rpc import error_details_pb2
  3. Observe that no error occurs
  4. Run pip install protobuf==4.21.0rc1 to install the pre-release version of protobuf
  5. In python shell, run >>> from google.rpc import error_details_pb2
  6. Observe the following error
>>> from google.rpc import error_details_pb2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/google/rpc/error_details_pb2.py", line 52, in <module>
    _descriptor.FieldDescriptor(
  File "/usr/local/lib/python3.9/site-packages/google/protobuf/descriptor.py", line 560, in __new__
    _message.Message._CheckCalledFromGeneratedFile()
AttributeError: module 'google._upb._message' has no attribute 'Message'. Did you mean: 'CMessage'?
  1. Install grpcio-tools==1.44.0 or newer
  2. In python shell, run >>> from google.rpc import error_details_pb2
  3. Observe that no error occurs
  4. Uninstall grpcio-tools
  5. In python shell, run >>> from google.rpc import error_details_pb2
  6. Observe that no error occurs

What did you expect to see
I expected to run from google.rpc import error_details_pb2 in a python shell successfully after installing both googleapis-common-protos and protobuf==4.21.0rc1

What did you see instead?
I saw this error

>>> from google.rpc import error_details_pb2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/google/rpc/error_details_pb2.py", line 52, in <module>
    _descriptor.FieldDescriptor(
  File "/usr/local/lib/python3.9/site-packages/google/protobuf/descriptor.py", line 560, in __new__
    _message.Message._CheckCalledFromGeneratedFile()
AttributeError: module 'google._upb._message' has no attribute 'Message'. Did you mean: 'CMessage'?

The strange thing is that installing grpcio-tools solved the issue, however removing grpcio-tools did not bring the issue back.

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

Anything else we should know about your project / environment
I used a clean environment for testing, only installing googleapis-common-protos and protobuf==4.21.0rc1

@haberman
Copy link
Member

_message.Message._CheckCalledFromGeneratedFile()

This error indicates that you are using old generated code. The file error_details_pb2.py must have been generated by a protoc prior to 3.19.0.

Per the update at https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates, protobuf 4.21.0 requires that the _pb2.py files are generated from protoc >= 3.19.0

If you regenerate the _pb2.py files it should fix the problem.

The strange thing is that installing grpcio-tools solved the issue, however removing grpcio-tools did not bring the issue back.

My hunch is that installing grpcio-tools downgraded protobuf to 3.x.

@nfelt
Copy link

nfelt commented May 17, 2022

@haberman - since it looks like 4.21.0 final is not yet released, could the protobuf team please consider improving the error message that users get in this case to make it clearer what's broken, prior to the final release?

For example, maybe google._upb._message.Message could be populated with some shim that emits an error message pointing users to https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates or some other indication that the protobuf dep is too new for the generated code to work?

The context is that my team also got a report of this issue: tensorflow/tensorboard#5703 Older releases of our pip package that have generated Python proto files don't have an upper bound on their protobuf runtime dep, which historically hadn't been a problem, but I'm concerned it will become a significant breakage as soon as 4.21.0 is released, and it would help a lot of if the error message was a bit more self-explanatory that downgrading the protobuf dep to the 3.x major version series would at least temporarily resolve the problem.

Edited to add that this will also break a lot of existing released TensorFlow pip packages with the same unclear failure mode, as I think you've seen: tensorflow/tensorflow#56077 (comment)

I am not on the TF team but FWIW, my understanding is that they are blocked on upgrading protoc due to tensorflow/tensorflow#53234 which is very unlikely to be something that can be resolved in a few days, and TF's release cadence almost certainly wouldn't allow rushing out a patch release in that time frame either, so a fix on the TF side seems very challenging given the relatively short notice.

@haberman
Copy link
Member

could the protobuf team please consider improving the error message that users get in this case to make it clearer what's broken, prior to the final release?

Yes I think that is a good idea. I had been thinking a similar thing.

@nfelt
Copy link

nfelt commented May 17, 2022

@haberman Thanks for considering, that would be much appreciated 👍

@haberman
Copy link
Member

PR: protocolbuffers/upb#617

copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this issue May 20, 2022
See also: #53234
See also: protocolbuffers/protobuf#9954
See also: #56077

PiperOrigin-RevId: 450054200
tensorflow-jenkins pushed a commit to tensorflow/tensorflow that referenced this issue May 20, 2022
See also: #53234
See also: protocolbuffers/protobuf#9954
See also: #56077

PiperOrigin-RevId: 450054200
mihaimaruseac added a commit to tensorflow/tensorflow that referenced this issue May 20, 2022
See also: #53234
See also: protocolbuffers/protobuf#9954
See also: #56077

PiperOrigin-RevId: 450054200
pranve pushed a commit to pranve/tensorflow that referenced this issue May 21, 2022
pranve pushed a commit to pranve/tensorflow that referenced this issue May 21, 2022
pranve pushed a commit to pranve/tensorflow that referenced this issue May 21, 2022
bmd3k added a commit to tensorflow/tensorboard that referenced this issue May 26, 2022
The latest protobuf release is not backwards compatible with TensorFlow's protos and our copies of those protos in tensorboard/compat/proto . We knew this change was coming so, fortunately, TF had already fixed their dependencies to force a compatible version of protobuf. However, we also have to update our own requirements.txt to force the same version of protobuf, to unbreak the build when TensorFlow is not installed.

Googlers, see: http://b/182876485.
See: protocolbuffers/protobuf#9954 (comment)
See: https://cs.opensource.google/tensorflow/tensorflow/+/master:tensorflow/tools/pip_package/setup.py?q=protobuf
@xkszltl
Copy link
Contributor

xkszltl commented May 29, 2022

Regarding protobuf "4.21", does that mean the python version will diverge from mainstream version?

bmd3k added a commit to bmd3k/tensorboard that referenced this issue Jun 8, 2022
The latest protobuf release is not backwards compatible with TensorFlow's protos and our copies of those protos in tensorboard/compat/proto . We knew this change was coming so, fortunately, TF had already fixed their dependencies to force a compatible version of protobuf. However, we also have to update our own requirements.txt to force the same version of protobuf, to unbreak the build when TensorFlow is not installed.

Googlers, see: http://b/182876485.
See: protocolbuffers/protobuf#9954 (comment)
See: https://cs.opensource.google/tensorflow/tensorflow/+/master:tensorflow/tools/pip_package/setup.py?q=protobuf
bmd3k added a commit to tensorflow/tensorboard that referenced this issue Jun 8, 2022
The latest protobuf release is not backwards compatible with TensorFlow's protos and our copies of those protos in tensorboard/compat/proto . We knew this change was coming so, fortunately, TF had already fixed their dependencies to force a compatible version of protobuf. However, we also have to update our own requirements.txt to force the same version of protobuf, to unbreak the build when TensorFlow is not installed.

Googlers, see: http://b/182876485.
See: protocolbuffers/protobuf#9954 (comment)
See: https://cs.opensource.google/tensorflow/tensorflow/+/master:tensorflow/tools/pip_package/setup.py?q=protobuf
georgepaw pushed a commit to graphcore/tensorflow that referenced this issue Jul 25, 2022
Summary:
See also: tensorflow/tensorflow#53234
See also: protocolbuffers/protobuf#9954
See also: tensorflow/tensorflow#56077

TF1.15 Only

Reviewers: #tensorflow, #framework_ip_review_-_any_oss_or_third-party_code_use_has_been_approved, vladimirm

Reviewed By: #tensorflow, #framework_ip_review_-_any_oss_or_third-party_code_use_has_been_approved, vladimirm

Maniphest Tasks: T63128

Differential Revision: https://phabricator.sourcevertex.net/D67981
chxin66 pushed a commit to chxin66/tensorflow that referenced this issue Sep 5, 2022
yatbear pushed a commit to yatbear/tensorboard that referenced this issue Mar 27, 2023
The latest protobuf release is not backwards compatible with TensorFlow's protos and our copies of those protos in tensorboard/compat/proto . We knew this change was coming so, fortunately, TF had already fixed their dependencies to force a compatible version of protobuf. However, we also have to update our own requirements.txt to force the same version of protobuf, to unbreak the build when TensorFlow is not installed.

Googlers, see: http://b/182876485.
See: protocolbuffers/protobuf#9954 (comment)
See: https://cs.opensource.google/tensorflow/tensorflow/+/master:tensorflow/tools/pip_package/setup.py?q=protobuf
dna2github pushed a commit to dna2fork/tensorboard that referenced this issue May 1, 2023
The latest protobuf release is not backwards compatible with TensorFlow's protos and our copies of those protos in tensorboard/compat/proto . We knew this change was coming so, fortunately, TF had already fixed their dependencies to force a compatible version of protobuf. However, we also have to update our own requirements.txt to force the same version of protobuf, to unbreak the build when TensorFlow is not installed.

Googlers, see: http://b/182876485.
See: protocolbuffers/protobuf#9954 (comment)
See: https://cs.opensource.google/tensorflow/tensorflow/+/master:tensorflow/tools/pip_package/setup.py?q=protobuf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants