Skip to content

Commit b073a9d

Browse files
author
Val Brodsky
committed
Fix tests
1 parent 2f892a7 commit b073a9d

File tree

3 files changed

+13
-23
lines changed

3 files changed

+13
-23
lines changed

libs/labelbox/src/labelbox/client.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,7 @@ def upload_file(self, path: str) -> str:
202202
)
203203

204204
@retry.Retry(
205-
predicate=retry.if_exception_type(
206-
lbox.exceptions.InternalServerError
207-
)
205+
predicate=retry.if_exception_type(lbox.exceptions.InternalServerError)
208206
)
209207
def upload_data(
210208
self,
@@ -310,9 +308,7 @@ def _get_single(self, db_object_type, uid):
310308
res = self.execute(query_str, params)
311309
res = res and res.get(utils.camel_case(db_object_type.type_name()))
312310
if res is None:
313-
raise lbox.exceptions.ResourceNotFoundError(
314-
db_object_type, params
315-
)
311+
raise lbox.exceptions.ResourceNotFoundError(db_object_type, params)
316312
else:
317313
return db_object_type(self, res)
318314

@@ -1975,9 +1971,7 @@ def is_feature_schema_archived(
19751971
)
19761972

19771973
elif response.status_code == 404:
1978-
raise lbox.exceptions.ResourceNotFoundError(
1979-
Ontology, ontology_id
1980-
)
1974+
raise lbox.exceptions.ResourceNotFoundError(Ontology, ontology_id)
19811975
else:
19821976
raise lbox.exceptions.LabelboxError(
19831977
"Failed to get the feature schema archived status."
@@ -2006,9 +2000,7 @@ def get_model_slice(self, slice_id) -> ModelSlice:
20062000
"""
20072001
res = self.execute(query_str, {"id": slice_id})
20082002
if res is None or res["getSavedQuery"] is None:
2009-
raise lbox.exceptions.ResourceNotFoundError(
2010-
ModelSlice, slice_id
2011-
)
2003+
raise lbox.exceptions.ResourceNotFoundError(ModelSlice, slice_id)
20122004

20132005
return Entity.ModelSlice(self, res["getSavedQuery"])
20142006

@@ -2316,9 +2308,7 @@ def get_embedding_by_name(self, name: str) -> Embedding:
23162308
for e in embeddings:
23172309
if e.name == name:
23182310
return e
2319-
raise lbox.exceptions.ResourceNotFoundError(
2320-
Embedding, dict(name=name)
2321-
)
2311+
raise lbox.exceptions.ResourceNotFoundError(Embedding, dict(name=name))
23222312

23232313
def upsert_label_feedback(
23242314
self, label_id: str, feedback: str, scores: Dict[str, float]
@@ -2365,8 +2355,7 @@ def upsert_label_feedback(
23652355
scores_raw = res["upsertAutoQaLabelFeedback"]["scores"]
23662356

23672357
return [
2368-
labelbox.LabelScore(name=x["name"], score=x["score"])
2369-
for x in scores_raw
2358+
LabelScore(name=x["name"], score=x["score"]) for x in scores_raw
23702359
]
23712360

23722361
def get_labeling_service_dashboards(

libs/labelbox/tests/integration/test_client_errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def test_resource_not_found_error(client):
7373

7474
def test_network_error(client):
7575
client = labelbox.client.Client(
76-
api_key=client.api_key, endpoint="not_a_valid_URL"
76+
api_key=client._request_client.api_key, endpoint="not_a_valid_URL"
7777
)
7878

7979
with pytest.raises(lbox.exceptions.NetworkError) as excinfo:

libs/labelbox/tests/integration/test_foundry.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import labelbox as lb
21
import pytest
3-
from labelbox.schema.foundry.app import App
2+
from lbox.exceptions import LabelboxError, ResourceNotFoundError
43

4+
import labelbox as lb
5+
from labelbox.schema.foundry.app import App
56
from labelbox.schema.foundry.foundry_client import FoundryClient
67

78
# Yolo object detection model id
@@ -97,7 +98,7 @@ def test_get_app(foundry_client, app):
9798

9899

99100
def test_get_app_with_invalid_id(foundry_client):
100-
with pytest.raises(lb.exceptions.ResourceNotFoundError):
101+
with pytest.raises(ResourceNotFoundError):
101102
foundry_client._get_app("invalid-id")
102103

103104

@@ -144,7 +145,7 @@ def test_run_foundry_app_returns_model_run_id(
144145
def test_run_foundry_with_invalid_data_row_id(foundry_client, app, random_str):
145146
invalid_datarow_id = "invalid-global-key"
146147
data_rows = lb.GlobalKeys([invalid_datarow_id])
147-
with pytest.raises(lb.exceptions.LabelboxError) as exception:
148+
with pytest.raises(LabelboxError) as exception:
148149
foundry_client.run_app(
149150
model_run_name=f"test-app-with-invalid-datarow-id-{random_str}",
150151
data_rows=data_rows,
@@ -156,7 +157,7 @@ def test_run_foundry_with_invalid_data_row_id(foundry_client, app, random_str):
156157
def test_run_foundry_with_invalid_global_key(foundry_client, app, random_str):
157158
invalid_global_key = "invalid-global-key"
158159
data_rows = lb.GlobalKeys([invalid_global_key])
159-
with pytest.raises(lb.exceptions.LabelboxError) as exception:
160+
with pytest.raises(LabelboxError) as exception:
160161
foundry_client.run_app(
161162
model_run_name=f"test-app-with-invalid-global-key-{random_str}",
162163
data_rows=data_rows,

0 commit comments

Comments
 (0)