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

assignments of dict list is not supported for repeated field #135

Closed
arithmetic1728 opened this issue Sep 23, 2020 · 2 comments
Closed

assignments of dict list is not supported for repeated field #135

arithmetic1728 opened this issue Sep 23, 2020 · 2 comments
Assignees
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@arithmetic1728
Copy link

How to reproduce:

  1. Clone https://github.com/googleapis/python-vision, switch to proto_issue branch, then install it locally.
  2. Run the following sample.
from google.cloud import vision_v1
import proto
import json

request = dict(image=vision_v1.Image(content=b"content"))
batch_req = vision_v1.BatchAnnotateImagesRequest()

# This works (converting the dict to AnnotateImageRequest first, then form a list)
# batch_req.requests = [vision_v1.AnnotateImageRequest(request)]

# This throws exception (assigning the list of dict directly)
batch_req.requests = [request]

The last line throws the following exceptions:

TypeError: Parameter to MergeFrom() must be instance of same class: expected google.cloud.vision.v1.Image got Image.
@software-dov software-dov added 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. labels Sep 23, 2020
@danoscarmike danoscarmike added priority: p2 Moderately-important priority. Fix may not be included in next release. and removed priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. labels Sep 24, 2020
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. and removed 🚨 This issue needs some love. 🚨 labels Dec 23, 2020
@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Mar 23, 2021
@software-dov software-dov added priority: p3 Desirable enhancement or fix. May not be included in next release. and removed priority: p2 Moderately-important priority. Fix may not be included in next release. labels Apr 12, 2021
@software-dov
Copy link
Contributor

The workaround is to not assign repeated fields from lists of dicts.

The following should work:

from google.cloud import vision_v1

request = dict(image=vision_v1.Image(content=b"content"))
batch_req = vision_v1.BatchAnnotateImagesRequest()
batch_req.requests = [request]

Or to use the indirect method described in the issue text above.

Dropping priority to P3 since workarounds exist.

@yoshi-automation yoshi-automation removed the 🚨 This issue needs some love. label Apr 14, 2021
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. and removed 🚨 This issue needs some love. labels Nov 3, 2021
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. and removed 🚨 This issue needs some love. labels May 7, 2022
@parthea
Copy link
Contributor

parthea commented Mar 16, 2023

I can no longer reproduce this issue. Please open a new issue if you're still experiencing the problem.

@parthea parthea closed this as completed Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in 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