Skip to content
This repository was archived by the owner on Feb 13, 2024. It is now read-only.
This repository was archived by the owner on Feb 13, 2024. It is now read-only.

Protobuf messages can no longer be deserialized after migration to 2.0.0 #64

@alexcombessie

Description

@alexcombessie

Environment details

  • OS type and version: macOS 10.14.6 - also reproduced with Linux CentOS 7
  • Python version: 3.6.10
  • pip version: 18.1
  • google-cloud-vision version: 2.0.0
  • protobuf version: 3.13.0

Steps to reproduce

  1. Run client.annotate_image(request)=> SUCCESS (request is valid and you can print the output)
  2. Try to deserialized message => FAILURE AttributeError: 'DESCRIPTOR'

Code example

from google.protobuf.json_format import MessageToDict
message = client.annotate_image(request)
print(message)  # this works
MessageToDict(message)  # this fails

Stack trace

[12:09:25] [INFO] [dku.utils]  - responses {
[12:09:25] [INFO] [dku.utils]  -   localized_object_annotations {
[12:09:25] [INFO] [dku.utils]  -     mid: "/m/02dl1y"
[12:09:25] [INFO] [dku.utils]  -     name: "Hat"
[12:09:25] [INFO] [dku.utils]  -     score: 0.509366512298584
[12:09:25] [INFO] [dku.utils]  -     bounding_poly {
[12:09:25] [INFO] [dku.utils]  -       normalized_vertices {
[12:09:25] [INFO] [dku.utils]  -         x: 0.005275096278637648
[12:09:25] [INFO] [dku.utils]  -         y: 0.008623555302619934
[12:09:25] [INFO] [dku.utils]  -       }
[12:09:25] [INFO] [dku.utils]  -       normalized_vertices {
[12:09:25] [INFO] [dku.utils]  -         x: 0.9973958134651184
[12:09:25] [INFO] [dku.utils]  -         y: 0.008623555302619934
[12:09:25] [INFO] [dku.utils]  -       }
[12:09:25] [INFO] [dku.utils]  -       normalized_vertices {
[12:09:25] [INFO] [dku.utils]  -         x: 0.9973958134651184
[12:09:25] [INFO] [dku.utils]  -         y: 0.9851147532463074
[12:09:25] [INFO] [dku.utils]  -       }
[12:09:25] [INFO] [dku.utils]  -       normalized_vertices {
[12:09:25] [INFO] [dku.utils]  -         x: 0.005275096278637648
[12:09:25] [INFO] [dku.utils]  -         y: 0.9851147532463074
[12:09:25] [INFO] [dku.utils]  -       }
[12:09:25] [INFO] [dku.utils]  -     }
[12:09:25] [INFO] [dku.utils]  -   }
[12:09:25] [INFO] [dku.utils]  - }
[12:09:25] [INFO] [dku.utils]  - responses {
[12:09:25] [INFO] [dku.utils]  - *************** Recipe code failed **************
[12:09:25] [INFO] [dku.utils]  - }
[12:09:25] [INFO] [dku.utils]  - Begin Python stack
[12:09:25] [INFO] [dku.utils]  - responses {
[12:09:25] [INFO] [dku.utils]  - Traceback (most recent call last):
[12:09:25] [INFO] [dku.utils]  - }
[12:09:25] [INFO] [dku.utils]  -   File "/Users/alexandrecombessie/Library/DataScienceStudio/dss_home/code-envs/python/plugin_google-cloud-vision_managed_2/lib/python3.6/site-packages/proto/message.py", line 520, in __getattr__
[12:09:25] [INFO] [dku.utils]  -     pb_type = self._meta.fields[key].pb_type
[12:09:25] [INFO] [dku.utils]  - KeyError: 'DESCRIPTOR'
[12:09:25] [INFO] [dku.utils]  - During handling of the above exception, another exception occurred:
[12:09:25] [INFO] [dku.utils]  - Traceback (most recent call last):
[12:09:25] [INFO] [dku.utils]  -   File "/Users/alexandrecombessie/Library/DataScienceStudio/dss_home/jobs/TESTGOOGLEVISIONPLUGIN/Build_cloud_content__me__2020-10-13T10-09-12.241/compute_cloud_content_me/custom-python-recipe/pyouthtnvsUANhkXA/python-exec-wrapper.py", line 206, in <module>
[12:09:25] [INFO] [dku.utils]  -     exec(f.read())
[12:09:25] [INFO] [dku.utils]  -   File "<string>", line 58, in <module>
[12:09:25] [INFO] [dku.utils]  -   File "/Users/alexandrecombessie/Library/DataScienceStudio/dss_home/plugins/dev/google-cloud-vision/python-lib/api_parallelizer.py", line 201, in api_parallelizer
[12:09:25] [INFO] [dku.utils]  -     api_results.append(f.result())
[12:09:25] [INFO] [dku.utils]  -   File "/Users/alexandrecombessie/.pyenv/versions/3.6.10/lib/python3.6/concurrent/futures/_base.py", line 425, in result
[12:09:25] [INFO] [dku.utils]  -     return self.__get_result()
[12:09:25] [INFO] [dku.utils]  -   File "/Users/alexandrecombessie/.pyenv/versions/3.6.10/lib/python3.6/concurrent/futures/_base.py", line 384, in __get_result
[12:09:25] [INFO] [dku.utils]  -     raise self._exception
[12:09:25] [INFO] [dku.utils]  -   File "/Users/alexandrecombessie/.pyenv/versions/3.6.10/lib/python3.6/concurrent/futures/thread.py", line 56, in run
[12:09:25] [INFO] [dku.utils]  -     result = self.fn(*self.args, **self.kwargs)
[12:09:25] [INFO] [dku.utils]  -   File "/Users/alexandrecombessie/Library/DataScienceStudio/dss_home/plugins/dev/google-cloud-vision/python-lib/api_parallelizer.py", line 109, in api_call_batch
[12:09:25] [INFO] [dku.utils]  -     batch = batch_api_response_parser(batch=batch, response=response, api_column_names=api_column_names)
[12:09:25] [INFO] [dku.utils]  -   File "/Users/alexandrecombessie/Library/DataScienceStudio/dss_home/plugins/dev/google-cloud-vision/python-lib/google_vision_api_client.py", line 78, in batch_api_response_parser
[12:09:25] [INFO] [dku.utils]  -     response_dict = MessageToDict(response)
[12:09:25] [INFO] [dku.utils]  -   File "/Users/alexandrecombessie/Library/DataScienceStudio/dss_home/code-envs/python/plugin_google-cloud-vision_managed_2/lib/python3.6/site-packages/google/protobuf/json_format.py", line 175, in MessageToDict
[12:09:25] [INFO] [dku.utils]  -     return printer._MessageToJsonObject(message)
[12:09:25] [INFO] [dku.utils]  -   File "/Users/alexandrecombessie/Library/DataScienceStudio/dss_home/code-envs/python/plugin_google-cloud-vision_managed_2/lib/python3.6/site-packages/google/protobuf/json_format.py", line 209, in _MessageToJsonObject
[12:09:25] [INFO] [dku.utils]  -     message_descriptor = message.DESCRIPTOR
[12:09:25] [INFO] [dku.utils]  -   File "/Users/alexandrecombessie/Library/DataScienceStudio/dss_home/code-envs/python/plugin_google-cloud-vision_managed_2/lib/python3.6/site-packages/proto/message.py", line 525, in __getattr__
[12:09:25] [INFO] [dku.utils]  -     raise AttributeError(str(ex))
[12:09:25] [INFO] [dku.utils]  - AttributeError: 'DESCRIPTOR'

I read other issues, and it seems this bug is linked to 2 other issues: #60 #58

Metadata

Metadata

Assignees

Labels

status: investigatingThe issue is under investigation, which is determined to be non-trivial.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions