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

Commit e7d70e3

Browse files
Luke MoehlenbrockLuke Moehlenbrock
Luke Moehlenbrock
authored and
Luke Moehlenbrock
committed
add check for global keys that are too long
1 parent 0387e1d commit e7d70e3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

labelpandas/uploader.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from labelbase.models import create_model_run_with_name
3131
from labelbase.annotate import create_ndjsons
3232
from concurrent.futures import ThreadPoolExecutor, as_completed
33+
from uuid import uuid4
3334

3435
def create_upload_dict(client:labelboxClient, table: pandas.core.frame.DataFrame, table_dict:dict,
3536
row_data_col:str, global_key_col:str, external_id_col:str,
@@ -221,9 +222,14 @@ def create_upload(row_dict:dict, row_data_col:str, global_key_col:str, external_
221222
modelRunId = ""
222223
# Create a base data row dictionary
223224
data_row = {}
224-
if create_action or batch_action:
225+
if create_action or batch_action:
225226
data_row["row_data"] = row_dict[row_data_col]
226-
data_row["global_key"] = row_dict[global_key_col]
227+
if len(row_dict[global_key_col]) <= 200:
228+
data_row["global_key"] = row_dict[global_key_col]
229+
else:
230+
if verbose:
231+
print("Global key too long (>200 characters). Replacing with randomly generated global key.")
232+
data_row["global_key"] = str(uuid4())
227233
if external_id_col in row_dict.keys():
228234
data_row["external_id"] = row_dict[external_id_col]
229235
# Create a list of metadata for a data row

0 commit comments

Comments
 (0)