Please help me to resolve the error
I followed the instruction below,
https://cloud.google.com/translate/docs/quickstart-client-libraries-v3
and when I run the following code, I encounter the error that says "google.api_core.exceptions.DeadlineExceeded: 504 Deadline Exceeded" at “target_language_code” in the script.
Here is the code that I used.
from google.cloud import translate_v3beta1 as translate
client = translate.TranslationServiceClient()
#
project_id = YOUR_PROJECT_ID
# text =
'Text you wish to translate'
location = 'global'
parent = client.location_path(project_id, location)
response = client.translate_text(
parent=parent,
contents=[text],
mime_type='text/plain', # mime types: text/plain, text/html
source_language_code='en-US',
target_language_code='sr-Latn')
for
translation in response.translations:
print('Translated Text: {}'.format(translation))
Here is the trace log that I received.
Traceback (most recent call last):
File "C:\Program Files\Python36\lib\site-packages\google\api_core\grpc_helpers.py", line 57, in error_remapped_callable
return callable_(*args, **kwargs)
File "C:\Program Files\Python36\lib\site-packages\grpc\_channel.py", line 565, in __call__
return _end_unary_response_blocking(state, call, False, None)
File "C:\Program Files\Python36\lib\site-packages\grpc\_channel.py", line 467, in _end_unary_response_blocking
raise _Rendezvous(state, None, None, deadline)
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with:
status = StatusCode.DEADLINE_EXCEEDED
details = "Deadline Exceeded"
debug_error_string = "{"created":"@1567597238.887000000","description":"Deadline Exceeded","file":"src/core/ext/filters/deadline/deadline_filter.cc","file_line":69,"grpc_status":4}"
>
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "c:\Users\h1015543\.vscode\extensions\ms-python.python-2019.8.30787\pythonFiles\ptvsd_launcher.py", line 43, in <module>
main(ptvsdArgs)
File "c:\Users\h1015543\.vscode\extensions\ms-python.python-2019.8.30787\pythonFiles\lib\python\ptvsd\__main__.py", line 432, in main
run()
File "c:\Users\h1015543\.vscode\extensions\ms-python.python-2019.8.30787\pythonFiles\lib\python\ptvsd\__main__.py", line 316, in run_file
runpy.run_path(target, run_name='__main__')
File "C:\Program Files\Python36\lib\runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File "C:\Program Files\Python36\lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "C:\Program Files\Python36\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "c:\Users\h1015543\Documents\Python-study\v3beta1\test.py", line 15, in <module>
target_language_code='aaaaaaaa')
File "C:\Program Files\Python36\lib\site-packages\google\cloud\translate_v3beta1\gapic\translation_service_client.py", line 338, in translate_text
request, retry=retry, timeout=timeout, metadata=metadata
File "C:\Program Files\Python36\lib\site-packages\google\api_core\gapic_v1\method.py", line 143, in __call__
return wrapped_func(*args, **kwargs)
File "C:\Program Files\Python36\lib\site-packages\google\api_core\retry.py", line 273, in retry_wrapped_func
on_error=on_error,
File "C:\Program Files\Python36\lib\site-packages\google\api_core\retry.py", line 182, in retry_target
return target()
File "C:\Program Files\Python36\lib\site-packages\google\api_core\timeout.py", line 214, in func_with_timeout
return func(*args, **kwargs)
File "C:\Program Files\Python36\lib\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.DeadlineExceeded: 504 Deadline Exceeded
I would appreciated if you could give me an advice.