diff --git a/labelbox/client.py b/labelbox/client.py index 4d46a5024..e5e10db7c 100644 --- a/labelbox/client.py +++ b/labelbox/client.py @@ -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")) @@ -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], diff --git a/tests/integration/test_global_keys.py b/tests/integration/test_global_keys.py index 078356a9c..e3fff7b80 100644 --- a/tests/integration/test_global_keys.py +++ b/tests/integration/test_global_keys.py @@ -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): @@ -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): @@ -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 '