Skip to content

Commit 7f2c6c6

Browse files
authored
[SDK-302] Remove backoff library (#1255)
2 parents 230341e + c6ae9b3 commit 7f2c6c6

File tree

6 files changed

+13
-20
lines changed

6 files changed

+13
-20
lines changed

.yapfignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
pytest.ini
1+
Makefile
2+
*.txt
3+
*.ini

labelbox/schema/annotation_import.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import time
66
from typing import Any, BinaryIO, Dict, List, Union, TYPE_CHECKING, cast
77

8-
import backoff
8+
from google.api_core import retry
99
from labelbox import parser
1010
import requests
1111
from tqdm import tqdm # type: ignore
@@ -109,12 +109,9 @@ def wait_until_done(self,
109109
pbar.update(100 - pbar.n)
110110
pbar.close()
111111

112-
@backoff.on_exception(
113-
backoff.expo,
114-
(labelbox.exceptions.ApiLimitError, labelbox.exceptions.TimeoutError,
115-
labelbox.exceptions.NetworkError),
116-
max_tries=10,
117-
jitter=None)
112+
@retry.Retry(predicate=retry.if_exception_type(
113+
labelbox.exceptions.ApiLimitError, labelbox.exceptions.TimeoutError,
114+
labelbox.exceptions.NetworkError))
118115
def __backoff_refresh(self) -> None:
119116
self.refresh()
120117

labelbox/schema/bulk_import_request.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import logging
77
from pathlib import Path
88
import pydantic
9-
import backoff
9+
from google.api_core import retry
1010
from labelbox import parser
1111
import requests
1212
from pydantic import BaseModel, root_validator, validator
@@ -197,11 +197,9 @@ def wait_until_done(self, sleep_time_seconds: int = 5) -> None:
197197
time.sleep(sleep_time_seconds)
198198
self.__exponential_backoff_refresh()
199199

200-
@backoff.on_exception(
201-
backoff.expo, (lb_exceptions.ApiLimitError, lb_exceptions.TimeoutError,
202-
lb_exceptions.NetworkError),
203-
max_tries=10,
204-
jitter=None)
200+
@retry.Retry(predicate=retry.if_exception_type(lb_exceptions.ApiLimitError,
201+
lb_exceptions.TimeoutError,
202+
lb_exceptions.NetworkError))
205203
def __exponential_backoff_refresh(self) -> None:
206204
self.refresh()
207205

mypy.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
[mypy]
22

3-
[mypy-backoff.*]
4-
ignore_missing_imports = True
5-
63
[mypy-google.*]
74
ignore_missing_imports = True
85

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
backoff==1.10.0
21
geojson
32
google-api-core>=1.22.1
43
imagesize

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
url="https://labelbox.com",
2121
packages=setuptools.find_packages(),
2222
install_requires=[
23-
"backoff==1.10.0", "requests>=2.22.0", "google-api-core>=1.22.1",
24-
"pydantic>=1.8,<2.0", "tqdm", "python-dateutil>=2.8.2,<2.9.0"
23+
"requests>=2.22.0", "google-api-core>=1.22.1", "pydantic>=1.8,<2.0",
24+
"tqdm", "python-dateutil>=2.8.2,<2.9.0"
2525
],
2626
extras_require={
2727
'data': [

0 commit comments

Comments
 (0)