1
- import labelbase
1
+ from labelbase import Client as baseClient
2
2
from labelbox import Client
3
3
import pandas
4
4
from concurrent .futures import ThreadPoolExecutor , as_completed
5
5
6
- def create_upload_dict (df :pandas .core .frame .DataFrame , lb_client :Client , base_client :labelbase . Client , row_data_col :str ,
6
+ def create_upload_dict (df :pandas .core .frame .DataFrame , lb_client :Client , base_client :baseClient , row_data_col :str ,
7
7
global_key_col :str = "" , external_id_col :str = "" , metadata_index :dict = {}, local_files :bool = False , divider :str = "///" , verbose = False ):
8
8
""" Multithreads over a Pandas DataFrame, calling create_data_rows() on each row to return an upload dictionary
9
9
Args:
@@ -44,7 +44,7 @@ def create_upload_dict(df:pandas.core.frame.DataFrame, lb_client:Client, base_cl
44
44
print (f'Generated upload list - { len (global_key_to_upload_dict )} data rows to upload' )
45
45
return global_key_to_upload_dict
46
46
47
- def create_data_rows (lb_client :Client , base_client :labelbase . Client , row :pandas .core .series .Series ,
47
+ def create_data_rows (lb_client :Client , base_client :baseClient , row :pandas .core .series .Series ,
48
48
metadata_name_key_to_schema :dict , metadata_schema_to_name_key :dict , row_data_col :str ,
49
49
global_key_col :str = "" , external_id_col :str = "" , metadata_index :dict = {}, local_files = False , divider :str = "///" ):
50
50
""" Function to-be-multithreaded to create data row dictionaries from a Pandas DataFrame
@@ -63,8 +63,7 @@ def create_data_rows(lb_client:Client, base_client:labelbase.Client, row:pandas.
63
63
Returns:
64
64
Two items - the global_key, and a dictionary with "row_data", "global_key", "external_id" and "metadata_fields" keys
65
65
"""
66
- row_data_str = str (row [row_data_col ])
67
- row_data = labelbase .connector .upload_local_file (lb_client = lb_client , file_path = row_data_str ) if local_files else row_data_str
66
+ row_data = base_client .upload_local_file (file_path = str (row [row_data_col ])) if local_files else str (row [row_data_col ])
68
67
metadata_fields = [{"schema_id" : metadata_name_key_to_schema ['lb_integration_source' ], "value" : "Pandas" }]
69
68
if metadata_index :
70
69
for metadata_field_name in metadata_index .keys ():
0 commit comments