Skip to content

Commit 4715db5

Browse files
authored
[AL-6724] fix assert for ADV (#1191)
2 parents d095424 + 3c9a3f3 commit 4715db5

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

labelbox/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ def _get_single(self, db_object_type, uid):
427427
else:
428428
return db_object_type(self, res)
429429

430-
def get_project(self, project_id):
430+
def get_project(self, project_id) -> Project:
431431
""" Gets a single Project with the given ID.
432432
433433
>>> project = client.get_project("<project_id>")

tests/integration/test_data_rows.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -908,27 +908,40 @@ def test_data_row_bulk_creation_sync_with_unique_global_keys(
908908

909909

910910
def test_data_row_bulk_creation_sync_with_same_global_keys(
911-
dataset, sample_image):
911+
dataset, sample_image, is_adv_enabled):
912912
global_key_1 = str(uuid.uuid4())
913913

914-
with pytest.raises(labelbox.exceptions.MalformedQueryException):
914+
if is_adv_enabled:
915+
# ADV does not throw an error for duplicate global keys
916+
# but rather create the first one and reject the second
915917
dataset.create_data_rows_sync([{
916918
DataRow.row_data: sample_image,
917919
DataRow.global_key: global_key_1
918920
}, {
919921
DataRow.row_data: sample_image,
920922
DataRow.global_key: global_key_1
921923
}])
924+
assert len(list(dataset.data_rows())) == 1
925+
assert list(dataset.data_rows())[0].global_key == global_key_1
926+
else:
927+
with pytest.raises(labelbox.exceptions.MalformedQueryException):
928+
dataset.create_data_rows_sync([{
929+
DataRow.row_data: sample_image,
930+
DataRow.global_key: global_key_1
931+
}, {
932+
DataRow.row_data: sample_image,
933+
DataRow.global_key: global_key_1
934+
}])
922935

923-
assert len(list(dataset.data_rows())) == 0
936+
assert len(list(dataset.data_rows())) == 0
924937

925-
dataset.create_data_rows_sync([{
926-
DataRow.row_data: sample_image,
927-
DataRow.global_key: global_key_1
928-
}])
938+
dataset.create_data_rows_sync([{
939+
DataRow.row_data: sample_image,
940+
DataRow.global_key: global_key_1
941+
}])
929942

930-
assert len(list(dataset.data_rows())) == 1
931-
assert list(dataset.data_rows())[0].global_key == global_key_1
943+
assert len(list(dataset.data_rows())) == 1
944+
assert list(dataset.data_rows())[0].global_key == global_key_1
932945

933946

934947
def test_create_conversational_text(dataset, conversational_content):

0 commit comments

Comments
 (0)