Skip to content

Commit 9c838b0

Browse files
author
Val Brodsky
committed
Add prediction upload test by global key
1 parent 077a28b commit 9c838b0

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

tests/integration/annotation_import/test_data_types.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,51 @@ def test_import_data_types(
180180
data_row.delete()
181181

182182

183+
def test_import_data_types_by_global_key(
184+
client,
185+
configured_project,
186+
initial_dataset,
187+
rand_gen,
188+
data_row_json_by_data_type,
189+
annotations_by_data_type,
190+
):
191+
192+
project = configured_project
193+
project_id = project.uid
194+
dataset = initial_dataset
195+
data_type_class = ImageData
196+
set_project_media_type_from_data_type(project, data_type_class)
197+
198+
data_row_ndjson = data_row_json_by_data_type['image']
199+
data_row_ndjson['global_key'] = str(uuid.uuid4())
200+
data_row = create_data_row_for_project(project, dataset, data_row_ndjson,
201+
rand_gen(str))
202+
203+
annotations_ndjson = annotations_by_data_type['image']
204+
annotations_list = [
205+
label.annotations
206+
for label in NDJsonConverter.deserialize(annotations_ndjson)
207+
]
208+
labels = [
209+
lb_types.Label(data=data_type_class(global_key=data_row.global_key),
210+
annotations=annotations)
211+
for annotations in annotations_list
212+
]
213+
214+
label_import = lb.LabelImport.create_from_objects(client, project_id,
215+
f'test-import-image',
216+
labels)
217+
label_import.wait_until_done()
218+
219+
assert label_import.state == AnnotationImportState.FINISHED
220+
assert len(label_import.errors) == 0
221+
exported_labels = project.export_labels(download=True)
222+
objects = exported_labels[0]['Label']['objects']
223+
classifications = exported_labels[0]['Label']['classifications']
224+
assert len(objects) + len(classifications) == len(labels)
225+
data_row.delete()
226+
227+
183228
def validate_iso_format(date_string: str):
184229
parsed_t = datetime.datetime.fromisoformat(
185230
date_string) #this will blow up if the string is not in iso format

0 commit comments

Comments
 (0)