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

ImageAnnotatorClient.text_detection retry bug! #31

Closed
TurnrDev opened this issue Jun 28, 2020 · 3 comments
Closed

ImageAnnotatorClient.text_detection retry bug! #31

TurnrDev opened this issue Jun 28, 2020 · 3 comments
Assignees
Labels
api: vision Issues related to the googleapis/python-vision API. priority: p2 Moderately-important priority. 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

@TurnrDev
Copy link

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Please run down the following list and make sure you've tried the usual "quick fixes":

If you are still having issues, please be sure to include as much information as possible:

Environment details

  • OS type and version: Arch Linux
  • Python version: 3.8.3
  • pip version: 20.1.1
  • google-cloud-vision version: 1.0.0

Steps to reproduce

  1. Try to call `ImageAnnotatorClient.text_detection(image, retry=5)
  2. Get error that int object is not callable. Something somewhere is doing retry()

Code example

See here

from google.cloud import vision
from google.cloud.vision import types
from google.oauth2 import service_account

class Image:
	
	def __init__(self, service_file, image_content=None, image_uri=None):
		self.google = vision.ImageAnnotatorClient(credentials=service_account.Credentials.from_service_account_file(
			service_file))
		
		self.image = types.Image()
		if image_content:
			self.image.content = image_content
		elif image_uri:
			self.image.source.image_uri = image_uri
		else:
			raise AttributeError('Please define either image_uri or image_content')
	
	def get_text(self):
		print("Requesting TEXT_DETECTION from Google Cloud API. This will cost us 0.0015 USD.")
		response = self.google.text_detection(image=self.image, retry=5)
		self.text_found = response.text_annotations

Stack trace

_________ test_answer[dutch_xp-https://cdn.discordapp.com/attachments/370708840850653184/726727557453447238/Screenshot_20200628-111544_Pokmon_GO.jpg-224399847] _________

test_name = 'dutch_xp', input = 'https://cdn.discordapp.com/attachments/370708840850653184/726727557453447238/Screenshot_20200628-111544_Pokmon_GO.jpg'
expected = 224399847

    @pytest.mark.parametrize("test_name,input,expected", options)
    def test_answer(test_name,input,expected):
>       assert func(input) == expected

test_profileself_total_xp.py:27: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_profileself_total_xp.py:6: in func
    foo.get_text()
PogoOCR/types.py:92: in get_text
    super().get_text()
PogoOCR/cloudvision.py:21: in get_text
    response = self.google.text_detection(image=self.image, retry=5)
env/lib/python3.8/site-packages/google/cloud/vision_helpers/decorators.py:101: in inner
    response = self.annotate_image(request, retry=retry, timeout=timeout)
env/lib/python3.8/site-packages/google/cloud/vision_helpers/__init__.py:72: in annotate_image
    r = self.batch_annotate_images([request], retry=retry, timeout=timeout)
env/lib/python3.8/site-packages/google/cloud/vision_v1/gapic/image_annotator_client.py:273: in batch_annotate_images
    return self._inner_api_calls["batch_annotate_images"](
env/lib/python3.8/site-packages/google/api_core/gapic_v1/method.py:130: in __call__
    wrapped_func = _apply_decorators(self._target, [retry, timeout_])
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

func = <function _wrap_unary_errors.<locals>.error_remapped_callable at 0x7f12e75ee040>, decorators = <filter object at 0x7f12e75b6460>

    def _apply_decorators(func, decorators):
        """Apply a list of decorators to a given function.
    
        ``decorators`` may contain items that are ``None`` or ``False`` which will
        be ignored.
        """
        decorators = filter(_is_not_none_or_false, reversed(decorators))
    
        for decorator in decorators:
>           func = decorator(func)
E           TypeError: 'int' object is not callable

env/lib/python3.8/site-packages/google/api_core/gapic_v1/method.py:45: TypeError

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

P.S Your docs are unreadable.

@product-auto-label product-auto-label bot added the api: vision Issues related to the googleapis/python-vision API. label Jun 28, 2020
TurnrDev pushed a commit to TrainerDex/PogoOCR that referenced this issue Jun 28, 2020
TurnrDev pushed a commit to TrainerDex/PogoOCR that referenced this issue Jun 28, 2020
@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Jun 29, 2020
@munkhuushmgl munkhuushmgl self-assigned this Jul 7, 2020
@munkhuushmgl munkhuushmgl added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. and removed 🚨 This issue needs some love. triage me I really want to be triaged. labels Jul 7, 2020
@munkhuushmgl
Copy link
Contributor

@TurnrDev I think this has been fixed by #29

@TurnrDev
Copy link
Author

Which release will this fix be available in?

@kokroo
Copy link

kokroo commented Mar 16, 2023

Getting the same error. This is still not fixed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: vision Issues related to the googleapis/python-vision API. priority: p2 Moderately-important priority. 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

4 participants