Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit 42c9bb4

Browse files
Update client.py
1 parent 687e3fa commit 42c9bb4

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

labelpandas/client.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def create_data_rows_from_table(
4343
verbose : Required (bool) - If True, prints information about code execution
4444
divider : Optional (str) - String delimiter for all name keys generated
4545
Returns:
46-
List of errors from data row upload - if successful, is an empty list
46+
List of errors from data row upload and a list of errors from table conversion - if either is successful, is an empty list
4747
"""
4848

4949
# Ensure all your metadata_index keys are metadata fields in Labelbox and that your Pandas DataFrame has all the right columns
@@ -57,22 +57,29 @@ def create_data_rows_from_table(
5757
return None
5858

5959
# Create a dictionary where {key=global_key : value=labelbox_upload_dictionary} - this is unique to Pandas
60-
result, global_key_to_upload_dict = connector.create_upload_dict(
60+
global_key_to_upload_dict, conversion_errors = connector.create_upload_dict(
6161
df=df, lb_client=self.lb_client, base_client=self.base_client,
6262
row_data_col=row_data_col, global_key_col=global_key_col, external_id_col=external_id_col,
6363
metadata_index=metadata_index, local_files=local_files, divider=divider, verbose=verbose
6464
)
6565

66-
if not result:
67-
return global_key_to_upload_dict
66+
if conversion_errors:
67+
if global_key_to_upload_dict:
68+
print(f'There were {len(conversion_errors)} errors in creating your upload list - upload will continue and return a list of errors as a second return value')
69+
else:
70+
print(f'There were {len(conversion_errors)} errors in creating your upload list - upload will not continue')
71+
return [], errors
6872

6973
# Upload your data rows to Labelbox
7074
upload_results = self.base_client.batch_create_data_rows(
7175
dataset=lb_dataset, global_key_to_upload_dict=global_key_to_upload_dict,
7276
skip_duplicates=skip_duplicates, divider=divider, verbose=verbose
7377
)
74-
75-
return upload_results
78+
79+
if conversion_errors:
80+
return upload_results, conversion_errors
81+
else:
82+
return upload_results, []
7683

7784
# def upsert_table_metadata():
7885
# return table

0 commit comments

Comments
 (0)