Skip to content

Commit

Permalink
Merge pull request #116 from climatepolicyradar/feature/retry-transla…
Browse files Browse the repository at this point in the history
…te-api

Adding retry on translate endpoint.
  • Loading branch information
THOR300 authored Oct 26, 2023
2 parents 212842e + b07f9f0 commit 5a28723
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/translator/translate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from typing import List
import six
import logging
from tenacity import retry, stop_after_attempt, wait_random_exponential


from cpr_data_access.parser_models import ParserOutput
from google.cloud import translate_v2
Expand All @@ -9,6 +11,10 @@
_LOGGER = logging.getLogger(__file__)


@retry(
stop=stop_after_attempt(4),
wait=wait_random_exponential(multiplier=1, min=1, max=10),
)
def translate_text(text: List[str], target_language: str) -> List[str]:
"""
Translate text into the target language.
Expand Down

0 comments on commit 5a28723

Please sign in to comment.