Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDK-588] Fix flaky pdf test. #1512

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,20 +744,18 @@ def wait_for_data_row_processing():
DataRow be fully processed with media_attributes
"""

def func(client, data_row, compare_with_prev_media_attrs=False):
def func(client, data_row, custom_check=None):
"""
added check_updated_at because when a data_row is updated from say
an image to pdf, it already has media_attributes and the loop does
not wait for processing to a pdf
"""
prev_media_attrs = data_row.media_attributes if compare_with_prev_media_attrs else None
data_row_id = data_row.uid
timeout_seconds = 60
while True:
data_row = client.get_data_row(data_row_id)
if data_row.media_attributes and (prev_media_attrs is None or
prev_media_attrs
!= data_row.media_attributes):
passed_custom_check = not custom_check or custom_check(data_row)
if data_row.media_attributes and passed_custom_check:
return data_row
timeout_seconds -= 2
if timeout_seconds <= 0:
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/test_data_rows.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,9 +593,10 @@ def test_data_row_update(client, dataset, rand_gen, image_url,
pdf_url = "https://storage.googleapis.com/labelbox-datasets/arxiv-pdf/data/99-word-token-pdfs/0801.3483.pdf"
tileLayerUrl = "https://storage.googleapis.com/labelbox-datasets/arxiv-pdf/data/99-word-token-pdfs/0801.3483-lb-textlayer.json"
data_row.update(row_data={'pdfUrl': pdf_url, "tileLayerUrl": tileLayerUrl})
custom_check = lambda data_row: data_row.row_data and 'pdfUrl' not in data_row.row_data
data_row = wait_for_data_row_processing(client,
data_row,
compare_with_prev_media_attrs=True)
custom_check=custom_check)
assert data_row.row_data == pdf_url


Expand Down
Loading