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

Inappropriate Exception for queries to Ukranian #49

Closed
jvacek opened this issue Aug 30, 2022 · 6 comments
Closed

Inappropriate Exception for queries to Ukranian #49

jvacek opened this issue Aug 30, 2022 · 6 comments

Comments

@jvacek
Copy link

jvacek commented Aug 30, 2022

Instead of appropriately raising DeepLException: Bad request, message: Value for 'target_lang' not supported., the request throws TooManyRequestsException: Too many requests, DeepL servers are currently experiencing high load, message: Too many requests after ~10s of sleeping. It would be much better to raise early that it is not currently supported.

In [21]: translator.translate_text("hrdinum slava", source_lang='cs', target_lang="uk")        
2022-08-30 12:32:47,545 deepl        INFO     Request to DeepL API method=POST url=https://api-free.deepl.com/v2/translate
2022-08-30 12:32:47,828 deepl        INFO     Starting retry 1 for request POST https://api-free.deepl.com/v2/translate after sleeping for 0.72 seconds. 
2022-08-30 12:32:48,711 deepl        INFO     Starting retry 2 for request POST https://api-free.deepl.com/v2/translate after sleeping for 1.39 seconds. 
2022-08-30 12:32:50,287 deepl        INFO     Starting retry 3 for request POST https://api-free.deepl.com/v2/translate after sleeping for 2.57 seconds. 
2022-08-30 12:32:52,963 deepl        INFO     Starting retry 4 for request POST https://api-free.deepl.com/v2/translate after sleeping for 4.27 seconds. 
2022-08-30 12:32:57,410 deepl        INFO     Starting retry 5 for request POST https://api-free.deepl.com/v2/translate after sleeping for 4.98 seconds. 
2022-08-30 12:33:02,605 deepl        INFO     DeepL API response status_code=429 url=https://api-free.deepl.com/v2/translate
---------------------------------------------------------------------------
TooManyRequestsException                  Traceback (most recent call last)
Input In [21], in <module>
----> 1 translator.translate_text("hrdinum slava", source_lang='cs', target_lang="uk")

File ~/Git/Supernova/venv/lib/python3.9/site-packages/deepl/translator.py:769, in Translator.translate_text(self, text, source_lang, target_lang, split_sentences, preserve_formatting, formality, glossary, tag_handling, outline_detection, non_splitting_tags, splitting_tags, ignore_tags)
    763     request_data["ignore_tags"] = join_tags(ignore_tags)
    765 status, content, json = self._api_call(
    766     "v2/translate", data=request_data
    767 )
--> 769 self._raise_for_status(status, content, json)
    771 translations = json.get("translations", [])
    772 output = []

File ~/Git/Supernova/venv/lib/python3.9/site-packages/deepl/translator.py:560, in Translator._raise_for_status(self, status_code, content, json, glossary, downloading_document)
    558     raise DeepLException(f"Bad request{message}")
    559 elif status_code == http.HTTPStatus.TOO_MANY_REQUESTS:
--> 560     raise TooManyRequestsException(
    561         "Too many requests, DeepL servers are currently experiencing "
    562         f"high load{message}"
    563     )
    564 elif status_code == http.HTTPStatus.SERVICE_UNAVAILABLE:
    565     if downloading_document:

TooManyRequestsException: Too many requests, DeepL servers are currently experiencing high load, message: Too many requests
@daniel-jones-deepl
Copy link
Member

Hi @jvacek Jonas, thanks for reporting this, we're looking into it.

@gantoin
Copy link

gantoin commented Sep 16, 2022

Looks like it fixed in the v1.10.0 version.

@jvacek
Copy link
Author

jvacek commented Sep 16, 2022

Will the same thing happen the next time a new language is being trained?

@gantoin
Copy link

gantoin commented Sep 16, 2022

Will the same thing happen the next time a new language is being trained?

Yes, I think so. Take a look at this commit f761732

@jvacek
Copy link
Author

jvacek commented Sep 16, 2022

This might actually be an issue for the backend instead of the Python package actually, I would not be surprised if the response being given by the API is the cause of the exception being faulty. i.e. I would assume the other implementations of the deepl package would suffer from a similar thing

@daniel-jones-deepl
Copy link
Member

Hi @jvacek Jonas and @gantoin Antoine, yes DeepL supports Ukrainian now.

Yes it was caused by the backend API not this Python library. We will fix the issue, so it should not happen again next time we release a new language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants