Skip to content

Commit 449fac4

Browse files
authored
Merge branch 'develop' into PNO/SN-149_project.clone
2 parents 12f4e5c + c3e3f37 commit 449fac4

File tree

9 files changed

+79
-34
lines changed

9 files changed

+79
-34
lines changed

libs/labelbox/src/labelbox/schema/export_task.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,3 +920,4 @@ def get_stream(
920920
def get_task(client, task_id):
921921
"""Returns the task with the given id."""
922922
return ExportTask(Task.get_task(client, task_id))
923+

libs/labelbox/tests/conftest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,10 @@ def export_v2_test_helpers() -> Type[ExportV2Helpers]:
929929

930930
@pytest.fixture
931931
def big_dataset_data_row_ids(big_dataset: Dataset):
932-
yield [dr.uid for dr in list(big_dataset.export_data_rows())]
932+
export_task = big_dataset.export()
933+
export_task.wait_till_done()
934+
stream = export_task.get_buffered_stream()
935+
yield [dr.json["data_row"]["id"] for dr in stream]
933936

934937

935938
@pytest.fixture(scope='function')

libs/labelbox/tests/data/annotation_import/test_send_to_annotate_mea.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_send_to_annotate_from_model(client, configured_project,
5555
# Check that the data row was sent to the new project
5656
destination_batches = list(destination_project.batches())
5757
assert len(destination_batches) == 1
58-
58+
5959
destination_data_rows = list(destination_batches[0].export_data_rows())
6060
assert len(destination_data_rows) == len(data_row_ids)
6161
assert all([dr.uid in data_row_ids for dr in destination_data_rows])

libs/labelbox/tests/integration/conftest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,10 @@ def export_v2_test_helpers() -> Type[ExportV2Helpers]:
314314

315315
@pytest.fixture
316316
def big_dataset_data_row_ids(big_dataset: Dataset):
317-
yield [dr.uid for dr in list(big_dataset.export_data_rows())]
317+
export_task = big_dataset.export()
318+
export_task.wait_till_done()
319+
stream = export_task.get_buffered_stream()
320+
yield [dr.json["data_row"]["id"] for dr in stream]
318321

319322

320323
@pytest.fixture(scope='function')

libs/labelbox/tests/integration/test_batch.py

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import time
22
from typing import List
33
from uuid import uuid4
4-
54
import pytest
65

76
from labelbox import Dataset, Project
@@ -92,7 +91,10 @@ def test_create_batch_async(project: Project,
9291

9392
def test_create_batch_with_consensus_settings(project: Project,
9493
small_dataset: Dataset):
95-
data_rows = [dr.uid for dr in list(small_dataset.export_data_rows())]
94+
export_task = small_dataset.export()
95+
export_task.wait_till_done()
96+
stream = export_task.get_buffered_stream()
97+
data_rows = [dr.json["data_row"]["id"] for dr in stream]
9698
consensus_settings = {"coverage_percentage": 0.1, "number_of_labels": 3}
9799
batch = project.create_batch("batch with consensus settings",
98100
data_rows,
@@ -105,31 +107,44 @@ def test_create_batch_with_consensus_settings(project: Project,
105107

106108
def test_create_batch_with_data_row_class(project: Project,
107109
small_dataset: Dataset):
108-
data_rows = list(small_dataset.export_data_rows())
110+
export_task = small_dataset.export()
111+
export_task.wait_till_done()
112+
stream = export_task.get_buffered_stream()
113+
data_rows = [dr.json["data_row"]["id"] for dr in stream]
109114
batch = project.create_batch("test-batch-data-rows", data_rows, 3)
110115
assert batch.name == "test-batch-data-rows"
111116
assert batch.size == len(data_rows)
112117

113118

114119
def test_archive_batch(project: Project, small_dataset: Dataset):
115-
data_rows = [dr.uid for dr in list(small_dataset.export_data_rows())]
120+
export_task = small_dataset.export()
121+
export_task.wait_till_done()
122+
stream = export_task.get_buffered_stream()
123+
data_rows = [dr.json["data_row"]["id"] for dr in stream]
124+
116125
batch = project.create_batch("batch to archive", data_rows)
117126
batch.remove_queued_data_rows()
118-
exported_data_rows = list(batch.export_data_rows())
119-
120-
assert len(exported_data_rows) == 0
127+
overview = project.get_overview()
128+
129+
assert overview.to_label == 0
121130

122131

123132
def test_delete(project: Project, small_dataset: Dataset):
124-
data_rows = [dr.uid for dr in list(small_dataset.export_data_rows())]
133+
export_task = small_dataset.export()
134+
export_task.wait_till_done()
135+
stream = export_task.get_buffered_stream()
136+
data_rows = [dr.json["data_row"]["id"] for dr in stream]
125137
batch = project.create_batch("batch to delete", data_rows)
126138
batch.delete()
127139

128140
assert len(list(project.batches())) == 0
129141

130142

131143
def test_batch_project(project: Project, small_dataset: Dataset):
132-
data_rows = [dr.uid for dr in list(small_dataset.export_data_rows())]
144+
export_task = small_dataset.export()
145+
export_task.wait_till_done()
146+
stream = export_task.get_buffered_stream()
147+
data_rows = [dr.json["data_row"]["id"] for dr in stream]
133148
batch = project.create_batch("batch to test project relationship",
134149
data_rows)
135150

@@ -186,6 +201,7 @@ def test_batch_creation_with_processing_timeout(
186201
project._wait_processing_max_seconds = stashed_wait_timeout
187202

188203

204+
@pytest.mark.export_v1("export_v1 test remove later")
189205
def test_export_data_rows(project: Project, dataset: Dataset, image_url: str,
190206
external_id: str):
191207
n_data_rows = 2
@@ -255,18 +271,34 @@ def test_list_project_batches_with_no_batches(project: Project):
255271
reason="Test cannot be used effectively with MAL/LabelImport. \
256272
Fix/Unskip after resolving deletion with MAL/LabelImport")
257273
def test_delete_labels(project, small_dataset):
258-
data_rows = [dr.uid for dr in list(small_dataset.export_data_rows())]
274+
export_task = small_dataset.export()
275+
export_task.wait_till_done()
276+
stream = export_task.get_buffered_stream()
277+
data_rows = [dr.json["data_row"]["id"] for dr in stream]
259278
batch = project.create_batch("batch to delete labels", data_rows)
260279

261280

262281
@pytest.mark.skip(
263282
reason="Test cannot be used effectively with MAL/LabelImport. \
264283
Fix/Unskip after resolving deletion with MAL/LabelImport")
265284
def test_delete_labels_with_templates(project: Project, small_dataset: Dataset):
266-
data_rows = [dr.uid for dr in list(small_dataset.export_data_rows())]
285+
export_task = small_dataset.export()
286+
export_task.wait_till_done()
287+
stream = export_task.get_buffered_stream()
288+
data_rows = [dr.json["data_row"]["id"] for dr in stream]
267289
batch = project.create_batch("batch to delete labels w templates",
268290
data_rows)
269-
exported_data_rows = list(batch.export_data_rows())
291+
292+
export_task = project.export(filters={"batch_ids": [batch.uid]})
293+
export_task.wait_till_done()
294+
stream = export_task.get_buffered_stream()
295+
exported_data_rows = [dr.json["data_row"]["id"] for dr in stream]
296+
270297
res = batch.delete_labels(labels_as_template=True)
271-
exported_data_rows = list(batch.export_data_rows())
298+
299+
export_task = project.export(filters={"batch_ids": [batch.uid]})
300+
export_task.wait_till_done()
301+
stream = export_task.get_buffered_stream()
302+
exported_data_rows = [dr.json["data_row"]["id"] for dr in stream]
303+
272304
assert len(exported_data_rows) == 5

libs/labelbox/tests/integration/test_batches.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ def test_create_batches(project: Project, big_dataset_data_row_ids: List[str]):
2020

2121

2222
def test_create_batches_from_dataset(project: Project, big_dataset: Dataset):
23-
data_rows = [dr.uid for dr in list(big_dataset.export_data_rows())]
23+
export_task = big_dataset.export()
24+
export_task.wait_till_done()
25+
stream = export_task.get_buffered_stream()
26+
data_rows = [dr.json["data_row"]["id"] for dr in stream]
2427
project._wait_until_data_rows_are_processed(data_rows, [], 300)
2528

2629
task = project.create_batches_from_dataset("test-batch",

libs/labelbox/tests/integration/test_project.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import time
22
import os
33
import uuid
4-
54
import pytest
65
import requests
76

@@ -201,8 +200,10 @@ def test_batches(project: Project, dataset: Dataset, image_url):
201200
},
202201
] * 2)
203202
task.wait_till_done()
204-
# TODO: Move to export_v2
205-
data_rows = [dr.uid for dr in list(dataset.export_data_rows())]
203+
export_task = dataset.export()
204+
export_task.wait_till_done()
205+
stream = export_task.get_buffered_stream()
206+
data_rows = [dr.json["data_row"]["id"] for dr in stream]
206207
batch_one = f'batch one {uuid.uuid4()}'
207208
batch_two = f'batch two {uuid.uuid4()}'
208209
project.create_batch(batch_one, [data_rows[0]])
@@ -217,19 +218,17 @@ def test_create_batch_with_global_keys_sync(project: Project, data_rows):
217218
global_keys = [dr.global_key for dr in data_rows]
218219
batch_name = f'batch {uuid.uuid4()}'
219220
batch = project.create_batch(batch_name, global_keys=global_keys)
220-
# TODO: Move to export_v2
221-
batch_data_rows = set(batch.export_data_rows())
222-
assert batch_data_rows == set(data_rows)
221+
222+
assert batch.size == len(set(data_rows))
223223

224224

225225
@pytest.mark.parametrize('data_rows', [2], indirect=True)
226226
def test_create_batch_with_global_keys_async(project: Project, data_rows):
227227
global_keys = [dr.global_key for dr in data_rows]
228228
batch_name = f'batch {uuid.uuid4()}'
229229
batch = project._create_batch_async(batch_name, global_keys=global_keys)
230-
# TODO: Move to export_v2
231-
batch_data_rows = set(batch.export_data_rows())
232-
assert batch_data_rows == set(data_rows)
230+
231+
assert batch.size == len(set(data_rows))
233232

234233

235234
def test_media_type(client, project: Project, rand_gen):

libs/labelbox/tests/integration/test_send_to_annotate.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
from labelbox import UniqueIds, OntologyBuilder, LabelingFrontend
1+
from labelbox import UniqueIds, Project, Ontology, Client
22
from labelbox.schema.conflict_resolution_strategy import ConflictResolutionStrategy
3+
from typing import List
34

45

56
def test_send_to_annotate_include_annotations(
6-
client, configured_batch_project_with_label, project_pack, ontology):
7+
client: Client, configured_batch_project_with_label: Project, project_pack: List[Project], ontology: Ontology):
78
[source_project, _, data_row, _] = configured_batch_project_with_label
8-
destination_project = project_pack[0]
9+
destination_project: Project = project_pack[0]
910

1011
src_ontology = source_project.ontology()
1112
destination_project.setup_editor(ontology)
@@ -45,10 +46,14 @@ def test_send_to_annotate_include_annotations(
4546
# Check that the data row was sent to the new project
4647
destination_batches = list(destination_project.batches())
4748
assert len(destination_batches) == 1
48-
49-
destination_data_rows = list(destination_batches[0].export_data_rows())
49+
50+
export_task = destination_project.export()
51+
export_task.wait_till_done()
52+
stream = export_task.get_buffered_stream()
53+
54+
destination_data_rows = [dr.json["data_row"]["id"] for dr in stream]
5055
assert len(destination_data_rows) == 1
51-
assert destination_data_rows[0].uid == data_row.uid
56+
assert destination_data_rows[0] == data_row.uid
5257

5358
# Verify annotations were copied into the destination project
5459
destination_project_labels = (list(destination_project.labels()))

libs/labelbox/tests/integration/test_task.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,9 @@ def test_task_success_json(dataset, image_url, snapshot):
5858
'test_task.test_task_success_json.json')
5959
assert len(task.result)
6060

61-
61+
@pytest.mark.export_v1("export_v1 test remove later")
6262
def test_task_success_label_export(client, configured_project_with_label):
6363
project, _, _, _ = configured_project_with_label
64-
# TODO: Move to export_v2
6564
project.export_labels()
6665
user = client.get_user()
6766
task = None

0 commit comments

Comments
 (0)