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

Vision: Operation returned from 'purge_product: raises TypeError in 'done'. #9150

Closed
dizcology opened this issue Aug 30, 2019 · 10 comments
Closed
Assignees
Labels
api: vision Issues related to the Cloud Vision API. external This issue is blocked on a bug with the actual product. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@dizcology
Copy link
Contributor

Environment details

  1. Vision API, Product Search, Purge Product
  2. OSX
  3. 2.7.14
  4. google-cloud-vision 0.39.0

Steps to reproduce

  1. Run tests or either of the purge product samples from this PR: Purge products GoogleCloudPlatform/python-docs-samples#2349
  2. The LRO fails at operation.done()

Code example

see PR linked above.

Stack trace

Traceback (most recent call last):
  File "/Users/yuhanliu/projects/dpe-github/python-docs-samples/vision/cloud-client/product_search/product_in_product_set_management_test.py", line 88, in test_purge_products_in_product_set
    PROJECT_ID, LOCATION, PRODUCT_SET_ID, force=True)
  File "/Users/yuhanliu/projects/dpe-github/python-docs-samples/vision/cloud-client/product_search/product_in_product_set_management.py", line 153, in purge_products_in_product_set
    if operation.done():
  File "/Users/yuhanliu/.virtualenvs/vision-ga/lib/python2.7/site-packages/google/api_core/operation.py", line 162, in done
    self._refresh_and_update()
  File "/Users/yuhanliu/.virtualenvs/vision-ga/lib/python2.7/site-packages/google/api_core/operation.py", line 154, in _refresh_and_update
    self._set_result_from_operation()
  File "/Users/yuhanliu/.virtualenvs/vision-ga/lib/python2.7/site-packages/google/api_core/operation.py", line 131, in _set_result_from_operation
    self._result_type, self._operation.response
  File "/Users/yuhanliu/.virtualenvs/vision-ga/lib/python2.7/site-packages/google/api_core/protobuf_helpers.py", line 69, in from_any_pb
    any_pb.__class__.__name__, pb_type.__name__
TypeError: Could not convert Any to Empty
@busunkim96 busunkim96 added api: vision Issues related to the Cloud Vision API. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. labels Aug 30, 2019
@tseaver tseaver changed the title Vision API Product Search Purge Product: TypeError: Could not convert Any to Empty Vision: Operattion returned from 'purge_product: raises TypeError in 'done'. Aug 30, 2019
@tseaver
Copy link
Contributor

tseaver commented Aug 30, 2019

@dizcology At the point that the exception is raised, can you print out the repr of self.operation.response?

@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Aug 31, 2019
@dizcology
Copy link
Contributor Author

Thanks @tseaver

When the exception is raised I got this:

ipdb> pp self.operation.response
type_url: "type.googleapis.com/google.cloud.vision.v1.PurgeProductsRequest"
value: "\n-projects/rising-sea-112358/locations/us-west1\030\001 \001"

ipdb> pp type(self.operation.response)
<class 'google.protobuf.any_pb2.Any'>

it might be that the library was trying to convert the response to type Empty?

@tseaver
Copy link
Contributor

tseaver commented Sep 3, 2019

@dizcology Looks to me like the .proto for the PurgeProducts RPC is missing the comment markup to indicate the type of the response. E.g., see the .proto for the ImportProductSets RPC, which contains this line:

  // `Operation.response` contains `ImportProductSetsResponse`. (results)

@tseaver tseaver added external This issue is blocked on a bug with the actual product. and removed triage me I really want to be triaged. labels Sep 3, 2019
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Sep 3, 2019
@dizcology
Copy link
Contributor Author

Thanks @tseaver - does this mean that the comment markup is used in GAPIC library generation for specifying the message types?

@tseaver
Copy link
Contributor

tseaver commented Sep 3, 2019

@dizcology I'm not sure: the code which actually parses all that out (in repo https://github.com/googleapis/gapic-generator/) is too arcane for me to read.

@tseaver tseaver changed the title Vision: Operattion returned from 'purge_product: raises TypeError in 'done'. Vision: Operation returned from 'purge_product: raises TypeError in 'done'. Sep 4, 2019
@tseaver
Copy link
Contributor

tseaver commented Sep 4, 2019

@lukesneeringer, @busunkim96 Can one of you confirm that the comment in the .proto file is used to generate the response type for LRO-returning RPCs?

@tseaver tseaver removed the triage me I really want to be triaged. label Sep 4, 2019
@dizcology
Copy link
Contributor Author

Some more information:

Comparing with the import product set call (which also returns an LRO), I am seeing different _result_type on the LRO.

For import product set:

ipdb> pp operation._result_type
<class 'google.cloud.vision_v1.types.ImportProductSetsResponse'>

Whereas for purge product:

ipdb> pp operation._result_type
<class 'google.protobuf.empty_pb2.Empty'>

What I am having a hard time tracking down is how and where this _result_type is set.

@busunkim96
Copy link
Contributor

@dizcology Would you expect the response to be Empty here, or should it be one of the Responses?

@busunkim96
Copy link
Contributor

It looks like the return types are set in the GAPIC config:

https://github.com/googleapis/googleapis/blob/abea8146b9561efd7c408b4d2095f87509fb5e78/google/cloud/vision/v1/vision_gapic.yaml#L547-L566

There is also a way to specify return type via proto annotations using operation_info, but it doesn't look like the Vision protos do this.

I see other APIs with similar configurations for LROs that don't seem to have issues. 🤔

@busunkim96
Copy link
Contributor

This has been resolved with a change in the Backend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: vision Issues related to the Cloud Vision API. external This issue is blocked on a bug with the actual product. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

5 participants