|
1 | 1 | import json |
2 | 2 | import logging |
3 | 3 | import time |
| 4 | +import warnings |
4 | 5 | from collections import namedtuple |
5 | 6 | from datetime import datetime, timezone |
6 | 7 | from pathlib import Path |
@@ -231,6 +232,9 @@ def export_queued_data_rows( |
231 | 232 | Raises: |
232 | 233 | LabelboxError: if the export fails or is unable to download within the specified time. |
233 | 234 | """ |
| 235 | + warnings.warn( |
| 236 | + "You are currently utilizing exports v1 for this action, which will be deprecated after December 31st, 2023. We recommend transitioning to exports v2. To view export v2 details, visit our docs: https://docs.labelbox.com/reference/label-export", |
| 237 | + DeprecationWarning) |
234 | 238 | id_param = "projectId" |
235 | 239 | metadata_param = "includeMetadataInput" |
236 | 240 | query_str = """mutation GetQueuedDataRowsExportUrlPyApi($%s: ID!, $%s: Boolean!) |
@@ -334,6 +338,9 @@ def export_labels(self, |
334 | 338 | URL of the data file with this Project's labels. If the server didn't |
335 | 339 | generate during the `timeout_seconds` period, None is returned. |
336 | 340 | """ |
| 341 | + warnings.warn( |
| 342 | + "You are currently utilizing exports v1 for this action, which will be deprecated after December 31st, 2023. We recommend transitioning to exports v2. To view export v2 details, visit our docs: https://docs.labelbox.com/reference/label-export", |
| 343 | + DeprecationWarning) |
337 | 344 |
|
338 | 345 | def _string_from_dict(dictionary: dict, value_with_quotes=False) -> str: |
339 | 346 | """Returns a concatenated string of the dictionary's keys and values |
@@ -1166,6 +1173,60 @@ def set_labeling_parameter_overrides(self, data) -> bool: |
1166 | 1173 | res = self.client.execute(query_str, {id_param: self.uid}) |
1167 | 1174 | return res["project"]["setLabelingParameterOverrides"]["success"] |
1168 | 1175 |
|
| 1176 | + def update_data_row_labeling_priority( |
| 1177 | + self, |
| 1178 | + data_rows: List[str], |
| 1179 | + priority: int, |
| 1180 | + ) -> bool: |
| 1181 | + """ |
| 1182 | + Updates labeling parameter overrides to this project in bulk. This method allows up to 1 million data rows to be |
| 1183 | + updated at once. |
| 1184 | +
|
| 1185 | + See information on priority here: |
| 1186 | + https://docs.labelbox.com/en/configure-editor/queue-system#reservation-system |
| 1187 | +
|
| 1188 | + Args: |
| 1189 | + data_rows (iterable): An iterable of data row ids. |
| 1190 | + priority (int): Priority for the new override. See above for more information. |
| 1191 | +
|
| 1192 | + Returns: |
| 1193 | + bool, indicates if the operation was a success. |
| 1194 | + """ |
| 1195 | + |
| 1196 | + method = "createQueuePriorityUpdateTask" |
| 1197 | + priority_param = "priority" |
| 1198 | + project_param = "projectId" |
| 1199 | + data_rows_param = "dataRowIds" |
| 1200 | + query_str = """mutation %sPyApi( |
| 1201 | + $%s: Int! |
| 1202 | + $%s: ID! |
| 1203 | + $%s: [ID!] |
| 1204 | + ) { |
| 1205 | + project(where: { id: $%s }) { |
| 1206 | + %s( |
| 1207 | + data: { priority: $%s, dataRowIds: $%s } |
| 1208 | + ) { |
| 1209 | + taskId |
| 1210 | + } |
| 1211 | + } |
| 1212 | + } |
| 1213 | + """ % (method, priority_param, project_param, data_rows_param, |
| 1214 | + project_param, method, priority_param, data_rows_param) |
| 1215 | + res = self.client.execute( |
| 1216 | + query_str, { |
| 1217 | + priority_param: priority, |
| 1218 | + project_param: self.uid, |
| 1219 | + data_rows_param: data_rows |
| 1220 | + })["project"][method] |
| 1221 | + |
| 1222 | + task_id = res['taskId'] |
| 1223 | + |
| 1224 | + task = self._wait_for_task(task_id) |
| 1225 | + if task.status != "COMPLETE": |
| 1226 | + raise LabelboxError(f"Priority was not updated successfully: " + |
| 1227 | + json.dumps(task.errors)) |
| 1228 | + return True |
| 1229 | + |
1169 | 1230 | def upsert_review_queue(self, quota_factor) -> None: |
1170 | 1231 | """ Sets the the proportion of total assets in a project to review. |
1171 | 1232 |
|
|
0 commit comments