Skip to content
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
13 changes: 8 additions & 5 deletions labelbox/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1114,8 +1114,11 @@ def _format_failed_rows(rows: Dict[str, str],
sanitized=False))
# Failed assignments
errors.extend(
_format_failed_rows(rows=res['invalidGlobalKeyAssignments'],
error_msg="Invalid global key"))
_format_failed_rows(
rows=res['invalidGlobalKeyAssignments'],
error_msg=
"Invalid assignment. Either DataRow does not exist, or globalKey is invalid"
))
errors.extend(
_format_failed_rows(rows=res['accessDeniedAssignments'],
error_msg="Access denied to Data Row"))
Expand Down Expand Up @@ -1270,13 +1273,13 @@ def clear_global_keys(
'Errors' contains a list of global_keys correspond to the data rows that could not be
modified, accessed by the user, or not found.
Examples:
>>> job_result = client.get_data_row_ids_for_global_keys(["key1","key2"])
>>> job_result = client.clear_global_keys(["key1","key2","notfoundkey"])
>>> print(job_result['status'])
Partial Success
>>> print(job_result['results'])
['cl7tv9wry00hlka6gai588ozv', 'cl7tv9wxg00hpka6gf8sh81bj']
['key1', 'key2']
>>> print(job_result['errors'])
[{'global_key': 'asdf', 'error': 'Data Row not found'}]
[{'global_key': 'notfoundkey', 'error': 'Failed to find data row matching provided global key'}]
"""

def _format_failed_rows(rows: List[str],
Expand Down
13 changes: 9 additions & 4 deletions tests/integration/test_global_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ def test_assign_same_global_keys_to_data_rows(client, dataset, image_url):
assert len(res['errors']) == 1
assert res['errors'][0]['data_row_id'] == dr_2.uid
assert res['errors'][0]['global_key'] == gk_1
assert res['errors'][0]['error'] == "Invalid global key"
assert res['errors'][0][
'error'] == "Invalid assignment. Either DataRow does not exist, or globalKey is invalid"


def test_global_key_sanitization(dataset, image_url):
Expand Down Expand Up @@ -111,7 +112,8 @@ def test_long_global_key_validation(client, dataset, image_url):
assert res['results'][0]['global_key'] == gk_1
assert res['errors'][0]['data_row_id'] == dr_2.uid
assert res['errors'][0]['global_key'] == gk_2
assert res['errors'][0]['error'] == 'Invalid global key'
assert res['errors'][0][
'error'] == 'Invalid assignment. Either DataRow does not exist, or globalKey is invalid'


def test_global_key_with_whitespaces_validation(client, dataset, image_url):
Expand Down Expand Up @@ -143,8 +145,11 @@ def test_global_key_with_whitespaces_validation(client, dataset, image_url):
assign_errors_msgs = set([e['error'] for e in res['errors']])
assert assign_errors_ids == set([dr_1.uid, dr_2.uid, dr_3.uid])
assert assign_errors_gks == set([gk_1, gk_2, gk_3])
assert assign_errors_msgs == set(
['Invalid global key', 'Invalid global key', 'Invalid global key'])
assert assign_errors_msgs == set([
'Invalid assignment. Either DataRow does not exist, or globalKey is invalid',
'Invalid assignment. Either DataRow does not exist, or globalKey is invalid',
'Invalid assignment. Either DataRow does not exist, or globalKey is invalid'
])


@pytest.mark.skip(reason='get_data_rows_for_global_keys not included in '
Expand Down