Skip to content

Commit a616788

Browse files
author
Val Brodsky
committed
Support global keys for Project update_data_row_labeling_priority
1 parent 3f894f0 commit a616788

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

labelbox/schema/project.py

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,10 +1185,26 @@ def set_labeling_parameter_overrides(self, data) -> bool:
11851185
res = self.client.execute(query_str, {id_param: self.uid})
11861186
return res["project"]["setLabelingParameterOverrides"]["success"]
11871187

1188+
@overload
1189+
def update_data_row_labeling_priority(
1190+
self,
1191+
data_rows: DataRowIdentifiers,
1192+
priority: int,
1193+
) -> bool:
1194+
pass
1195+
1196+
@overload
11881197
def update_data_row_labeling_priority(
11891198
self,
11901199
data_rows: List[str],
11911200
priority: int,
1201+
) -> bool:
1202+
pass
1203+
1204+
def update_data_row_labeling_priority(
1205+
self,
1206+
data_rows,
1207+
priority: int,
11921208
) -> bool:
11931209
"""
11941210
Updates labeling parameter overrides to this project in bulk. This method allows up to 1 million data rows to be
@@ -1198,25 +1214,31 @@ def update_data_row_labeling_priority(
11981214
https://docs.labelbox.com/en/configure-editor/queue-system#reservation-system
11991215
12001216
Args:
1201-
data_rows (iterable): An iterable of data row ids.
1217+
data_rows: a list of data row ids to update priorities for. This can be a list of strings or a DataRowIdentifiers object
1218+
DataRowIdentifier objects are lists of ids or global keys. A DataIdentifier object can be a UniqueIds or GlobalKeys class.
12021219
priority (int): Priority for the new override. See above for more information.
12031220
12041221
Returns:
12051222
bool, indicates if the operation was a success.
12061223
"""
12071224

1225+
if isinstance(data_rows, list):
1226+
data_rows = UniqueIds(data_rows)
1227+
warnings.warn("Using data row ids will be deprecated. Please use "
1228+
"UniqueIds or GlobalKeys instead.")
1229+
12081230
method = "createQueuePriorityUpdateTask"
12091231
priority_param = "priority"
12101232
project_param = "projectId"
1211-
data_rows_param = "dataRowIds"
1233+
data_rows_param = "dataRowIdentifiers"
12121234
query_str = """mutation %sPyApi(
12131235
$%s: Int!
12141236
$%s: ID!
1215-
$%s: [ID!]
1237+
$%s: QueuePriorityUpdateDataRowIdentifiersInput
12161238
) {
12171239
project(where: { id: $%s }) {
12181240
%s(
1219-
data: { priority: $%s, dataRowIds: $%s }
1241+
data: { priority: $%s, dataRowIdentifiers: $%s }
12201242
) {
12211243
taskId
12221244
}
@@ -1228,7 +1250,10 @@ def update_data_row_labeling_priority(
12281250
query_str, {
12291251
priority_param: priority,
12301252
project_param: self.uid,
1231-
data_rows_param: data_rows
1253+
data_rows_param: {
1254+
"ids": [id for id in data_rows],
1255+
"idType": data_rows._id_type,
1256+
},
12321257
})["project"][method]
12331258

12341259
task_id = res['taskId']

0 commit comments

Comments
 (0)