Skip to content

Commit 6041a26

Browse files
committed
AL-4081: Adjusted test
1 parent cbdf1c8 commit 6041a26

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

labelbox/schema/project.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ class Project(DbObject, Updateable, Deletable):
8989
benchmarks = Relationship.ToMany("Benchmark", False)
9090
ontology = Relationship.ToOne("Ontology", True)
9191

92+
#
93+
_wait_processing_max_seconds = 3600
94+
9295
def update(self, **kwargs):
9396
""" Updates this project with the specified attributes
9497
@@ -594,7 +597,8 @@ def create_batch(self,
594597
if not len(dr_ids):
595598
raise ValueError("You need at least one data row in a batch")
596599

597-
self._wait_until_data_rows_are_processed(data_rows,)
600+
self._wait_until_data_rows_are_processed(
601+
data_rows, self._wait_processing_max_seconds)
598602
method = 'createBatchV2'
599603
query_str = """mutation %sPyApi($projectId: ID!, $batchInput: CreateBatchInput!) {
600604
project(where: {id: $projectId}) {
@@ -980,7 +984,7 @@ def _is_url_valid(url: Union[str, Path]) -> bool:
980984
raise ValueError(
981985
f'Invalid annotations given of type: {type(annotations)}')
982986

983-
def _wait_until_data_rows_are_processed(self, data_row_ids: List[str], wait_processing_max_seconds=3600, sleep_interval=30):
987+
def _wait_until_data_rows_are_processed(self, data_row_ids: List[str], wait_processing_max_seconds: int, sleep_interval=30):
984988
""" Wait until all the specified data rows are processed"""
985989
start_time = datetime.now()
986990
while True:
@@ -992,6 +996,9 @@ def _wait_until_data_rows_are_processed(self, data_row_ids: List[str], wait_proc
992996
all_good = self.__check_data_rows_have_been_processed(data_row_ids)
993997
if all_good:
994998
return
999+
1000+
logger.debug(
1001+
'Some of the data rows are still being processed, waiting...')
9951002
time.sleep(sleep_interval)
9961003

9971004
def __check_data_rows_have_been_processed(self, data_row_ids: List[str]):

tests/integration/test_batch.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from labelbox.exceptions import ProcessingWaitTimeout
12
import pytest
23
from labelbox import Dataset, Project
34

@@ -144,10 +145,10 @@ def test_batch_creation_with_processing_timeout(
144145
data_row_ids = valid_data_rows + unprocessed_data_rows
145146

146147
with pytest.raises(ProcessingWaitTimeout):
148+
batch_project._wait_processing_max_seconds = 0
147149
batch_project.create_batch(
148150
"batch to test failed data rows",
149-
data_row_ids,
150-
wait_processing_max_seconds=0
151+
data_row_ids
151152
)
152153

153154

0 commit comments

Comments
 (0)