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

Commit 9e6e58e

Browse files
Luke MoehlenbrockLuke Moehlenbrock
authored andcommitted
Update labelpandas to fix bugs with upsert_data_rows_from_table
1 parent 66e8e06 commit 9e6e58e

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

labelpandas/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def create_data_rows_from_table(
229229
# Returns:
230230
# Results from all performed actions in a dictionary - if an expected action has no results, it was not performed
231231
# """
232-
def upsert_data_rows_from_table(self, table:pd.core.frame.DataFrame, dataset_id:str="", batch_data_rows:bool=False, annotation_method:str="", divider:str="///"):
232+
def upsert_data_rows_from_table(self, table:pd.core.frame.DataFrame, dataset_id:str="", project_id:str="", model_id:str="", upload_method:str="", mask_method:str="png", priority:int=5, model_run_id:str="", batch_data_rows:bool=False, verbose:bool=False, divider:str="///"):
233233
""" Performs the following actions if proper information is provided:
234234
- batches data rows to projects (if batch_data_rows == True) * **
235235
- uploads annotations as pre-labels or submitted labels * **
@@ -273,7 +273,7 @@ def upsert_data_rows_from_table(self, table:pd.core.frame.DataFrame, dataset_id:
273273
actions = determine_actions(
274274
row_data_col=x["row_data_col"], dataset_id=dataset_id, dataset_id_col=x["dataset_id_col"], project_id=project_id,
275275
project_id_col=x["project_id_col"], model_id=model_id, model_id_col=x["model_id_col"], model_run_id=model_run_id,
276-
model_run_id_col=x["model_run_id_col"], upload_method=label_method, metadata_index=x["metadata_index"],
276+
model_run_id_col=x["model_run_id_col"], upload_method=upload_method, metadata_index=x["metadata_index"],
277277
attachment_index=x["attachment_index"], annotation_index=x["annotation_index"], prediction_index=x["prediction_index"]
278278
)
279279

@@ -299,7 +299,7 @@ def upsert_data_rows_from_table(self, table:pd.core.frame.DataFrame, dataset_id:
299299
model_run_id_col=x["model_run_id_col"], model_run_id=model_run_id,
300300
metadata_index=x["metadata_index"], attachment_index=x["attachment_index"],
301301
annotation_index=x["annotation_index"], prediction_index=x["prediction_index"],
302-
create_action=actions["create"], annotate_action=actions["annotate"], prediction_action=actions["predictions"],
302+
create_action=actions["create"], annotate_action=actions["annotate"], prediction_action=actions["predictions"], batch_action=actions["batch"],
303303
upload_method=upload_method, mask_method=mask_method, divider=divider, verbose=verbose
304304
)
305305

labelpandas/uploader.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def create_upload_dict(client:labelboxClient, table: pandas.core.frame.DataFrame
3636
dataset_id_col:str, dataset_id:str, project_id_col:str, project_id:str,
3737
model_id_col:str, model_id:str, model_run_id_col:str, model_run_id:str,
3838
metadata_index:dict, attachment_index:dict, annotation_index:dict, prediction_index:dict,
39-
create_action, annotate_action, prediction_action,
39+
create_action, annotate_action, prediction_action, batch_action,
4040
upload_method:str, mask_method:str, divider:str, verbose:bool, extra_client:bool=None):
4141
"""
4242
Args:
@@ -96,6 +96,7 @@ def create_upload_dict(client:labelboxClient, table: pandas.core.frame.DataFrame
9696
ontology=client.get_project(projectId).ontology(),
9797
divider=divider, invert=True, detailed=True
9898
)
99+
ontology_index['project_type'] = str(client.get_project(projectId).media_type)
99100
project_id_to_ontology_index[projectId] = ontology_index
100101
# Get dictionary where {key=model_run_id : value=ontology_index}
101102
model_run_id_to_ontology_index = {}
@@ -143,7 +144,7 @@ def create_upload_dict(client:labelboxClient, table: pandas.core.frame.DataFrame
143144
model_id_col, model_id, model_run_id_col, model_run_id,
144145
metadata_index, attachment_index, annotation_index, prediction_index,
145146
project_id_to_ontology_index, model_run_id_to_ontology_index, model_id_to_model_run_id,
146-
create_action, annotate_action, prediction_action,
147+
create_action, annotate_action, prediction_action, batch_action,
147148
metadata_name_key_to_schema, upload_method, mask_method, divider, verbose
148149
))
149150
for f in as_completed(futures):
@@ -166,7 +167,7 @@ def create_upload(row_dict:dict, row_data_col:str, global_key_col:str, external_
166167
model_id_col:str, model_id:str, model_run_id_col:str, model_run_id:str,
167168
metadata_index:dict, attachment_index:dict, annotation_index:dict, prediction_index:dict,
168169
project_id_to_ontology_index:dict, model_run_id_to_ontology_index:dict, model_id_to_model_run_id:dict,
169-
create_action:bool, annotate_action:bool, prediction_action:bool,
170+
create_action:bool, annotate_action:bool, prediction_action:bool, batch_action:bool,
170171
metadata_name_key_to_schema:dict, upload_method:str, mask_method:str,
171172
divider:str, verbose:bool):
172173
""" Takes a single table row as-a-dictinary and returns a dictionary where:
@@ -213,7 +214,7 @@ def create_upload(row_dict:dict, row_data_col:str, global_key_col:str, external_
213214
modelRunId = ""
214215
# Create a base data row dictionary
215216
data_row = {}
216-
if create_action:
217+
if create_action or batch_action:
217218
data_row["row_data"] = row_dict[row_data_col]
218219
data_row["global_key"] = row_dict[global_key_col]
219220
data_row["external_id"] = row_dict[external_id_col]

0 commit comments

Comments
 (0)