Skip to content

Commit 5a6e250

Browse files
author
Val Brodsky
committed
PR updates
1 parent 700fefe commit 5a6e250

File tree

7 files changed

+30
-24
lines changed

7 files changed

+30
-24
lines changed

tests/integration/annotation_import/conftest.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,14 +513,16 @@ def configured_project(client, initial_dataset, ontology, rand_gen, image_url):
513513
project._wait_until_data_rows_are_processed(data_row_ids=data_row_ids,
514514
sleep_interval=3)
515515

516-
project.create_batch(
516+
batch = project.create_batch(
517517
rand_gen(str),
518518
data_row_ids, # sample of data row objects
519519
5 # priority between 1(Highest) - 5(lowest)
520520
)
521521
project.data_row_ids = data_row_ids
522522

523523
yield project
524+
525+
batch.delete()
524526
project.delete()
525527

526528

@@ -614,8 +616,10 @@ def configured_project_with_one_data_row(client, ontology, rand_gen,
614616
This fixture has only one data row and all predictions will be mapped to it
615617
616618
Custom Data Row IDs Strategy:
617-
Individuals can create their own fixture to supply data row ids.
619+
Individuals can supply hard-coded data row ids when a creation of data row is not required.
618620
This particular fixture, termed "hardcoded_datarow_id," should be defined locally within a test file.
621+
In the future, we can use this approach to inject correct number of rows instead of using configured_project fixture
622+
that creates a data row for each member of ontology (14 in total) for each run.
619623
"""
620624

621625

tests/integration/annotation_import/test_bulk_import_request.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ def test_create_from_url(project):
4141
assert bulk_import_request.state == BulkImportRequestState.RUNNING
4242

4343

44-
def test_validate_file(project_with_ontology):
44+
def test_validate_file(project_with_empty_ontology):
4545
name = str(uuid.uuid4())
4646
url = "https://storage.googleapis.com/labelbox-public-bucket/predictions_test_v2.ndjson"
4747
with pytest.raises(MALValidationError):
48-
project_with_ontology.upload_annotations(name=name,
49-
annotations=url,
50-
validate=True)
48+
project_with_empty_ontology.upload_annotations(name=name,
49+
annotations=url,
50+
validate=True)
5151
#Schema ids shouldn't match
5252

5353

tests/integration/conftest.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
IMG_URL = "https://picsum.photos/200/300.jpg"
2929
SMALL_DATASET_URL = "https://storage.googleapis.com/lb-artifacts-testing-public/sdk_integration_test/potato.jpeg"
30+
DATA_ROW_PROCESSING_WAIT_TIMEOUT_SECONDS = 30
31+
DATA_ROW_PROCESSING_WAIT_SLEEP_INTERNAL_SECONDS = 3
3032

3133

3234
class Environ(Enum):
@@ -392,7 +394,7 @@ def initial_dataset(client, rand_gen):
392394

393395

394396
@pytest.fixture
395-
def project_with_ontology(project):
397+
def project_with_empty_ontology(project):
396398
editor = list(
397399
project.client.get_labeling_frontends(
398400
where=LabelingFrontend.name == "editor"))[0]
@@ -402,13 +404,13 @@ def project_with_ontology(project):
402404

403405

404406
@pytest.fixture
405-
def configured_project(project_with_ontology, initial_dataset, rand_gen,
407+
def configured_project(project_with_empty_ontology, initial_dataset, rand_gen,
406408
image_url):
407409
dataset = initial_dataset
408410
data_row_id = dataset.create_data_row(row_data=image_url).uid
409-
project = project_with_ontology
411+
project = project_with_empty_ontology
410412

411-
project.create_batch(
413+
batch = project.create_batch(
412414
rand_gen(str),
413415
[data_row_id], # sample of data row objects
414416
5 # priority between 1(Highest) - 5(lowest)
@@ -417,6 +419,8 @@ def configured_project(project_with_ontology, initial_dataset, rand_gen,
417419

418420
yield project
419421

422+
batch.delete()
423+
420424

421425
@pytest.fixture
422426
def configured_project_with_label(client, rand_gen, image_url, project, dataset,
@@ -426,21 +430,19 @@ def configured_project_with_label(client, rand_gen, image_url, project, dataset,
426430
Additionally includes a create_label method for any needed extra labels
427431
One label is already created and yielded when using fixture
428432
"""
429-
start_time = time.time()
430-
project._wait_until_data_rows_are_processed(data_row_ids=[data_row.uid],
431-
sleep_interval=3)
433+
project._wait_until_data_rows_are_processed(
434+
data_row_ids=[data_row.uid],
435+
wait_processing_max_seconds=DATA_ROW_PROCESSING_WAIT_TIMEOUT_SECONDS,
436+
sleep_interval=DATA_ROW_PROCESSING_WAIT_SLEEP_INTERNAL_SECONDS)
432437

433438
project.create_batch(
434439
rand_gen(str),
435440
[data_row.uid], # sample of data row objects
436441
5 # priority between 1(Highest) - 5(lowest)
437442
)
438-
print("create_batch took: ", time.time() - start_time)
439443
ontology = _setup_ontology(project)
440-
print("setup ontology took: ", time.time() - start_time)
441444
label = _create_label(project, data_row, ontology,
442445
wait_for_label_processing)
443-
print("create_label took: ", time.time() - start_time)
444446
yield [project, dataset, data_row, label]
445447

446448
for label in project.labels():

tests/integration/export_v2/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def configured_project_with_ontology(client, initial_dataset, ontology,
297297

298298

299299
@pytest.fixture
300-
def configured_project_with_one_data_row(client, ontology, rand_gen):
300+
def configured_project_without_data_rows(client, ontology, rand_gen):
301301
project = client.create_project(name=rand_gen(str),
302302
description=rand_gen(str),
303303
queue_mode=QueueMode.Batch)

tests/integration/export_v2/test_export_video.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
from labelbox.schema.annotation_import import AnnotationImportState
66

77

8-
def test_export_v2_video(client, configured_project_with_one_data_row,
8+
def test_export_v2_video(client, configured_project_without_data_rows,
99
video_data, video_data_row,
1010
bbox_video_annotation_objects, rand_gen):
1111

12-
project = configured_project_with_one_data_row
12+
project = configured_project_without_data_rows
1313
project_id = project.uid
1414
labels = []
1515
_, data_row_uids = video_data

tests/integration/test_filtering.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def project_to_test_where(client, rand_gen):
1515
p_b = client.create_project(name=p_b_name, queue_mode=QueueMode.Batch)
1616
p_c = client.create_project(name=p_c_name, queue_mode=QueueMode.Batch)
1717

18-
yield p_a, p_b, p_c
18+
yield p_a, p_b
1919

2020
p_a.delete()
2121
p_b.delete()
@@ -26,7 +26,7 @@ def project_to_test_where(client, rand_gen):
2626
# other builds simultaneously adding projects to test org
2727
def test_where(client, project_to_test_where):
2828
p_a, p_b, p_c = project_to_test_where
29-
p_a_name, p_b_name, _ = [p.name for p in [p_a, p_b, p_c]]
29+
p_a_name, p_b_name = [p.name for p in [p_a, p_b]]
3030

3131
def get(where=None):
3232
date_where = Project.created_at >= p_a.created_at

tests/integration/test_project.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,15 @@ def test_attach_instructions(client, project):
171171

172172
@pytest.mark.skipif(condition=os.environ['LABELBOX_TEST_ENVIRON'] == "onprem",
173173
reason="new mutation does not work for onprem")
174-
def test_html_instructions(project_with_ontology):
174+
def test_html_instructions(project_with_empty_ontology):
175175
html_file_path = '/tmp/instructions.html'
176176
sample_html_str = "<html></html>"
177177

178178
with open(html_file_path, 'w') as file:
179179
file.write(sample_html_str)
180180

181-
project_with_ontology.upsert_instructions(html_file_path)
182-
updated_ontology = project_with_ontology.ontology().normalized
181+
project_with_empty_ontology.upsert_instructions(html_file_path)
182+
updated_ontology = project_with_empty_ontology.ontology().normalized
183183

184184
instructions = updated_ontology.pop('projectInstructions')
185185
assert requests.get(instructions).text == sample_html_str

0 commit comments

Comments
 (0)