Skip to content

Commit 14032ee

Browse files
[SDK-588] Fix flaky pdf test. (#1512)
1 parent 5f93be0 commit 14032ee

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

tests/conftest.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -744,20 +744,18 @@ def wait_for_data_row_processing():
744744
DataRow be fully processed with media_attributes
745745
"""
746746

747-
def func(client, data_row, compare_with_prev_media_attrs=False):
747+
def func(client, data_row, custom_check=None):
748748
"""
749749
added check_updated_at because when a data_row is updated from say
750750
an image to pdf, it already has media_attributes and the loop does
751751
not wait for processing to a pdf
752752
"""
753-
prev_media_attrs = data_row.media_attributes if compare_with_prev_media_attrs else None
754753
data_row_id = data_row.uid
755754
timeout_seconds = 60
756755
while True:
757756
data_row = client.get_data_row(data_row_id)
758-
if data_row.media_attributes and (prev_media_attrs is None or
759-
prev_media_attrs
760-
!= data_row.media_attributes):
757+
passed_custom_check = not custom_check or custom_check(data_row)
758+
if data_row.media_attributes and passed_custom_check:
761759
return data_row
762760
timeout_seconds -= 2
763761
if timeout_seconds <= 0:

tests/integration/test_data_rows.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,9 +593,10 @@ def test_data_row_update(client, dataset, rand_gen, image_url,
593593
pdf_url = "https://storage.googleapis.com/labelbox-datasets/arxiv-pdf/data/99-word-token-pdfs/0801.3483.pdf"
594594
tileLayerUrl = "https://storage.googleapis.com/labelbox-datasets/arxiv-pdf/data/99-word-token-pdfs/0801.3483-lb-textlayer.json"
595595
data_row.update(row_data={'pdfUrl': pdf_url, "tileLayerUrl": tileLayerUrl})
596+
custom_check = lambda data_row: data_row.row_data and 'pdfUrl' not in data_row.row_data
596597
data_row = wait_for_data_row_processing(client,
597598
data_row,
598-
compare_with_prev_media_attrs=True)
599+
custom_check=custom_check)
599600
assert data_row.row_data == pdf_url
600601

601602

0 commit comments

Comments
 (0)