Skip to content

Commit 61ec132

Browse files
committed
AL-4081: Updated test for expected to fail case
1 parent 1823ad6 commit 61ec132

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

labelbox/exceptions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,8 @@ class MALValidationError(LabelboxError):
129129
class OperationNotAllowedException(Exception):
130130
"""Raised when user does not have permissions to a resource or has exceeded usage limit"""
131131
pass
132+
133+
134+
class ProcessingWaitTimeout(Exception):
135+
"""Raised when waiting for the data rows to be processed takes longer than allowed"""
136+
pass

labelbox/schema/project.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import ndjson
1111
import requests
1212
from labelbox import utils
13-
from labelbox.exceptions import InvalidQueryError, LabelboxError
13+
from labelbox.exceptions import InvalidQueryError, LabelboxError, ProcessingWaitTimeout
1414
from labelbox.orm import query
1515
from labelbox.orm.db_object import DbObject, Deletable, Updateable
1616
from labelbox.orm.model import Entity, Field, Relationship
@@ -975,9 +975,9 @@ def _wait_until_data_rows_are_processed(self, data_row_ids: List[str], wait_proc
975975
start_time = datetime.now()
976976
while True:
977977
if (datetime.now() - start_time).total_seconds() >= wait_processing_max_seconds:
978-
logger.warning(
979-
"""Not all data rows have been processed, proceeding anyway""")
980-
return
978+
raise ProcessingWaitTimeout(
979+
"Maximum wait time exceeded while waiting for data rows to be processed. Try creating a batch a bit later"
980+
)
981981

982982
all_good = self.__check_data_rows_have_been_processed(data_row_ids)
983983
if all_good:

tests/integration/test_batch.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import warnings
2-
31
import pytest
42
from labelbox import Dataset, Project
53
from labelbox.schema.queue_mode import QueueMode
@@ -118,7 +116,7 @@ def test_batch_creation_with_processing_timeout(
118116
unique_dataset: Dataset
119117
):
120118
"""
121-
Create a batch with zero wait time, this means that the waiting will termintate instantly
119+
Create a batch with zero wait time, this means that the waiting logic will throw exception immediately
122120
"""
123121
# wait for these data rows to be processed
124122
valid_data_rows = [dr.uid for dr in list(small_dataset.export_data_rows())]
@@ -132,18 +130,13 @@ def test_batch_creation_with_processing_timeout(
132130
unique_dataset.export_data_rows())]
133131

134132
data_row_ids = valid_data_rows + unprocessed_data_rows
135-
with warnings.catch_warnings(record=True) as w:
136-
warnings.simplefilter("always")
137-
breakpoint()
133+
134+
with pytest.raises(ProcessingWaitTimeout):
138135
batch_project.create_batch(
139136
"batch to test failed data rows",
140137
data_row_ids,
141138
wait_processing_max_seconds=0
142139
)
143-
assert len(w) == 1
144-
assert issubclass(w[-1].category, DeprecationWarning)
145-
assert "Not all data rows have been processed, proceeding anyway" in str(
146-
w[-1].message)
147140

148141

149142
def test_export_data_rows(batch_project: Project, dataset: Dataset):

0 commit comments

Comments
 (0)