Skip to content

Commit 31b79da

Browse files
authored
Release 3.55.0 (#1276)
2 parents 9a8b9f7 + 748b562 commit 31b79da

File tree

10 files changed

+66
-12
lines changed

10 files changed

+66
-12
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
# Changelog
2+
3+
# Version 3.55.0 (2023-11-06)
4+
## Fixed
5+
* Fix the instantiation of `failed_data_row_ids` in Batch. This fix will address the issue with the `create_batch` method for more than 1,000 data rows.
6+
* Improve Python type hints for the `data_rows()` method in the Dataset.
7+
* Fix the `DataRowMetadataOntology` method `bulk_export()` to properly export global key(s).
8+
* In the `DataRowMetadataOntology` method `update_enum_option`, provide a more descriptive error message when the enum option is not valid.
9+
210
# Version 3.54.1 (2023-10-17)
311
## Notebooks
412
* Revised the notebooks to update outdated examples when using `client.create_project()` to create a project

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.54.1'
24+
release = '3.55.0'
2525

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

labelbox/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
name = "labelbox"
2-
__version__ = "3.54.1"
2+
3+
__version__ = "3.55.0"
34

45
from labelbox.client import Client
56
from labelbox.schema.project import Project

labelbox/schema/batch.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(self,
4343
client,
4444
project_id,
4545
*args,
46-
failed_data_row_ids=None,
46+
failed_data_row_ids=[],
4747
**kwargs):
4848
super().__init__(client, *args, **kwargs)
4949
self.project_id = project_id
@@ -187,6 +187,11 @@ def delete_labels(self, set_labels_as_template=False) -> None:
187187
experimental=True)
188188
return res
189189

190+
# modify this function to return an empty list if there are no failed data rows
191+
190192
@property
191193
def failed_data_row_ids(self):
194+
if self._failed_data_row_ids is None:
195+
self._failed_data_row_ids = []
196+
192197
return (x for x in self._failed_data_row_ids)

