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

Commit 03d893a

Browse files
Update client.py
1 parent 4837852 commit 03d893a

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

labelpandas/client.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from labelbox import Client as labelboxClient
22
from labelbox.schema.dataset import Dataset as labelboxDataset
33
from labelbase.metadata import sync_metadata_fields
4-
from labelbase.uploader import batch_create_data_rows, batch_upload_annotations, batch_rows_to_project
4+
from labelbase import uploader
55
import pandas as pd
66
from labelpandas import connector
77

@@ -101,18 +101,27 @@ def create_data_rows_from_table(
101101
return {"upload_results" : [], "conversion_errors" : errors}
102102

103103
# Upload your data rows to Labelbox
104-
data_row_upload_results = batch_create_data_rows(
104+
data_row_upload_results = uploader.batch_create_data_rows(
105105
client=self.lb_client, dataset=lb_dataset, global_key_to_upload_dict=global_key_to_upload_dict,
106106
skip_duplicates=skip_duplicates, divider=divider, verbose=verbose
107107
)
108108

109+
# Default global_key_col if row_data_col not provided
110+
global_key_col = global_key_col if global_key_col else row_data_col
111+
112+
# Create a dictionary where {key=global_key : value=data_row_id}
113+
global_key_to_data_row_id = uploader.create_global_key_to_data_row_dict(
114+
client=self.lb_client, global_keys=connector.get_unique_values_function(table, global_key_col)
115+
)
116+
109117
# Create a dictionary where {key=project_id : value=list_of_data_row_ids}, if applicable
110118
project_id_to_batch_dict = connector.create_batches(
111-
client=self.lb_client, table=table, global_key_col=global_key_col, project_id_col=project_id_col
119+
client=self.lb_client, table=table, global_key_col=global_key_col,
120+
project_id_col=project_id_col, global_key_to_data_row_id=global_key_to_data_row_id
112121
)
113122

114123
# Batch data rows to projects, if applicable
115-
batch_results = batch_rows_to_project(
124+
batch_results = uploader.batch_rows_to_project(
116125
client=self.lb_client, project_id_to_batch_dict, priority=priority
117126
)
118127

@@ -123,7 +132,7 @@ def create_data_rows_from_table(
123132
)
124133

125134
# Upload your annotations to Labelbox, if applicable
126-
annotation_upload_results = batch_upload_annotations(
135+
annotation_upload_results = uploader.batch_upload_annotations(
127136
client=self.lb_client, project_id_to_upload_dict=project_id_to_upload_dict, how=upload_method, verbose=verbose
128137
)
129138

0 commit comments

Comments
 (0)