Skip to content

Commit

Permalink
chore(deps): update dependency backoff to v2 (#386)
Browse files Browse the repository at this point in the history
* chore(deps): update dependency backoff to v2

* test: backoff wait_gen arg expects a generator

Co-authored-by: Anthonios Partheniou <partheniou@google.com>
  • Loading branch information
renovate-bot and parthea authored Apr 26, 2022
1 parent bd96c41 commit f6760a3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion translation/samples/snippets/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
backoff==1.11.1
backoff==2.0.0
flaky==3.7.0
pytest==7.1.2
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,28 @@ def bucket():

def on_backoff(invocation_dict):
"""Backoff callback; create a testing bucket for each backoff run"""
invocation_dict['kwargs']['bucket'] = next(get_ephemeral_bucket())
invocation_dict["kwargs"]["bucket"] = next(get_ephemeral_bucket())


# If necessary, retry test function while backing off the timeout sequentially
MAX_TIMEOUT = 500


@backoff.on_exception(wait_gen=lambda : iter([100, 250, 300, MAX_TIMEOUT]), exception=Exception, max_tries=5, on_backoff=on_backoff)
@backoff.on_exception(
wait_gen=lambda: (wait_time for wait_time in [100, 250, 300, MAX_TIMEOUT]),
exception=Exception,
max_tries=5,
on_backoff=on_backoff,
)
def test_batch_translate_text_with_glossary(capsys, bucket):

translate_v3_batch_translate_text_with_glossary.batch_translate_text_with_glossary(
"gs://cloud-samples-data/translation/text_with_glossary.txt",
"gs://{}/translation/BATCH_TRANSLATION_GLOS_OUTPUT/".format(bucket.name),
PROJECT_ID,
GLOSSARY_ID,
MAX_TIMEOUT)
MAX_TIMEOUT,
)

out, _ = capsys.readouterr()
assert "Total Characters: 9" in out

0 comments on commit f6760a3

Please sign in to comment.