Test output
args = (requests {
image {
content: "\377\330\377\341?\376Exif\000\000MM\000*\000\000\000\010\000\013\001\017\000\002\0... type_: WEB_DETECTION
}
image_context {
web_detection_params {
include_geo_results: true
}
}
}
,)
kwargs = {'metadata': [('x-goog-api-client', 'gl-python/3.6.13 grpc/1.38.1 gax/1.31.0 gapic/2.4.0')]}
@six.wraps(callable_)
def error_remapped_callable(*args, **kwargs):
try:
return callable_(*args, **kwargs)
.nox/py-3-6/lib/python3.6/site-packages/google/api_core/grpc_helpers.py:67:
self = <grpc._channel.UnaryUnaryMultiCallable object at 0x7fb18c383cf8>
request = requests {
image {
content: "\377\330\377\341?\376Exif\000\000MM\000*\000\000\000\010\000\013\001\017\000\002\00...
type: WEB_DETECTION
}
image_context {
web_detection_params {
include_geo_results: true
}
}
}
timeout = None
metadata = [('x-goog-api-client', 'gl-python/3.6.13 grpc/1.38.1 gax/1.31.0 gapic/2.4.0')]
credentials = None, wait_for_ready = None, compression = None
def __call__(self,
request,
timeout=None,
metadata=None,
credentials=None,
wait_for_ready=None,
compression=None):
state, call, = self._blocking(request, timeout, metadata, credentials,
wait_for_ready, compression)
return _end_unary_response_blocking(state, call, False, None)
.nox/py-3-6/lib/python3.6/site-packages/grpc/_channel.py:946:
state = <grpc._channel._RPCState object at 0x7fb18c23a518>
call = <grpc._cython.cygrpc.SegregatedCall object at 0x7fb18c240b08>
with_call = False, deadline = None
def _end_unary_response_blocking(state, call, with_call, deadline):
if state.code is grpc.StatusCode.OK:
if with_call:
rendezvous = _MultiThreadedRendezvous(state, call, None, deadline)
return state.response, rendezvous
else:
return state.response
else:
raise _InactiveRpcError(state)
E grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
E status = StatusCode.UNAUTHENTICATED
E details = "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project."
E debug_error_string = "{"created":"@1626167042.296343632","description":"Error received from peer ipv4:74.125.142.95:443","file":"src/core/lib/surface/call.cc","file_line":1066,"grpc_message":"Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.","grpc_status":16}"
E >
.nox/py-3-6/lib/python3.6/site-packages/grpc/_channel.py:849: _InactiveRpcError
The above exception was the direct cause of the following exception:
capsys = <_pytest.capture.CaptureFixture object at 0x7fb18c27e128>
def test_detect_web_with_geo(capsys):
file_name = os.path.join(
os.path.dirname(__file__),
'resources/city.jpg')
@backoff.on_exception(
backoff.expo, Exception, max_time=60, giveup=only_sample_error)
def run_sample():
detect.web_entities_include_geo_results(file_name)
detect_test.py:194:
.nox/py-3-6/lib/python3.6/site-packages/backoff/_sync.py:94: in retry
ret = target(*args, **kwargs)
detect_test.py:192: in run_sample
detect.web_entities_include_geo_results(file_name)
detect.py:613: in web_entities_include_geo_results
response = client.web_detection(image=image, image_context=image_context)
../../../google/cloud/vision_helpers/decorators.py:113: in inner
request, retry=retry, timeout=timeout, metadata=metadata
../../../google/cloud/vision_helpers/init.py:77: in annotate_image
requests=[request], retry=retry, timeout=timeout, metadata=metadata
../../../google/cloud/vision_v1/services/image_annotator/client.py:434: in batch_annotate_images
response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
.nox/py-3-6/lib/python3.6/site-packages/google/api_core/gapic_v1/method.py:145: in call
return wrapped_func(*args, **kwargs)
.nox/py-3-6/lib/python3.6/site-packages/google/api_core/grpc_helpers.py:69: in error_remapped_callable
six.raise_from(exceptions.from_grpc_error(exc), exc)
value = None
from_value = <_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAUTHENTICATED
details = "Request had invalid a...entication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.","grpc_status":16}"
???
E google.api_core.exceptions.Unauthenticated: 401 Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
:3: Unauthenticated
Apparently the ImageSource attribute of vision requests should allow "A publicly-accessible image HTTP/HTTPS URL"
https://cloud.google.com/vision/docs/reference/rpc/google.cloud.vision.v1#google.cloud.vision.v1.Image
https://googleapis.dev/python/vision/latest/vision_v1/types.html
Here, the Google API core seems to only expect a google storage uri link
Environment details
- OS type and version: macOS Big Sur 11.0.1
- Python version: 3.9.1`
- pip version: 20.3.3
google-cloud-vision
version: 2.0.0
Code example
from google.cloud import vision
client = vision.ImageAnnotatorClient()
requests = []
labels = []
# I had an array of image urls in a json file, but using the same url over and over gives the same error
images = range(100)
for img in images:
source = {"image_uri": "https://images.unsplash.com/photo-1544845120-288673aefccc?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max&ixid=eyJhcHBfaWQiOjEyMDd9"}
image = {"source": source}
features = [
{"type_": vision.Feature.Type.LABEL_DETECTION}
]
requests.append({"image": image, "features": features})
# The max number of responses to output in each JSON file
batch_size = 2 # max batch size
gcs_destination = {"uri": "gs://imagesort/results/"}
output_config = {"gcs_destination": gcs_destination,
"batch_size": batch_size}
operation = client.async_batch_annotate_images(
requests=requests, output_config=output_config)
print("Waiting for operation to complete...")
response = operation.result(90)
Stack trace
Traceback (most recent call last):
File "/Users/georgeoconnor/imagesort/env/lib/python3.9/site-packages/google/api_core/grpc_helpers.py", line 57, in error_remapped_callable
return callable_(*args, **kwargs)
File "/Users/georgeoconnor/imagesort/env/lib/python3.9/site-packages/grpc/_channel.py", line 923, in __call__
return _end_unary_response_blocking(state, call, False, None)
File "/Users/georgeoconnor/imagesort/env/lib/python3.9/site-packages/grpc/_channel.py", line 826, in _end_unary_response_blocking
raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.INVALID_ARGUMENT
details = "Invalid gcs prefix provided in request image.source.image_uri field. Valid prefixes must start with 'gs://'."
debug_error_string = "{"created":"@1611278568.485631000","description":"Error received from peer ipv6:[2404:6800:4015:800::200a]:443","file":"src/core/lib/surface/call.cc","file_line":1068,"grpc_message":"Invalid gcs prefix provided in request image.source.image_uri field. Valid prefixes must start with 'gs://'.","grpc_status":3}"
>
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/georgeoconnor/imagesort/test.py", line 22, in <module>
operation = client.async_batch_annotate_images(
File "/Users/georgeoconnor/imagesort/env/lib/python3.9/site-packages/google/cloud/vision_v1/services/image_annotator/client.py", line 493, in async_batch_annotate_images
response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
File "/Users/georgeoconnor/imagesort/env/lib/python3.9/site-packages/google/api_core/gapic_v1/method.py", line 145, in __call__
return wrapped_func(*args, **kwargs)
File "/Users/georgeoconnor/imagesort/env/lib/python3.9/site-packages/google/api_core/retry.py", line 281, in retry_wrapped_func
return retry_target(
File "/Users/georgeoconnor/imagesort/env/lib/python3.9/site-packages/google/api_core/retry.py", line 184, in retry_target
return target()
File "/Users/georgeoconnor/imagesort/env/lib/python3.9/site-packages/google/api_core/grpc_helpers.py", line 59, in error_remapped_callable
six.raise_from(exceptions.from_grpc_error(exc), exc)
File "<string>", line 3, in raise_from
google.api_core.exceptions.InvalidArgument: 400 Invalid gcs prefix provided in request image.source.image_uri field. Valid prefixes must start with 'gs://'.
I was wondering how the calls can be made asynchronous without using the batch functionality? (with something like asyncio)
This test failed!
To configure my behavior, see the Build Cop Bot documentation.
If I'm commenting on this issue too often, add the buildcop: quiet
label and
I will stop commenting.
commit: ab25338
buildURL: Build Status, Sponge
status: failed
Test output
target = functools.partial(>)
predicate = .if_exception_type_predicate at 0x7f791c1f3840>
sleep_generator =
deadline = 420, on_error = None
def retry_target(target, predicate, sleep_generator, deadline, on_error=None):
"""Call a function and retry if it fails.
This is the lowest-level retry helper. Generally, you'll use the
higher-level retry helper :class:`Retry`.
Args:
target(Callable): The function to call and retry. This must be a
nullary function - apply arguments with `functools.partial`.
predicate (Callable[Exception]): A callable used to determine if an
exception raised by the target should be considered retryable.
It should return True to retry or False otherwise.
sleep_generator (Iterable[float]): An infinite iterator that determines
how long to sleep between retries.
deadline (float): How long to keep retrying the target. The last sleep
period is shortened as necessary, so that the last retry runs at
``deadline`` (and not considerably beyond it).
on_error (Callable[Exception]): A function to call while processing a
retryable exception. Any error raised by this function will *not*
be caught.
Returns:
Any: the return value of the target function.
Raises:
google.api_core.RetryError: If the deadline is exceeded while retrying.
ValueError: If the sleep generator stops yielding values.
Exception: If the target raises a method that isn't retryable.
"""
if deadline is not None:
deadline_datetime = datetime_helpers.utcnow() + datetime.timedelta(
seconds=deadline
)
else:
deadline_datetime = None
last_exc = None
for sleep in sleep_generator:
try:
.nox/py-3-6/lib/python3.6/site-packages/google/api_core/retry.py:184:
self = <google.api_core.operation.Operation object at 0x7f791973a7b8>
retry = <google.api_core.retry.Retry object at 0x7f791c179e80>
def _done_or_raise(self, retry=DEFAULT_RETRY):
"""Check if the future is done and raise if it's not."""
kwargs = {} if retry is DEFAULT_RETRY else {"retry": retry}
if not self.done(**kwargs):
raise _OperationNotComplete()
E google.api_core.future.polling._OperationNotComplete
.nox/py-3-6/lib/python3.6/site-packages/google/api_core/future/polling.py:86: _OperationNotComplete
The above exception was the direct cause of the following exception:
self = <google.api_core.operation.Operation object at 0x7f791973a7b8>
timeout = 420, retry = <google.api_core.retry.Retry object at 0x7f791c179e80>
def _blocking_poll(self, timeout=None, retry=DEFAULT_RETRY):
"""Poll and wait for the Future to be resolved.
Args:
timeout (int):
How long (in seconds) to wait for the operation to complete.
If None, wait indefinitely.
"""
if self._result_set:
return
retry_ = self._retry.with_deadline(timeout)
try:
kwargs = {} if retry is DEFAULT_RETRY else {"retry": retry}
retry_(self._done_or_raise)(**kwargs)
.nox/py-3-6/lib/python3.6/site-packages/google/api_core/future/polling.py:107:
args = (), kwargs = {}
target = functools.partial(<bound method PollingFuture._done_or_raise of <google.api_core.operation.Operation object at 0x7f791973a7b8>>)
sleep_generator = <generator object exponential_sleep_generator at 0x7f79196a2468>
@general_helpers.wraps(func)
def retry_wrapped_func(*args, **kwargs):
"""A wrapper that calls target function with retry."""
target = functools.partial(func, *args, **kwargs)
sleep_generator = exponential_sleep_generator(
self._initial, self._maximum, multiplier=self._multiplier
)
return retry_target(
target,
self._predicate,
sleep_generator,
self._deadline,
.nox/py-3-6/lib/python3.6/site-packages/google/api_core/retry.py:286:
target = functools.partial(<bound method PollingFuture._done_or_raise of <google.api_core.operation.Operation object at 0x7f791973a7b8>>)
predicate = <function if_exception_type..if_exception_type_predicate at 0x7f791c1f3840>
sleep_generator = <generator object exponential_sleep_generator at 0x7f79196a2468>
deadline = 420, on_error = None
def retry_target(target, predicate, sleep_generator, deadline, on_error=None):
"""Call a function and retry if it fails.
This is the lowest-level retry helper. Generally, you'll use the
higher-level retry helper :class:`Retry`.
Args:
target(Callable): The function to call and retry. This must be a
nullary function - apply arguments with `functools.partial`.
predicate (Callable[Exception]): A callable used to determine if an
exception raised by the target should be considered retryable.
It should return True to retry or False otherwise.
sleep_generator (Iterable[float]): An infinite iterator that determines
how long to sleep between retries.
deadline (float): How long to keep retrying the target. The last sleep
period is shortened as necessary, so that the last retry runs at
``deadline`` (and not considerably beyond it).
on_error (Callable[Exception]): A function to call while processing a
retryable exception. Any error raised by this function will *not*
be caught.
Returns:
Any: the return value of the target function.
Raises:
google.api_core.RetryError: If the deadline is exceeded while retrying.
ValueError: If the sleep generator stops yielding values.
Exception: If the target raises a method that isn't retryable.
"""
if deadline is not None:
deadline_datetime = datetime_helpers.utcnow() + datetime.timedelta(
seconds=deadline
)
else:
deadline_datetime = None
last_exc = None
for sleep in sleep_generator:
try:
return target()
# pylint: disable=broad-except
# This function explicitly must deal with broad exceptions.
except Exception as exc:
if not predicate(exc):
raise
last_exc = exc
if on_error is not None:
on_error(exc)
now = datetime_helpers.utcnow()
if deadline_datetime is not None:
if deadline_datetime <= now:
six.raise_from(
exceptions.RetryError(
"Deadline of {:.1f}s exceeded while calling {}".format(
deadline, target
),
last_exc,
),
.nox/py-3-6/lib/python3.6/site-packages/google/api_core/retry.py:206:
value = None, from_value = _OperationNotComplete()
???
E google.api_core.exceptions.RetryError: Deadline of 420.0s exceeded while calling functools.partial(<bound method PollingFuture._done_or_raise of <google.api_core.operation.Operation object at 0x7f791973a7b8>>), last exception:
:3: RetryError
During handling of the above exception, another exception occurred:
capsys = <_pytest.capture.CaptureFixture object at 0x7f79196a8a20>
def test_async_detect_document(capsys):
storage_client = storage.Client()
bucket = storage_client.get_bucket(BUCKET)
if len(list(bucket.list_blobs(prefix=OUTPUT_PREFIX))) > 0:
for blob in bucket.list_blobs(prefix=OUTPUT_PREFIX):
blob.delete()
assert len(list(bucket.list_blobs(prefix=OUTPUT_PREFIX))) == 0
uri = 'gs://{}/vision/document/custom_0773375000_title_only.pdf'.format(
ASSET_BUCKET)
detect.async_detect_document(
gcs_source_uri=uri,
gcs_destination_uri=GCS_DESTINATION_URI)
detect_test.py:258:
detect.py:840: in async_detect_document
operation.result(timeout=420)
.nox/py-3-6/lib/python3.6/site-packages/google/api_core/future/polling.py:129: in result
self._blocking_poll(timeout=timeout, **kwargs)
self = <google.api_core.operation.Operation object at 0x7f791973a7b8>
timeout = 420, retry = <google.api_core.retry.Retry object at 0x7f791c179e80>
def _blocking_poll(self, timeout=None, retry=DEFAULT_RETRY):
"""Poll and wait for the Future to be resolved.
Args:
timeout (int):
How long (in seconds) to wait for the operation to complete.
If None, wait indefinitely.
"""
if self._result_set:
return
retry_ = self._retry.with_deadline(timeout)
try:
kwargs = {} if retry is DEFAULT_RETRY else {"retry": retry}
retry_(self._done_or_raise)(**kwargs)
except exceptions.RetryError:
raise concurrent.futures.TimeoutError(
"Operation did not complete within the designated " "timeout."
E concurrent.futures._base.TimeoutError: Operation did not complete within the designated timeout.
.nox/py-3-6/lib/python3.6/site-packages/google/api_core/future/polling.py:110: TimeoutError
Issue
Now I am using google cloud (behind proxy) vision to detect text in the image.
Environment variables
export HTTP_PROXY="http://username:[email protected]:8080"
export HTTPS_PROXY="http://username:[email protected]:8080"
export REQUESTS_CA_BUNDLE=/home/test/certificate.cer
export SSL_CERT_FILE=/home/test/certificate.cer
My code
os.environ['GOOGLE_APPLICATION_CREDENTIALS']='./json.json'
def google_ocr(image_file):
try:
# Instantiates a client
client = vision.ImageAnnotatorClient()
# Loads the image into memory
with io.open(image_file, 'rb') as image_file:
content = image_file.read()
image = types.Image(content=content)
# Performs label detection on the image file
response = client.text_detection(image=image,
image_context={"language_hints": ["en"]},)
annotations = response.text_annotations
if len(annotations) > 0:
text = annotations[0].description
else:
text = ''
print(text)
return text
except Exception as e:
print(e)
raise Exception
image = "./IMG.PNG"
print(google_ocr(image))
But there following error:
D0904 17:14:26.604910755 25602 ev_posix.cc:175] Using polling engine: epollex
D0904 17:14:26.604977752 25602 lb_policy_registry.cc:40] registering LB policy factory for "grpclb"
D0904 17:14:26.604984805 25602 lb_policy_registry.cc:40] registering LB policy factory for "cds_experimental"
D0904 17:14:26.604992289 25602 lb_policy_registry.cc:40] registering LB policy factory for "eds_experimental"
D0904 17:14:26.604996046 25602 lb_policy_registry.cc:40] registering LB policy factory for "lrs_experimental"
D0904 17:14:26.604999302 25602 lb_policy_registry.cc:40] registering LB policy factory for "priority_experimental"
D0904 17:14:26.605002428 25602 lb_policy_registry.cc:40] registering LB policy factory for "weighted_target_experimental"
D0904 17:14:26.605006536 25602 lb_policy_registry.cc:40] registering LB policy factory for "xds_routing_experimental"
D0904 17:14:26.605008991 25602 lb_policy_registry.cc:40] registering LB policy factory for "pick_first"
D0904 17:14:26.605012417 25602 lb_policy_registry.cc:40] registering LB policy factory for "round_robin"
D0904 17:14:26.605014902 25602 dns_resolver_ares.cc:507] Using ares dns resolver
I0904 17:14:46.652944635 25632 subchannel.cc:1033] Connect failed: {"created":"@1599214486.652892116","description":"Failed to connect to remote host: FD Shutdown","file":"src/core/lib/iomgr/lockfree_event.cc","file_line":195,"os_error":"Timeout occurred","referenced_errors":[{"created":"@1599214486.652880073","description":"connect() timed out","file":"src/core/lib/iomgr/tcp_client_posix.cc","file_line":113}],"target_address":"ipv4:172.217.26.138:443"}
I0904 17:14:46.653047319 25632 subchannel.cc:1033] Connect failed: {"created":"@1599214486.653027010","description":"Network is unreachable","errno":101,"file":"src/core/lib/iomgr/tcp_client_posix.cc","file_line":296,"os_error":"Network is unreachable","syscall":"connect","target_address":"ipv6:[2404:6800:4005:808::200a]:443"}
I0904 17:14:46.653062938 25632 subchannel.cc:970] Subchannel 0x1636680: Retry immediately
I0904 17:14:46.653069190 25632 subchannel.cc:997] Failed to connect to channel, retrying
503 failed to connect to all addresses
Traceback (most recent call last):
File "/home/atom_test/.local/lib/python3.6/site-packages/google/api_core/grpc_helpers.py", line 57, in error_remapped_callable
return callable_(*args, **kwargs)
File "/home/atom_test/.local/lib/python3.6/site-packages/grpc/_channel.py", line 826, in __call__
return _end_unary_response_blocking(state, call, False, None)
File "/home/atom_test/.local/lib/python3.6/site-packages/grpc/_channel.py", line 729, in _end_unary_response_blocking
raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "failed to connect to all addresses"
debug_error_string = "{"created":"@1599214486.653060353","description":"Failed to pick subchannel","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":4090,"referenced_errors":[{"created":"@1599214486.653058420","description":"failed to connect to all addresses","file":"src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc","file_line":394,"grpc_status":14}]}"
Here is network package capture
17:14:26.654152 IP System-Product-Name.51852 > hkg12s21-in-f10.1e100.net.https: Flags [S], seq 2069919229, win 64240, options [mss 1460,sackOK,TS val 2735503221 ecr 0,nop,wscale 7], length 0
17:14:27.667848 IP System-Product-Name.51852 > hkg12s21-in-f10.1e100.net.https: Flags [S], seq 2069919229, win 64240, options [mss 1460,sackOK,TS val 2735504235 ecr 0,nop,wscale 7], length 0
17:14:29.683836 IP System-Product-Name.51852 > hkg12s21-in-f10.1e100.net.https: Flags [S], seq 2069919229, win 64240, options [mss 1460,sackOK,TS val 2735506251 ecr 0,nop,wscale 7], length 0
17:14:33.811859 IP System-Product-Name.51852 > hkg12s21-in-f10.1e100.net.https: Flags [S], seq 2069919229, win 64240, options [mss 1460,sackOK,TS val 2735510379 ecr 0,nop,wscale 7], length 0
17:14:42.004065 IP System-Product-Name.51852 > hkg12s21-in-f10.1e100.net.https: Flags [S], seq 2069919229, win 64240, options [mss 1460,sackOK,TS val 2735518571 ecr 0,nop,wscale 7], length 0
17:14:46.653117 IP System-Product-Name.52098 > hkg12s21-in-f10.1e100.net.https: Flags [S], seq 3739133444, win 64240, options [mss 1460,sackOK,TS val 2735523220 ecr 0,nop,wscale 7], length 0
The oauth2.googleapis.com
was redirect to hkg12s21-in-f10.1e100.net
When I am using curl with the certificate, it can connect to the host hkg12s21-in-f10.1e100.net
. Just with python code, it does not work.
test@System-Product-Name:~$ curl --request POST https://hkg12s21-in-f10.1e100.net --cacert /home/test/certificate.cer
<!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
<title>Error 404 (Not Found)!!1</title>
<style>
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
</style>
<a href=//www.google.com/><span id=logo aria-label=Google></span></a>
<p><b>404.</b> <ins>Thatโs an error.</ins>
<p>The requested URL <code>/</code> was not found on this server. <ins>Thatโs all we know.</ins>
ImportError: cannot import name 'types'
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
`def async_detect_document(gcs_source_uri, gcs_destination_uri):
"""OCR with PDF/TIFF as source files on GCS"""
# Supported mime_types are: 'application/pdf' and 'image/tiff'
mime_type = "application/pdf"
# How many pages should be grouped into each json output file.
batch_size = 10
client = vision.ImageAnnotatorClient()
text_feature = vision.Feature(type_=vision.Feature.Type.DOCUMENT_TEXT_DETECTION)
image_context = vision.ImageContext(
text_detection_params=vision.TextDetectionParams(disable_orientation_detection=True)
)
features = [text_feature]
gcs_source = vision.GcsSource(uri=gcs_source_uri)
input_config = vision.InputConfig(gcs_source=gcs_source, mime_type=mime_type)
gcs_destination = vision.GcsDestination(uri=gcs_destination_uri)
output_config = vision.OutputConfig(gcs_destination=gcs_destination, batch_size=batch_size)
async_request = vision.AsyncAnnotateFileRequest(
features=features,
image_context=image_context,
input_config=input_config,
output_config=output_config,
)`
image_context = vision.ImageContext( text_detection_params=vision.TextDetectionParams(disable_orientation_detection=True) )
I get the following error, because of the line above.
`Traceback (most recent call last):
File ".\spike\google_ocr.py", line 84, in
"gs://manan-ocr-testing/tt",
File ".\spike\google_ocr.py", line 24, in async_detect_document
text_detection_params=vision.TextDetectionParams(mapping={"lineFilter": {"paths": ["confidence", "mergedText"]}})
File "C:\Users\manan.shah.virtualenvs\document_analysis-Q6JswU4T\lib\site-packages\proto\message.py", line 503, in init
"Unknown field for {}: {}".format(self.class.name, key)
ValueError: Unknown field for TextDetectionParams: lineFilter
PS C:\git\ds\document_analysis> pipenv run python .\spike\google_ocr.py
Loading .env environment variablesโฆ
Traceback (most recent call last):
File "C:\Users\manan.shah.virtualenvs\document_analysis-Q6JswU4T\lib\site-packages\proto\message.py", line 497, in init
pb_type = self._meta.fields[key].pb_type
KeyError: 'disable_orientation_detection'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".\spike\google_ocr.py", line 84, in
"gs://manan-ocr-testing/tt",
File ".\spike\google_ocr.py", line 24, in async_detect_document
text_detection_params=vision.TextDetectionParams(disable_orientation_detection=True)
File "C:\Users\manan.shah.virtualenvs\document_analysis-Q6JswU4T\lib\site-packages\proto\message.py", line 503, in init
"Unknown field for {}: {}".format(self.class.name, key)
ValueError: Unknown field for TextDetectionParams: disable_orientation_detection`
class TextDetectionParams(proto.Message):
Attributes:
enable_text_detection_confidence_score (bool):
By default, Cloud Vision API only includes confidence score
for DOCUMENT_TEXT_DETECTION result. Set the flag to true to
include confidence score for TEXT_DETECTION as well.
enable_text_detection_confidence_score = proto.Field(proto.BOOL, number=9)
When I look at the documentation, there is not a disable_orientation_detection property within TextDetectionParams, although the google cloud vision API mentions it here.
https://cloud.google.com/vision/docs/reference/rest/v1p4beta1/ImageContext#TextDetectionParams
Any ideas what am I missing here?
Environment details
- OS type and version: WIndows
- Python version: 3.6.8
- pip version: 20.2.3
google-cloud-vision
version: 2.3.0
Thanks!
Was updating some samples and found when calling the Google Cloud Vision API with the python client library which has some handwritten helper methods making it a partial GAPIC library, that if the users passes a URL that the API can't reach, the API returns an error message, but the client library doesn't throw
the error rather returns it as part of the response.
Call request: response = client.text_detection(image=image)
If you examine the response object from the api you'll find this:
error {
code: 3
message: "The URL does not appear to be accessible by us. Please double check or download the content and pass it in."
}
Seems like we should throw this error.
Related PR that I discovered this in: GoogleCloudPlatform/python-docs-samples#2569
I am currently implementing a GCloud function applying the vision API to given images. Currently, the function is running for about 30 seconds (5 images) using the async_batch_annotate_images. My goal was to call the async method to leave the function early to save computing time.
This is the last part of my code, everything works so far:
# loop over the images and prepare them
source = {'image_uri': input_image_uri}
image = {'source': source}
type_ = enums.Feature.Type.TEXT_DETECTION
features_element = {'type': type_}
features = [features_element]
requests_element = {'image': image, 'features': features}
requests.append(requests_element)
gcs_destination = {'uri': output_uri}
output_config = {'gcs_destination': gcs_destination, 'batch_size': 1}
client.async_batch_annotate_images(requests, output_config)
return True
How is it possible to call the async method and terminate the function right after the call to save computing time?
(@tseaver maybe you could help?)
This script was working fine just few days ago.. Suddenly giving an error now..
import google-cloud sdk
from google.cloud import vision
client = vision.ImageAnnotatorClient()
AttributeError: module 'google.cloud.vision' has no attribute 'ImageAnnotatorClient'
In jupyter notebook:
Package got installed successfully but still it is giving me the following error:
I tried reinstalling the library but sill couldn't resolve this issue.
(When I am doing the same in Pycharm, there is no issue)
This issue is also uploaded to Stack Overflow at https://stackoverflow.com/questions/60943745/google-cloud-server-forced-close-when-querying-for-object-localization.
I sometimes get the error
google.api_core.exceptions.ServiceUnavailable: 503 Getting metadata from plugin failed with error: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))
Upon running
# server/classifiers/gcloud/identifier.py
import io
import os
import json
from google.cloud import vision
from google.cloud.vision import types
from collections import Counter
client = vision.ImageAnnotatorClient()
with io.open("config/labels.json", "r") as f:
LABELS = json.loads(f.read())
def identify_from_string(blob):
image = types.Image(content=blob)
response = client.object_localization(image=image)
labels = response.localized_object_annotations
objects = set(label.name for label in labels)
c = Counter()
for label, s in LABELS.items():
for ob in objects:
if ob in s:
c[label] += s[ob]
if not c: print("Sorry, the server is currently full.")
return str(c)
With the error thrown on line with response = client.object_localization(image=image)
. On my app.py
, I have
# server/app.py
import os
import json
from server.classifiers.gcloud import identifier
from flask import Flask, Response, render_template, send_file, request
@app.route('/classify', methods=['POST'])
def classify():
app.logger.info("Got image to /classify")
file = request.files['image']
blob = file.read()
results = identifier.identify_from_string(blob)
return Response(response=json.dumps(dict(response)), status=200)
Where the server.classifiers.gcloud.identifier points to the file above. Occasionally, the issue suddenly goes away. Is there a way around this?
Environment details
- OS type and version: macOS Mojave 10.14.6
- Python version: Python 3.8.5
- pip version: pip 20.2.3
- google-cloud-vision version: 2.0.0
Steps to reproduce
- Run the example usage code: https://github.com/googleapis/python-vision#example-usage
- Get error
'google.cloud.vision' has no attribute 'enums'
Guessing this has to do with: https://googleapis.dev/python/vision/latest/UPGRADING.html
Code example
from google.cloud import vision
client = vision.ImageAnnotatorClient()
response = client.annotate_image({
'image': {'source': {'image_uri': 'gs://my-test-bucket/image.jpg'}},
'features': [{'type': vision.enums.Feature.Type.FACE_DETECTION}],
})
Stack trace
Traceback (most recent call last):
File "example.py", line 6, in <module>
'features': [{'type': vision.enums.Feature.Type.FACE_DETECTION}],
AttributeError: module 'google.cloud.vision' has no attribute 'enums'
how to fix: Instance of 'ImageAnnotatorClient' has no 'logo_detection' member?
I have spent days trying to debug an "illegal instruction" on import google.cloud.vision on a RaspberryPi ARMv6, making sure everything was updated, correct versions, etc. to no avail, and cannot find a statement if or if not Raspberry Pi ARMv6 is supported anywhere on cloud.google.com developer documentation. There are some two year old frustrated user posts on the net saying "no longer supported" but nothing official anywhere. Would have been nice under the Linux/Debian tutorials and "Getting Started" stuff.
Since lots of Raspberry Pi with PiCamera users are trying google.cloud.vision, you all could really help them avoid buying the wrong Pi.
If not supported, could you all put "Note: Raspberry Pi ARMv6 is not supported by google.cloud" in the README.md for python-vision?
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: Mac 11.0.1
- Python version:
python --version
3.7.9
- pip version:
pip --version
20.2.4
google-cloud-vision
version: pip show google-cloud-vision
Name: google-cloud-vision
Version: 2.0.0
Summary: Cloud Vision API API client library
Home-page: https://github.com/googleapis/python-vision
Author: Google LLC
Author-email: [email protected]
License: Apache 2.0
Location: /Users/davidchen/repo/gchannel/venv/lib/python3.7/site-packages
Requires: google-api-core, proto-plus, libcst
Steps to reproduce
- open python
- import vision sdk
Code example
(venv) โ src git:(fix-smart-animation) โ python
Python 3.7.9 (default, Nov 12 2020, 11:53:23)
[Clang 11.0.3 (clang-1103.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import google.cloud.vision
[1] 67548 segmentation fault python
Stack trace
google-api-core[grpc]==1.23.0 # via google-api-python-client, google-cloud-core, google-cloud-datastore, google-cloud-pubsub, google-cloud-translate, google-cloud-vision
google-cloud-vision==2.0.0
proto-plus==1.13.0 # via google-cloud-datastore, google-cloud-vision
libcst==0.3.15 # via google-cloud-datastore, google-cloud-vision
Making sure to follow these steps will guarantee the quickest resolution possible.
Thanks!
Hello! Autosynth couldn't regenerate python-vision. ๐
Here's the output from running synth.py
:
loud/vision/v1/product_search_service.proto=google/cloud/vision/v1/product_search_service.proto -Igoogle/cloud/vision/v1/text_annotation.proto=google/cloud/vision/v1/text_annotation.proto -Igoogle/cloud/vision/v1/web_detection.proto=google/cloud/vision/v1/web_detection.proto -Igoogle/api/annotations.proto=google/api/annotations.proto -Igoogle/api/http.proto=google/api/http.proto -Igoogle/protobuf/descriptor.proto=bazel-out/k8-fastbuild/bin/external/com_google_protobuf/_virtual_imports/descriptor_proto/google/protobuf/descriptor.proto -Igoogle/api/client.proto=google/api/client.proto -Igoogle/api/field_behavior.proto=google/api/field_behavior.proto -Igoogle/api/resource.proto=google/api/resource.proto -Igoogle/longrunning/operations.proto=google/longrunning/operations.proto -Igoogle/rpc/status.proto=google/rpc/status.proto -Igoogle/protobuf/any.proto=bazel-out/k8-fastbuild/bin/external/com_google_protobuf/_virtual_imports/any_proto/google/protobuf/any.proto -Igoogle/protobuf/duration.proto=bazel-out/k8-fastbuild/bin/external/com_google_protobuf/_virtual_imports/duration_proto/google/protobuf/duration.proto -Igoogle/protobuf/empty.proto=bazel-out/k8-fastbuild/bin/external/com_google_protobuf/_virtual_imports/empty_proto/google/protobuf/empty.proto -Igoogle/type/color.proto=google/type/color.proto -Igoogle/protobuf/wrappers.proto=bazel-out/k8-fastbuild/bin/external/com_google_protobuf/_virtual_imports/wrappers_proto/google/protobuf/wrappers.proto -Igoogle/type/latlng.proto=google/type/latlng.proto -Igoogle/protobuf/field_mask.proto=bazel-out/k8-fastbuild/bin/external/com_google_protobuf/_virtual_imports/field_mask_proto/google/protobuf/field_mask.proto -Igoogle/protobuf/timestamp.proto=bazel-out/k8-fastbuild/bin/external/com_google_protobuf/_virtual_imports/timestamp_proto/google/protobuf/timestamp.proto google/cloud/vision/v1/geometry.proto google/cloud/vision/v1/image_annotator.proto google/cloud/vision/v1/product_search.proto google/cloud/vision/v1/product_search_service.proto google/cloud/vision/v1/text_annotation.proto google/cloud/vision/v1/web_detection.proto` failed (Exit 1) protoc failed: error executing command bazel-out/host/bin/external/com_google_protobuf/protoc --experimental_allow_proto3_optional '--plugin=protoc-gen-python_gapic=bazel-out/host/bin/external/gapic_generator_python/gapic_plugin' ... (remaining 29 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox
google/cloud/vision/v1/geometry.proto:20:1: warning: Import google/api/annotations.proto is unused.
google/cloud/vision/v1/product_search.proto:23:1: warning: Import google/api/annotations.proto is unused.
google/cloud/vision/v1/text_annotation.proto:21:1: warning: Import google/api/annotations.proto is unused.
google/cloud/vision/v1/web_detection.proto:20:1: warning: Import google/api/annotations.proto is unused.
google/cloud/vision/v1/image_annotator.proto:28:1: warning: Import google/protobuf/field_mask.proto is unused.
Traceback (most recent call last):
File "/home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/sandbox/linux-sandbox/50/execroot/com_google_googleapis/bazel-out/host/bin/external/gapic_generator_python/gapic_plugin.runfiles/gapic_generator_python/gapic/cli/generate_with_pandoc.py", line 3, in <module>
from gapic.cli import generate
File "/home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/sandbox/linux-sandbox/50/execroot/com_google_googleapis/bazel-out/host/bin/external/gapic_generator_python/gapic_plugin.runfiles/gapic_generator_python/gapic/cli/generate.py", line 23, in <module>
from gapic import generator
File "/home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/sandbox/linux-sandbox/50/execroot/com_google_googleapis/bazel-out/host/bin/external/gapic_generator_python/gapic_plugin.runfiles/gapic_generator_python/gapic/generator/__init__.py", line 21, in <module>
from .generator import Generator
File "/home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/sandbox/linux-sandbox/50/execroot/com_google_googleapis/bazel-out/host/bin/external/gapic_generator_python/gapic_plugin.runfiles/gapic_generator_python/gapic/generator/generator.py", line 24, in <module>
from gapic.samplegen import manifest, samplegen
File "/home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/sandbox/linux-sandbox/50/execroot/com_google_googleapis/bazel-out/host/bin/external/gapic_generator_python/gapic_plugin.runfiles/gapic_generator_python/gapic/samplegen/__init__.py", line 15, in <module>
from gapic.samplegen import samplegen
File "/home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/sandbox/linux-sandbox/50/execroot/com_google_googleapis/bazel-out/host/bin/external/gapic_generator_python/gapic_plugin.runfiles/gapic_generator_python/gapic/samplegen/samplegen.py", line 27, in <module>
from gapic.schema import wrappers
File "/home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/sandbox/linux-sandbox/50/execroot/com_google_googleapis/bazel-out/host/bin/external/gapic_generator_python/gapic_plugin.runfiles/gapic_generator_python/gapic/schema/__init__.py", line 23, in <module>
from gapic.schema.api import API
File "/home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/sandbox/linux-sandbox/50/execroot/com_google_googleapis/bazel-out/host/bin/external/gapic_generator_python/gapic_plugin.runfiles/gapic_generator_python/gapic/schema/api.py", line 29, in <module>
from google.api_core import exceptions # type: ignore
ModuleNotFoundError: No module named 'google.api_core'
--python_gapic_out: protoc-gen-python_gapic: Plugin failed with status code 1.
Target //google/cloud/vision/v1:vision-v1-py failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.052s, Critical Path: 0.83s
INFO: 0 processes.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully
Traceback (most recent call last):
File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 102, in <module>
main()
File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 94, in main
spec.loader.exec_module(synth_module) # type: ignore
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/kbuilder/.cache/synthtool/python-vision/synth.py", line 34, in <module>
include_protos=True
File "/tmpfs/src/github/synthtool/synthtool/gcp/gapic_bazel.py", line 52, in py_library
return self._generate_code(service, version, "python", **kwargs)
File "/tmpfs/src/github/synthtool/synthtool/gcp/gapic_bazel.py", line 193, in _generate_code
shell.run(bazel_run_args)
File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 39, in run
raise exc
File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 33, in run
encoding="utf-8",
File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 438, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['bazel', '--max_idle_secs=240', 'build', '//google/cloud/vision/v1:vision-v1-py']' returned non-zero exit status 1.
2021-01-21 05:49:16,884 autosynth [ERROR] > Synthesis failed
2021-01-21 05:49:16,884 autosynth [DEBUG] > Running: git reset --hard HEAD
HEAD is now at d81f83a chore(deps): update dependency pillow to v8.1.0 (#90)
2021-01-21 05:49:16,890 autosynth [DEBUG] > Running: git checkout autosynth
Switched to branch 'autosynth'
2021-01-21 05:49:16,895 autosynth [DEBUG] > Running: git clean -fdx
Removing __pycache__/
Traceback (most recent call last):
File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 354, in <module>
main()
File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 189, in main
return _inner_main(temp_dir)
File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 334, in _inner_main
commit_count = synthesize_loop(x, multiple_prs, change_pusher, synthesizer)
File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 65, in synthesize_loop
has_changes = toolbox.synthesize_version_in_new_branch(synthesizer, youngest)
File "/tmpfs/src/github/synthtool/autosynth/synth_toolbox.py", line 259, in synthesize_version_in_new_branch
synthesizer.synthesize(synth_log_path, self.environ)
File "/tmpfs/src/github/synthtool/autosynth/synthesizer.py", line 120, in synthesize
synth_proc.check_returncode() # Raise an exception.
File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 389, in check_returncode
self.stderr)
subprocess.CalledProcessError: Command '['/tmpfs/src/github/synthtool/env/bin/python3', '-m', 'synthtool', '--metadata', 'synth.metadata', 'synth.py', '--']' returned non-zero exit status 1.
Google internal developers can see the full log here.
Hello! Autosynth couldn't regenerate python-vision. ๐
Here's the output from running synth.py
:
uilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/bazel_tools/tools/build_defs/repo/http.bzl:296:16):
- <builtin>
- /home/kbuilder/.cache/synthtool/googleapis/WORKSPACE:123:1
Loading: 0 packages loaded
INFO: SHA256 (https://github.com/grpc/grpc-java/archive/v1.27.2.zip) = 92ffb4391f847e02e115933a761e243dd1423f3fcafdc9b7ae0327eca102d76b
DEBUG: Rule 'io_grpc_grpc_java' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "92ffb4391f847e02e115933a761e243dd1423f3fcafdc9b7ae0327eca102d76b"
DEBUG: Call stack for the definition of repository 'io_grpc_grpc_java' which is a http_archive (rule definition at /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/bazel_tools/tools/build_defs/repo/http.bzl:296:16):
- <builtin>
- /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/com_google_api_gax_java/repositories.bzl:114:5
- /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/com_google_api_gax_java/repositories.bzl:60:5
- /home/kbuilder/.cache/synthtool/googleapis/WORKSPACE:138:1
Loading: 0 packages loaded
INFO: SHA256 (https://github.com/googleapis/gapic-generator/archive/a59457d24bd6f3c962c8e699c708121c928eedc8.zip) = 843bcf262d44f6a2c1c131844ff8ef40daf95dd3b7c95dd761656f9e010d06d7
DEBUG: Rule 'com_google_api_codegen' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "843bcf262d44f6a2c1c131844ff8ef40daf95dd3b7c95dd761656f9e010d06d7"
DEBUG: Call stack for the definition of repository 'com_google_api_codegen' which is a http_archive (rule definition at /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/bazel_tools/tools/build_defs/repo/http.bzl:296:16):
- <builtin>
- /home/kbuilder/.cache/synthtool/googleapis/WORKSPACE:62:1
Loading: 0 packages loaded
INFO: SHA256 (https://github.com/googleapis/protoc-java-resource-names-plugin/archive/64dafb71ea9a385a8da89989f0b9dab925bf4610.zip) = f475903e83904dbbe3651abae8cbf57ed804960a0dadd9cbde41b746db645052
DEBUG: Rule 'com_google_protoc_java_resource_names_plugin' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "f475903e83904dbbe3651abae8cbf57ed804960a0dadd9cbde41b746db645052"
DEBUG: Call stack for the definition of repository 'com_google_protoc_java_resource_names_plugin' which is a http_archive (rule definition at /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/bazel_tools/tools/build_defs/repo/http.bzl:296:16):
- <builtin>
- /home/kbuilder/.cache/synthtool/googleapis/WORKSPACE:155:1
INFO: SHA256 (https://github.com/googleapis/protoc-docs-plugin/archive/b2502d56b5ec2d47e063976da773206af295362d.zip) = 765ec120bb165ae98c3bae78705d2a127e64016e59738552e909fc8b11d06338
DEBUG: Rule 'protoc_docs_plugin' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "765ec120bb165ae98c3bae78705d2a127e64016e59738552e909fc8b11d06338"
DEBUG: Call stack for the definition of repository 'protoc_docs_plugin' which is a http_archive (rule definition at /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/bazel_tools/tools/build_defs/repo/http.bzl:296:16):
- <builtin>
- /home/kbuilder/.cache/synthtool/googleapis/WORKSPACE:179:1
Loading: 0 packages loaded
INFO: SHA256 (https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.20.0/bazel-gazelle-v0.20.0.tar.gz) = d8c45ee70ec39a57e7a05e5027c32b1576cc7f16d9dd37135b0eddde45cf1b10
DEBUG: Rule 'bazel_gazelle' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "d8c45ee70ec39a57e7a05e5027c32b1576cc7f16d9dd37135b0eddde45cf1b10"
DEBUG: Call stack for the definition of repository 'bazel_gazelle' which is a http_archive (rule definition at /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/bazel_tools/tools/build_defs/repo/http.bzl:296:16):
- <builtin>
- /home/kbuilder/.cache/synthtool/googleapis/WORKSPACE:200:1
Analyzing: target //google/cloud/vision/v1:vision-v1-py (1 packages loaded, 0 targets configured)
INFO: Call stack for the definition of repository 'go_sdk' which is a _go_download_sdk (rule definition at /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/io_bazel_rules_go/go/private/sdk.bzl:79:20):
- <builtin>
- /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/io_bazel_rules_go/go/private/sdk.bzl:92:5
- /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/io_bazel_rules_go/go/private/sdk.bzl:260:13
- /home/kbuilder/.cache/synthtool/googleapis/WORKSPACE:81:1
ERROR: While resolving toolchains for target @pypi_black//:black: invalid registered toolchain '@gapic_generator_python//:pyenv3_toolchain': no such package '@gapic_generator_python//': The repository '@gapic_generator_python' could not be resolved
ERROR: Analysis of target '//google/cloud/vision/v1:vision-v1-py' failed; build aborted: invalid registered toolchain '@gapic_generator_python//:pyenv3_toolchain': no such package '@gapic_generator_python//': The repository '@gapic_generator_python' could not be resolved
INFO: Elapsed time: 6.549s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (21 packages loaded, 22 targets configured)
FAILED: Build did NOT complete successfully (21 packages loaded, 22 targets configured)
2020-06-20 08:42:46,315 synthtool [DEBUG] > Wrote metadata to synth.metadata.
Traceback (most recent call last):
File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 102, in <module>
main()
File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 94, in main
spec.loader.exec_module(synth_module) # type: ignore
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/kbuilder/.cache/synthtool/python-vision/synth.py", line 33, in <module>
include_protos=True
File "/tmpfs/src/github/synthtool/synthtool/gcp/gapic_bazel.py", line 46, in py_library
return self._generate_code(service, version, "python", **kwargs)
File "/tmpfs/src/github/synthtool/synthtool/gcp/gapic_bazel.py", line 180, in _generate_code
shell.run(bazel_run_args)
File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 39, in run
raise exc
File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 33, in run
encoding="utf-8",
File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 438, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['bazel', '--max_idle_secs=60', 'build', '//google/cloud/vision/v1:vision-v1-py']' returned non-zero exit status 1.
2020-06-20 08:42:46,358 autosynth [ERROR] > Synthesis failed
2020-06-20 08:42:46,359 autosynth [DEBUG] > Running: git reset --hard HEAD
HEAD is now at b33fa88 docs: added note about not supported device (#24)
2020-06-20 08:42:46,364 autosynth [DEBUG] > Running: git checkout autosynth-self
Switched to branch 'autosynth-self'
2020-06-20 08:42:46,370 autosynth [ERROR] > Command '['/tmpfs/src/github/synthtool/env/bin/python3', '-m', 'synthtool', '--metadata', 'synth.metadata', 'synth.py', '--']' returned non-zero exit status 1.
2020-06-20 08:42:46,576 autosynth [INFO] > PR already exists: https://github.com/googleapis/python-vision/pull/27
2020-06-20 08:42:46,576 autosynth [DEBUG] > Running: git clean -fdx
Removing __pycache__/
Removing google/__pycache__/
Traceback (most recent call last):
File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 649, in <module>
main()
File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 506, in main
return _inner_main(temp_dir)
File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 629, in _inner_main
commit_count = synthesize_loop(x, multiple_prs, change_pusher, synthesizer)
File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 367, in synthesize_loop
synthesize_inner_loop(fork, synthesizer)
File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 411, in synthesize_inner_loop
synthesizer, len(toolbox.versions) - 1
File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 266, in synthesize_version_in_new_branch
synthesizer.synthesize(synth_log_path, self.environ)
File "/tmpfs/src/github/synthtool/autosynth/synthesizer.py", line 120, in synthesize
synth_proc.check_returncode() # Raise an exception.
File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 389, in check_returncode
self.stderr)
subprocess.CalledProcessError: Command '['/tmpfs/src/github/synthtool/env/bin/python3', '-m', 'synthtool', '--metadata', 'synth.metadata', 'synth.py', '--']' returned non-zero exit status 1.
Google internal developers can see the full log here.
Hi,
Google Cloud SDK works well to get annotation responses via vision API, and I just like to know how can I serialize the response. Is there any helper or serializer for Google response objects? Otherwise, should I parse and build dictionaries from the response object by manual?
- OS type and version
OS X El Capitan
- Python version and virtual environment information
python --version
2.7.13
- google-cloud-python version
pip show google-cloud
, pip show google-<service>
or pip freeze
157.0.0
- Stacktrace if available
- Steps to reproduce
- Code example
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
- Run
client.annotate_image(request)
=> SUCCESS (request is valid and you can print the output)
- 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
Recommend Projects
-
-
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
An Open Source Machine Learning Framework for Everyone
-
The Web framework for perfectionists with deadlines.
-
A PHP framework for web artisans
-
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
Some thing interesting about web. New door for the world.
-
A server is a program made to process requests and deliver data to clients.
-
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Some thing interesting about visualization, use data art
-
Some thing interesting about game, make everyone happy.
-
Recommend Org
-
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Open source projects and samples from Microsoft.
-
Google โค๏ธ Open Source for everyone.
-
Alibaba Open Source for everyone
-
Data-Driven Documents codes.
-
China tencent open source team.
-