Skip to content

Commit 6a34aeb

Browse files
authored
Release 3.54.0 (#1258)
2 parents ddb8063 + d67624e commit 6a34aeb

16 files changed

+153
-50
lines changed

.yapfignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
pytest.ini
1+
Makefile
2+
*.txt
3+
*.ini

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# Changelog
2+
# Version 3.54.0 (2023-10-10)
3+
## Added
4+
* Add exports v1 deprecation warning
5+
* Create method in SDK to modify LPO priorities in bulk
6+
## Removed
7+
* Remove backoff library
28
# Version 3.53.0 (2023-10-03)
39
## Added
410
* Remove LPO deprecation warning and allow greater range of priority values

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
copyright = '2021, Labelbox'
2222
author = 'Labelbox'
2323

24-
release = '3.53.0'
24+
release = '3.54.0'
2525

2626
# -- General configuration ---------------------------------------------------
2727

labelbox/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name = "labelbox"
2-
__version__ = "3.53.0"
2+
__version__ = "3.54.0"
33

44
from labelbox.client import Client
55
from labelbox.schema.project import Project

labelbox/schema/annotation_import.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import time
66
from typing import Any, BinaryIO, Dict, List, Union, TYPE_CHECKING, cast
77

8-
import backoff
8+
from google.api_core import retry
99
from labelbox import parser
1010
import requests
1111
from tqdm import tqdm # type: ignore
@@ -109,12 +109,9 @@ def wait_until_done(self,
109109
pbar.update(100 - pbar.n)
110110
pbar.close()
111111

112-
@backoff.on_exception(
113-
backoff.expo,
114-
(labelbox.exceptions.ApiLimitError, labelbox.exceptions.TimeoutError,
115-
labelbox.exceptions.NetworkError),
116-
max_tries=10,
117-
jitter=None)
112+
@retry.Retry(predicate=retry.if_exception_type(
113+
labelbox.exceptions.ApiLimitError, labelbox.exceptions.TimeoutError,
114+
labelbox.exceptions.NetworkError))
118115
def __backoff_refresh(self) -> None:
119116
self.refresh()
120117

labelbox/schema/batch.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import requests
1010
import logging
1111
import time
12+
import warnings
1213

1314
if TYPE_CHECKING:
1415
from labelbox import Project
@@ -103,6 +104,10 @@ def export_data_rows(self,
103104
Raises:
104105
LabelboxError: if the export fails or is unable to download within the specified time.
105106
"""
107+
warnings.warn(
108+
"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",
109+
DeprecationWarning)
110+
106111
id_param = "batchId"
107112
metadata_param = "includeMetadataInput"
108113
query_str = """mutation GetBatchDataRowsExportUrlPyApi($%s: ID!, $%s: Boolean!)

labelbox/schema/bulk_import_request.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import logging
77
from pathlib import Path
88
import pydantic
9-
import backoff
9+
from google.api_core import retry
1010
from labelbox import parser
1111
import requests
1212
from pydantic import BaseModel, root_validator, validator
@@ -197,11 +197,9 @@ def wait_until_done(self, sleep_time_seconds: int = 5) -> None:
197197
time.sleep(sleep_time_seconds)
198198
self.__exponential_backoff_refresh()
199199

200-
@backoff.on_exception(
201-
backoff.expo, (lb_exceptions.ApiLimitError, lb_exceptions.TimeoutError,
202-
lb_exceptions.NetworkError),
203-
max_tries=10,
204-
jitter=None)
200+
@retry.Retry(predicate=retry.if_exception_type(lb_exceptions.ApiLimitError,
201+
lb_exceptions.TimeoutError,
202+
lb_exceptions.NetworkError))
205203
def __exponential_backoff_refresh(self) -> None:
206204
self.refresh()
207205

labelbox/schema/dataset.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from collections.abc import Iterable
66
from string import Template
77
import time
8+
import warnings
89

910
from labelbox import parser
1011
from itertools import islice
@@ -565,6 +566,9 @@ def export_data_rows(self,
565566
Raises:
566567
LabelboxError: if the export fails or is unable to download within the specified time.
567568
"""
569+
warnings.warn(
570+
"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",
571+
DeprecationWarning)
568572
id_param = "datasetId"
569573
metadata_param = "includeMetadataInput"
570574
query_str = """mutation GetDatasetDataRowsExportUrlPyApi($%s: ID!, $%s: Boolean!)

labelbox/schema/model_run.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import time
66
import logging
77
import requests
8+
import warnings
89
from labelbox import parser
910
from enum import Enum
1011

@@ -470,6 +471,9 @@ def export_labels(
470471
If the server didn't generate during the `timeout_seconds` period,
471472
None is returned.
472473
"""
474+
warnings.warn(
475+
"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",
476+
DeprecationWarning)
473477
sleep_time = 2
474478
query_str = """mutation exportModelRunAnnotationsPyApi($modelRunId: ID!) {
475479
exportModelRunAnnotations(data: {modelRunId: $modelRunId}) {

labelbox/schema/project.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
22
import logging
33
import time
4+
import warnings
45
from collections import namedtuple
56
from datetime import datetime, timezone
67
from pathlib import Path
@@ -231,6 +232,9 @@ def export_queued_data_rows(
231232
Raises:
232233
LabelboxError: if the export fails or is unable to download within the specified time.
233234
"""
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)
234238
id_param = "projectId"
235239
metadata_param = "includeMetadataInput"
236240
query_str = """mutation GetQueuedDataRowsExportUrlPyApi($%s: ID!, $%s: Boolean!)
@@ -334,6 +338,9 @@ def export_labels(self,
334338
URL of the data file with this Project's labels. If the server didn't
335339
generate during the `timeout_seconds` period, None is returned.
336340
"""
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)
337344

338345
def _string_from_dict(dictionary: dict, value_with_quotes=False) -> str:
339346
"""Returns a concatenated string of the dictionary's keys and values
@@ -1166,6 +1173,60 @@ def set_labeling_parameter_overrides(self, data) -> bool:
11661173
res = self.client.execute(query_str, {id_param: self.uid})
11671174
return res["project"]["setLabelingParameterOverrides"]["success"]
11681175

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+
11691230
def upsert_review_queue(self, quota_factor) -> None:
11701231
""" Sets the the proportion of total assets in a project to review.
11711232

0 commit comments

Comments
 (0)