@@ -1004,29 +1004,33 @@ def assign_global_keys_to_data_rows(
10041004 ]["jobId" ]
10051005 }
10061006
1007- # TODO: Add a timeout to this based on success or not. output looks different than expected.
1008- # TODO: Current output of sanitized rows is not showing any output. all outputs are empty lists.
1009- # expected output {data, jobStatus} but seeing the assignment outputs above
1010-
1011- res = self .execute (get_failed_assignments_str ,
1012- get_failed_assignments_params )
1013- errors = []
1014- if res ['assignGlobalKeysToDataRowsResult' ][
1015- 'invalidGlobalKeyAssignments' ] is not None :
1016- errors .append ("Invalid Global Keys: " +
1017- str (res ['invalidGlobalKeyAssignments' ]))
1018- if res ['assignGlobalKeysToDataRowsResult' ][
1019- 'unmodifiedAssignments' ] is not None :
1020- errors .append ("Unmodified Assignments: " +
1021- str (res ['unmodifiedAssignments' ]))
1022- if res ['assignGlobalKeysToDataRowsResult' ][
1023- 'accessDeniedAssignments' ] is not None :
1024- errors .append ("Access Denied Assignments: " +
1025- str (res ['accessDeniedAssignments' ]))
1026- if len (errors ) > 0 :
1027- raise Exception ("Failed to assign global keys to data rows: " +
1028- str (errors ))
1029- return res ['assignGlobalKeysToDataRowsResult' ]['sanitizedAssignments' ]
1007+ while timeout >= 0 :
1008+ res = self .execute (get_failed_assignments_str ,
1009+ get_failed_assignments_params )
1010+ if res ["assignGlobalKeysToDataRowsResult" ][
1011+ "jobStatus" ] == "COMPLETE" :
1012+ errors = []
1013+ res = res ['assignGlobalKeysToDataRowsResult' ]
1014+ if res ['invalidGlobalKeyAssignments' ] is not None :
1015+ errors .append ("Invalid Global Keys: " +
1016+ str (res ['invalidGlobalKeyAssignments' ]))
1017+ if res ['unmodifiedAssignments' ] is not None :
1018+ errors .append ("Unmodified Assignments: " +
1019+ str (res ['unmodifiedAssignments' ]))
1020+ if res ['accessDeniedAssignments' ] is not None :
1021+ errors .append ("Access Denied Assignments: " +
1022+ str (res ['accessDeniedAssignments' ]))
1023+ if len (errors ) > 0 :
1024+ raise Exception (
1025+ "Failed to assign global keys to data rows: " +
1026+ str (errors ))
1027+ return res ['sanitizedAssignments' ]
1028+ time .sleep (2 )
1029+ timeout -= 2
1030+
1031+ raise labelbox .exceptions .TimeoutError (
1032+ "Timed out waiting for assign global keys to data rows job to complete."
1033+ )
10301034
10311035 def get_data_row_ids_for_global_keys (self ,
10321036 global_keys : List [str ],
@@ -1066,11 +1070,10 @@ def get_data_row_ids_for_global_keys(self,
10661070 while timeout >= 0 :
10671071 res = self .execute (get_data_rows_str , get_data_rows_params )
10681072 if res ["dataRowsForGlobalKeysResult" ]['jobStatus' ] == "COMPLETE" :
1069- # TODO: should consider deleted, not found, global keys return?
10701073 return res ["dataRowsForGlobalKeysResult" ]['data' ][
10711074 'fetchedDataRows' ]
10721075 time .sleep (2 )
10731076 timeout -= 2
10741077
1075- raise TimeoutError (
1078+ raise labelbox . exceptions . TimeoutError (
10761079 "Timed out waiting for data rows for global keys job to complete." )
0 commit comments