Skip to content

Commit 334fed9

Browse files
authored
Fix instantiation of failed_data_row_ids in Batch (#1274)
2 parents 05372ee + 19739e1 commit 334fed9

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

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)

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,

0 commit comments

Comments
 (0)