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

Commit 7535115

Browse files
Update connector.py
1 parent fa4f2ec commit 7535115

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

labelpandas/connector.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import labelbase
1+
from labelbase import Client as baseClient
22
from labelbox import Client
33
import pandas
44
from concurrent.futures import ThreadPoolExecutor, as_completed
55

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,
77
global_key_col:str="", external_id_col:str="", metadata_index:dict={}, local_files:bool=False, divider:str="///", verbose=False):
88
""" Multithreads over a Pandas DataFrame, calling create_data_rows() on each row to return an upload dictionary
99
Args:
@@ -44,7 +44,7 @@ def create_upload_dict(df:pandas.core.frame.DataFrame, lb_client:Client, base_cl
4444
print(f'Generated upload list - {len(global_key_to_upload_dict)} data rows to upload')
4545
return global_key_to_upload_dict
4646

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,
4848
metadata_name_key_to_schema:dict, metadata_schema_to_name_key:dict, row_data_col:str,
4949
global_key_col:str="", external_id_col:str="", metadata_index:dict={}, local_files=False, divider:str="///"):
5050
""" 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.
6363
Returns:
6464
Two items - the global_key, and a dictionary with "row_data", "global_key", "external_id" and "metadata_fields" keys
6565
"""
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])
6867
metadata_fields = [{"schema_id" : metadata_name_key_to_schema['lb_integration_source'], "value" : "Pandas"}]
6968
if metadata_index:
7069
for metadata_field_name in metadata_index.keys():

0 commit comments

Comments
 (0)