Skip to content

Commit fde2538

Browse files
committed
resolving conflicts
2 parents 32aeebf + dd4530a commit fde2538

30 files changed

+1567
-284
lines changed

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
env:
6868
# make sure to tell tox to use these environs in tox.ini
6969
#
70-
# randall@labelbox.com
70+
# msokoloff+prod-python@labelbox.com
7171
LABELBOX_TEST_API_KEY_PROD: ${{ secrets.LABELBOX_API_KEY }}
7272

7373
# randall+staging-python@labelbox.com

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
* Comparing a Labelbox object (e.g. Project) to None doesn't raise an exception
77
* Adding `order_by` to `Project.labels` doesn't raise an exception
88

9-
## Version 2.4.10 (2021-01-05)
9+
## Version 2.4.11 (2021-03-07)
10+
### Fix
11+
* Increase query timeout
12+
* Retry 502s
13+
14+
## Version 2.4.10 (2021-02-05)
1015
### Added
1116
* SDK version added to request headers
1217

Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
FROM python:3.7
22

3-
COPY . /usr/src/labelbox
3+
RUN pip install pytest pytest-cases
4+
45
WORKDIR /usr/src/labelbox
6+
COPY requirements.txt /usr/src/labelbox
7+
RUN pip install -r requirements.txt
8+
COPY . /usr/src/labelbox
9+
510

6-
RUN pip install pytest
711
RUN python setup.py install

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ build:
55
test-staging: build
66
docker run -it -v ${PWD}:/usr/src -w /usr/src \
77
-e LABELBOX_TEST_ENVIRON="staging" \
8-
-e LABELBOX_TEST_API_KEY_STAGING="<REPLACE>" \
8+
-e LABELBOX_TEST_API_KEY_STAGING=${LABELBOX_TEST_API_KEY_STAGING} \
99
local/labelbox-python:test pytest $(PATH_TO_TEST) -svvx
1010

1111
test-prod: build
1212
docker run -it -v ${PWD}:/usr/src -w /usr/src \
1313
-e LABELBOX_TEST_ENVIRON="prod" \
14-
-e LABELBOX_TEST_API_KEY_PROD=${apikey} \
14+
-e LABELBOX_TEST_API_KEY_PROD=${LABELBOX_TEST_API_KEY_PROD} \
1515
local/labelbox-python:test pytest $(PATH_TO_TEST) -svvx

labelbox/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name = "labelbox"
2-
__version__ = "2.4.10"
2+
__version__ = "2.4.11"
33

44
from labelbox.client import Client
55
from labelbox.schema.bulk_import_request import BulkImportRequest
@@ -15,4 +15,4 @@
1515
from labelbox.schema.asset_metadata import AssetMetadata
1616
from labelbox.schema.webhook import Webhook
1717
from labelbox.schema.prediction import Prediction, PredictionModel
18-
from labelbox.schema.ontology import Ontology
18+
from labelbox.schema.ontology import Ontology

labelbox/client.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ def __init__(self,
7171
'X-User-Agent': f'python-sdk {SDK_VERSION}'
7272
}
7373

74+
#TODO: Add exponential backoff so we don'tt overwhelm the api
7475
@retry.Retry(predicate=retry.if_exception_type(
7576
labelbox.exceptions.InternalServerError))
76-
def execute(self, query, params=None, timeout=10.0):
77+
def execute(self, query, params=None, timeout=30.0):
7778
""" Sends a request to the server for the execution of the
7879
given query.
7980
@@ -126,25 +127,23 @@ def convert_value(value):
126127
logger.debug("Response: %s", response.text)
127128
except requests.exceptions.Timeout as e:
128129
raise labelbox.exceptions.TimeoutError(str(e))
129-
130130
except requests.exceptions.RequestException as e:
131131
logger.error("Unknown error: %s", str(e))
132132
raise labelbox.exceptions.NetworkError(e)
133-
134133
except Exception as e:
135134
raise labelbox.exceptions.LabelboxError(
136135
"Unknown error during Client.query(): " + str(e), e)
137-
138136
try:
139137
r_json = response.json()
140138
except:
141-
error_502 = '502 Bad Gateway'
142-
if error_502 in response.text:
143-
raise labelbox.exceptions.InternalServerError(error_502)
144139
if "upstream connect error or disconnect/reset before headers" \
145140
in response.text:
146141
raise labelbox.exceptions.InternalServerError(
147142
"Connection reset")
143+
elif response.status_code == 502:
144+
error_502 = '502 Bad Gateway'
145+
raise labelbox.exceptions.InternalServerError(error_502)
146+
148147
raise labelbox.exceptions.LabelboxError(
149148
"Failed to parse response as JSON: %s" % response.text)
150149

@@ -189,6 +188,7 @@ def check_errors(keywords, *path):
189188

190189
# Check if API limit was exceeded
191190
response_msg = r_json.get("message", "")
191+
192192
if response_msg.startswith("You have exceeded"):
193193
raise labelbox.exceptions.ApiLimitError(response_msg)
194194

@@ -292,7 +292,6 @@ def upload_data(self,
292292
"1": (filename, content, content_type) if
293293
(filename and content_type) else content
294294
})
295-
296295
try:
297296
file_data = response.json().get("data", None)
298297
except ValueError as e: # response is not valid JSON

labelbox/exceptions.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,9 @@ class UuidError(LabelboxError):
103103

104104

105105
class InconsistentOntologyException(Exception):
106-
pass
106+
pass
107+
108+
109+
class MALValidationError(LabelboxError):
110+
"""Raised when user input is invalid for MAL imports."""
111+
...

labelbox/schema/asset_metadata.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from enum import Enum
2+
13
from labelbox.orm.db_object import DbObject
24
from labelbox.orm.model import Field
35

@@ -9,9 +11,16 @@ class AssetMetadata(DbObject):
911
meta_type (str): IMAGE, VIDEO, TEXT, or IMAGE_OVERLAY
1012
meta_value (str): URL to an external file or a string of text
1113
"""
12-
VIDEO = "VIDEO"
13-
IMAGE = "IMAGE"
14-
TEXT = "TEXT"
14+
15+
class MetaType(Enum):
16+
VIDEO = "VIDEO"
17+
IMAGE = "IMAGE"
18+
TEXT = "TEXT"
19+
IMAGE_OVERLAY = "IMAGE_OVERLAY"
20+
21+
# For backwards compatibility
22+
for topic in MetaType:
23+
vars()[topic.name] = topic.value
1524

1625
meta_type = Field.String("meta_type")
1726
meta_value = Field.String("meta_value")

0 commit comments

Comments
 (0)