labelbox/schema/data_row_metadata.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ def _parse_ontology(raw_ontology) -> List[DataRowMetadataSchema]:
255255
options = []
256256
for option in schema["options"]:
257257
option["uid"] = option["id"]
258-
259258
options.append(
260259
DataRowMetadataSchema(**{
261260
**option,
@@ -366,7 +365,12 @@ def update_enum_option(self, name: str, option: str,
366365
raise ValueError(
367366
f"Updating Enum option is only supported for Enum metadata schema"
368367
)
368+
valid_options: List[str] = [o.name for o in schema.options]
369369

370+
if option not in valid_options:
371+
raise ValueError(
372+
f"Enum option '{option}' is not a valid option for Enum '{name}', valid options are: {valid_options}"
373+
)
370374
upsert_schema = _UpsertCustomMetadataSchemaInput(id=schema.uid,
371375
name=schema.name,
372376
kind=schema.kind.value)
@@ -431,7 +435,9 @@ def parse_metadata(
431435
if "fields" in dr:
432436
fields = self.parse_metadata_fields(dr["fields"])
433437
parsed.append(
434-
DataRowMetadata(data_row_id=dr["dataRowId"], fields=fields))
438+
DataRowMetadata(data_row_id=dr["dataRowId"],
439+
global_key=dr["globalKey"],
440+
fields=fields))
435441
return parsed
436442

437443
def parse_metadata_fields(
@@ -617,6 +623,7 @@ def _bulk_export(_data_row_ids: List[str]) -> List[DataRowMetadata]:
617623
query = """query dataRowCustomMetadataPyApi($dataRowIds: [ID!]!) {
618624
dataRowCustomMetadata(where: {dataRowIds : $dataRowIds}) {
619625
dataRowId
626+
globalKey
620627
fields {
621628
value
622629
schemaId

labelbox/schema/dataset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ class Dataset(DbObject, Updateable, Deletable):
6868

6969
def data_rows(
7070
self,
71-
from_cursor: str = None,
72-
where: Comparison = None,
71+
from_cursor: Optional[str] = None,
72+
where: Optional[Comparison] = None,
7373
) -> PaginatedCollection:
7474
"""
7575
Custom method to paginate data_rows via cursor.

tests/data/annotation_types/data/test_text.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def test_text():
2222

2323

2424
def test_url():
25-
url = "https://filesamples.com/samples/document/txt/sample3.txt"
25+
url = "https://storage.googleapis.com/lb-artifacts-testing-public/sdk_integration_test/sample3.txt"
2626
text_data = TextData(url=url)
2727
text = text_data.value
2828
assert len(text) == 3541

tests/integration/test_batch.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,17 @@ def get_data_row_ids(ds: Dataset):
1414

1515

1616
def test_create_batch(project: Project, big_dataset_data_row_ids: List[str]):
17-
batch = project.create_batch("test-batch", big_dataset_data_row_ids, 3)
17+
batch = project.create_batch("test-batch",
18+
big_dataset_data_row_ids,
19+
3,
20+
consensus_settings={
21+
'number_of_labels': 3,
22+
'coverage_percentage': 0.1
23+
})
24+
1825
assert batch.name == "test-batch"
1926
assert batch.size == len(big_dataset_data_row_ids)
27+
assert len([dr for dr in batch.failed_data_row_ids]) == 0
2028

2129

2230
def test_create_batch_with_invalid_data_rows_ids(project: Project):
@@ -101,6 +109,7 @@ def test_create_batch_async(project: Project,
101109
priority=3)
102110
assert batch.name == "big-batch"
103111
assert batch.size == len(big_dataset_data_row_ids)
112+
assert len([dr for dr in batch.failed_data_row_ids]) == 0
104113

105114

106115
def test_create_batch_with_consensus_settings(project: Project,

tests/integration/test_data_row_metadata.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ def test_export_empty_metadata(client, configured_project_with_label,
9494
assert label.data.metadata == []
9595

9696

97+
def test_bulk_export_datarow_metadata(data_row, mdo: DataRowMetadataOntology):
98+
metadata = make_metadata(data_row.uid)
99+
mdo.bulk_upsert([metadata])
100+
exported = mdo.bulk_export([data_row.uid])
101+
assert exported[0].global_key == data_row.global_key
102+
assert exported[0].data_row_id == data_row.uid
103+
assert len([field for field in exported[0].fields]) == 3
104+
105+
97106
def test_get_datarow_metadata_ontology(mdo):
98107
assert len(mdo.fields)
99108
assert len(mdo.reserved_fields)
@@ -316,6 +325,8 @@ def test_parse_raw_metadata(mdo):
316325
example = {
317326
'dataRowId':
318327
'ckr6kkfx801ui0yrtg9fje8xh',
328+
'globalKey':
329+
'global-key-1',
319330
'fields': [
320331
{
321332
'schemaId': 'cko8s9r5v0001h2dk9elqdidh',
@@ -344,6 +355,7 @@ def test_parse_raw_metadata(mdo):
344355
assert len(parsed) == 1
345356
for row in parsed:
346357
assert row.data_row_id == example["dataRowId"]
358+
assert row.global_key == example["globalKey"]
347359
assert len(row.fields) == 4
348360

349361
for row in parsed:

tests/integration/test_data_rows.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,8 @@ def test_data_row_bulk_creation_sync_with_same_global_keys(
964964
assert list(dataset.data_rows())[0].global_key == global_key_1
965965

966966

967-
def test_create_conversational_text(dataset, conversational_content):
967+
@pytest.fixture
968+
def converstational_data_rows(dataset, conversational_content):
968969
examples = [
969970
{
970971
**conversational_content, 'media_type':
@@ -975,9 +976,20 @@ def test_create_conversational_text(dataset, conversational_content):
975976
"conversationalData": conversational_content['row_data']['messages']
976977
} # Old way to check for backwards compatibility
977978
]
978-
dataset.create_data_rows_sync(examples)
979+
task = dataset.create_data_rows(examples)
980+
task.wait_till_done()
981+
assert task.status == "COMPLETE"
982+
979983
data_rows = list(dataset.data_rows())
980-
assert len(data_rows) == len(examples)
984+
985+
yield data_rows
986+
for dr in data_rows:
987+
dr.delete()
988+
989+
990+
def test_create_conversational_text(converstational_data_rows,
991+
conversational_content):
992+
data_rows = converstational_data_rows
981993
for data_row in data_rows:
982994
assert requests.get(
983995
data_row.row_data).json() == conversational_content['row_data']

0 commit comments

Comments
 (0)