Skip to content

Commit aac3ae7

Browse files
authored
Release 3.52.0 (#1221)
2 parents 21d72c9 + d814fcb commit aac3ae7

28 files changed

+754
-327
lines changed

.github/workflows/python-package.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
echo "LABELBOX_TEST_ENVIRON=prod" >> $GITHUB_ENV
4040
else
4141
echo "LABELBOX_TEST_ENVIRON=staging" >> $GITHUB_ENV
42+
echo "FIXTURE_PROFILE=true" >> $GITHUB_ENV
4243
fi
4344
4445
- uses: actions/checkout@v2

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Changelog
2+
# Version 3.52.0 (2023-08-24)
3+
## Added
4+
* Added methods to create multiple batches for a project from a list of data rows
5+
* Limit the number of data rows to be checked for processing status
26
# Version 3.51.0 (2023-08-14)
37
## Added
48
* Added global keys to export v2 filters for project, dataset and DataRow

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ test-local: build-image
1313
-e LABELBOX_TEST_ENVIRON="local" \
1414
-e DA_GCP_LABELBOX_API_KEY=${DA_GCP_LABELBOX_API_KEY} \
1515
-e LABELBOX_TEST_API_KEY_LOCAL=${LABELBOX_TEST_API_KEY_LOCAL} \
16+
-e FIXTURE_PROFILE=true \
1617
local/labelbox-python:test pytest $(PATH_TO_TEST)
1718

1819
test-staging: build-image

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.51.0'
24+
release = '3.52.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.51.0"
2+
__version__ = "3.52.0"
33

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

labelbox/client.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,3 +1704,27 @@ def unarchive_feature_schema_node(self, ontology_id: str,
17041704
raise labelbox.exceptions.LabelboxError(
17051705
"Failed unarchive the feature schema node, message: ",
17061706
response.text)
1707+
1708+
def get_batch(self, project_id: str, batch_id: str) -> Entity.Batch:
1709+
# obtain batch entity to return
1710+
get_batch_str = """query %s($projectId: ID!, $batchId: ID!) {
1711+
project(where: {id: $projectId}) {
1712+
batches(where: {id: $batchId}) {
1713+
nodes {
1714+
%s
1715+
}
1716+
}
1717+
}
1718+
}
1719+
""" % ("getProjectBatchPyApi",
1720+
query.results_query_part(Entity.Batch))
1721+
1722+
batch = self.execute(
1723+
get_batch_str, {
1724+
"projectId": project_id,
1725+
"batchId": batch_id
1726+
},
1727+
timeout=180.0,
1728+
experimental=True)["project"]["batches"]["nodes"][0]
1729+
1730+
return Entity.Batch(self, project_id, batch)
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import json
2+
from typing import TYPE_CHECKING, Callable, List, Optional, Dict, Any
3+
4+
from labelbox.orm.model import Entity
5+
6+
if TYPE_CHECKING:
7+
from labelbox import User
8+
9+
def lru_cache() -> Callable[..., Callable[..., Dict[str, Any]]]:
10+
pass
11+
else:
12+
from functools import lru_cache
13+
14+
15+
class CreateBatchesTask:
16+
17+
def __init__(self, client, project_id: str, batch_ids: List[str],
18+
task_ids: List[str]):
19+
self.client = client
20+
self.project_id = project_id
21+
self.batches = batch_ids
22+
self.tasks = [
23+
Entity.Task.get_task(self.client, task_id) for task_id in task_ids
24+
]
25+
26+
def wait_till_done(self, timeout_seconds: int = 300) -> None:
27+
"""
28+
Waits for the task to complete.
29+
30+
Args:
31+
timeout_seconds: the number of seconds to wait before timing out
32+
33+
Returns: None
34+
"""
35+
36+
for task in self.tasks:
37+
task.wait_till_done(timeout_seconds)
38+
39+
def errors(self) -> Optional[Dict[str, Any]]:
40+
"""
41+
Returns the errors from the task, if any.
42+
43+
Returns: a dictionary of errors, keyed by task id
44+
"""
45+
46+
errors = {}
47+
for task in self.tasks:
48+
if task.status == "FAILED":
49+
errors[task.uid] = json.loads(task.result_url)
50+
51+
if len(errors) == 0:
52+
return None
53+
54+
return errors
55+
56+
@lru_cache()
57+
def result(self):
58+
"""
59+
Returns the batches created by the task.
60+
61+
Returns: the list of batches created by the task
62+
"""
63+
64+
return [
65+
self.client.get_batch(self.project_id, batch_id)
66+
for batch_id in self.batches
67+
]

0 commit comments

Comments
 (0)