question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inappropriate Exception for queries to Ukranian

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
daniel-jones-deeplcommented, Sep 20, 2022

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.

1reaction
jvacekcommented, 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

Read more comments on GitHub >

github_iconTop Results From Across the Web

The WTO's First Ruling on National Security: What Does It ...
In the Russia-Ukraine dispute, Russia invoked the exception to justify measures that blocked trade between Ukraine, Kazakhstan, and the Kyrgyz ...
Read more >
Why my JPA queries take such time to be executed? - LinkedIn
Bad uses or inappropriate design in persistence layer can causes: 1 - Slowless to extract data from database. 2 - Out of memory...
Read more >
TransactionRequiredException Executing an update/delete ...
I received this exception when trying to run a bulk UPDATE query in a non-JTA (i.e. resource-local) entity manager in Java SE. I...
Read more >
On Ukraine, Tucker Carlson backpedals after supporting Putin
The answer, to Carlson's mind, is no. (Nothing, not even jailing antiwar protesters, is worse than submitting cable news hosts to criticism.) ...
Read more >
Help Ukraine Stop Russia - Refactoring.Guru
There's a chance you worked with someone from Ukraine previously on a software project. Ask if they need any help. Even something simple...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found