Skip to content

Commit

Permalink
Release 3.52.0 (#1221)
Browse files Browse the repository at this point in the history
  • Loading branch information
kopreschko authored Aug 24, 2023
2 parents 21d72c9 + d814fcb commit aac3ae7
Show file tree
Hide file tree
Showing 28 changed files with 754 additions and 327 deletions.
1 change: 1 addition & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
echo "LABELBOX_TEST_ENVIRON=prod" >> $GITHUB_ENV
else
echo "LABELBOX_TEST_ENVIRON=staging" >> $GITHUB_ENV
echo "FIXTURE_PROFILE=true" >> $GITHUB_ENV
fi
- uses: actions/checkout@v2
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Changelog
# Version 3.52.0 (2023-08-24)
## Added
* Added methods to create multiple batches for a project from a list of data rows
* Limit the number of data rows to be checked for processing status
# Version 3.51.0 (2023-08-14)
## Added
* Added global keys to export v2 filters for project, dataset and DataRow
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ test-local: build-image
-e LABELBOX_TEST_ENVIRON="local" \
-e DA_GCP_LABELBOX_API_KEY=${DA_GCP_LABELBOX_API_KEY} \
-e LABELBOX_TEST_API_KEY_LOCAL=${LABELBOX_TEST_API_KEY_LOCAL} \
-e FIXTURE_PROFILE=true \
local/labelbox-python:test pytest $(PATH_TO_TEST)

test-staging: build-image
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
copyright = '2021, Labelbox'
author = 'Labelbox'

release = '3.51.0'
release = '3.52.0'

# -- General configuration ---------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion labelbox/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name = "labelbox"
__version__ = "3.51.0"
__version__ = "3.52.0"

from labelbox.client import Client
from labelbox.schema.project import Project
Expand Down
24 changes: 24 additions & 0 deletions labelbox/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1704,3 +1704,27 @@ def unarchive_feature_schema_node(self, ontology_id: str,
raise labelbox.exceptions.LabelboxError(
"Failed unarchive the feature schema node, message: ",
response.text)

def get_batch(self, project_id: str, batch_id: str) -> Entity.Batch:
# obtain batch entity to return
get_batch_str = """query %s($projectId: ID!, $batchId: ID!) {
project(where: {id: $projectId}) {
batches(where: {id: $batchId}) {
nodes {
%s
}
}
}
}
""" % ("getProjectBatchPyApi",
query.results_query_part(Entity.Batch))

batch = self.execute(
get_batch_str, {
"projectId": project_id,
"batchId": batch_id
},
timeout=180.0,
experimental=True)["project"]["batches"]["nodes"][0]

return Entity.Batch(self, project_id, batch)
67 changes: 67 additions & 0 deletions labelbox/schema/create_batches_task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import json
from typing import TYPE_CHECKING, Callable, List, Optional, Dict, Any

from labelbox.orm.model import Entity

if TYPE_CHECKING:
from labelbox import User

def lru_cache() -> Callable[..., Callable[..., Dict[str, Any]]]:
pass
else:
from functools import lru_cache


class CreateBatchesTask:

def __init__(self, client, project_id: str, batch_ids: List[str],
task_ids: List[str]):
self.client = client
self.project_id = project_id
self.batches = batch_ids
self.tasks = [
Entity.Task.get_task(self.client, task_id) for task_id in task_ids
]

def wait_till_done(self, timeout_seconds: int = 300) -> None:
"""
Waits for the task to complete.
Args:
timeout_seconds: the number of seconds to wait before timing out
Returns: None
"""

for task in self.tasks:
task.wait_till_done(timeout_seconds)

def errors(self) -> Optional[Dict[str, Any]]:
"""
Returns the errors from the task, if any.
Returns: a dictionary of errors, keyed by task id
"""

errors = {}
for task in self.tasks:
if task.status == "FAILED":
errors[task.uid] = json.loads(task.result_url)

if len(errors) == 0:
return None

return errors

@lru_cache()
def result(self):
"""
Returns the batches created by the task.
Returns: the list of batches created by the task
"""

return [
self.client.get_batch(self.project_id, batch_id)
for batch_id in self.batches
]
Loading

0 comments on commit aac3ae7

Please sign in to comment.