Skip to content

Commit b3fa77b

Browse files
authored
Merge pull request #930 from Labelbox/VB/remove-labellist-sdk_AL-4965
Vb/remove labellist sdk al 4965
2 parents a7e8005 + 6b2af89 commit b3fa77b

File tree

19 files changed

+39
-88
lines changed

19 files changed

+39
-88
lines changed

labelbox/data/annotation_types/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from .data import VideoData
2525

2626
from .label import Label
27-
2827
from .collection import LabelList
2928
from .collection import LabelGenerator
3029

labelbox/data/annotation_types/collection.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ class LabelList:
2222
Use on smaller datasets.
2323
"""
2424

25-
warnings.warn("LabelList is deprecated and will be "
26-
"removed in a future release.")
27-
2825
def __init__(self, data: Optional[Iterable[Label]] = None):
26+
warnings.warn("LabelList is deprecated and will be "
27+
"removed in a future release.")
28+
2929
if data is None:
3030
self._data = []
3131
elif isinstance(data, Label):
@@ -179,10 +179,8 @@ def _apply_threaded(self, fns, max_concurrency, *args):
179179

180180
class LabelGenerator(PrefetchGenerator):
181181
"""
182-
A container for interacting with a collection of labels.
183-
184-
Use this class if you have larger data. It is slightly harder to work with
185-
than the LabelList but will be much more memory efficient.
182+
A container for interacting with a large collection of labels.
183+
For a small number of labels, just use a list of Label objects.
186184
"""
187185

188186
def __init__(self, data: Generator[Label, None, None], *args, **kwargs):
@@ -191,7 +189,7 @@ def __init__(self, data: Generator[Label, None, None], *args, **kwargs):
191189

192190
def as_list(self) -> "LabelList":
193191
warnings.warn("This method is deprecated and will be "
194-
"removed in a future release. LabeList"
192+
"removed in a future release. LabelList"
195193
" class will be deprecated.")
196194
return LabelList(data=list(self))
197195

@@ -304,4 +302,4 @@ def __next__(self):
304302
return self._process(value)
305303

306304

307-
LabelCollection = Union[LabelList, LabelGenerator, Iterable[Label]]
305+
LabelCollection = Union[LabelGenerator, Iterable[Label]]

labelbox/data/metrics/group.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from typing_extensions import Literal
1313

1414
from ..annotation_types.feature import FeatureSchema
15-
from ..annotation_types import ObjectAnnotation, ClassificationAnnotation, Label, LabelList
15+
from ..annotation_types import ObjectAnnotation, ClassificationAnnotation, Label
1616

1717

1818
def get_identifying_key(
@@ -79,8 +79,8 @@ def all_have_key(features: List[FeatureSchema]) -> Tuple[bool, bool]:
7979
return all_schemas, all_names
8080

8181

82-
def get_label_pairs(labels_a: LabelList,
83-
labels_b: LabelList,
82+
def get_label_pairs(labels_a: list,
83+
labels_b: list,
8484
match_on="uid",
8585
filter_mismatch=False) -> Dict[str, Tuple[Label, Label]]:
8686
"""
@@ -91,8 +91,8 @@ def get_label_pairs(labels_a: LabelList,
9191
If this assumption fails, then the user has to determine their own matching strategy.
9292
9393
Args:
94-
labels_a (LabelList): A collection of labels to match with labels_b
95-
labels_b (LabelList): A collection of labels to match with labels_a
94+
labels_a (list): A collection of labels to match with labels_b
95+
labels_b (list): A collection of labels to match with labels_a
9696
match_on ('uid' or 'external_id'): The data row key to match labels by. Can either be uid or external id.
9797
filter_mismatch (bool): Whether or not to ignore mismatches
9898

labelbox/data/serialization/labelbox_v1/converter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def serialize(
6969
Note that any metric annotations will not be written since they are not defined in the LBV1 format.
7070
7171
Args:
72-
labels: Either a LabelList or a LabelGenerator (LabelCollection)
72+
labels: Either a list of Label objects or a LabelGenerator (LabelCollection)
7373
Returns:
7474
A generator for accessing the labelbox json export representation of the data
7575
"""

labelbox/data/serialization/labelbox_v1/objects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def from_common(cls, mask: Mask,
219219
extra: Dict[str, Any]) -> "LBV1Mask":
220220
if mask.mask.url is None:
221221
raise ValueError(
222-
"Mask does not have a url. Use `LabelGenerator.add_url_to_masks`, `LabelList.add_url_to_masks`, or `Label.add_url_to_masks`."
222+
"Mask does not have a url. Use `LabelGenerator.add_url_to_masks`, or `Label.add_url_to_masks`."
223223
)
224224
return cls(instanceURI=mask.mask.url,
225225
classifications=classifications,

labelbox/data/serialization/ndjson/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class DataRow(BaseModel):
1313
def validate_id(cls, v):
1414
if v is None:
1515
raise ValueError(
16-
"Data row ids are not set. Use `LabelGenerator.add_to_dataset`, `LabelList.add_to_dataset`, or `Label.create_data_row`. "
16+
"Data row ids are not set. Use `LabelGenerator.add_to_dataset`,or `Label.create_data_row`. "
1717
"You can also manually assign the id for each `BaseData` object"
1818
)
1919
return v

labelbox/data/serialization/ndjson/converter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def serialize(
3636
We will continue to improve the error messages and add helper functions to deal with this.
3737
3838
Args:
39-
labels: Either a LabelList or a LabelGenerator
39+
labels: Either a list of Label objects or a LabelGenerator
4040
Returns:
4141
A generator for accessing the ndjson representation of the data
4242
"""

tests/data/annotation_types/test_collection.py

Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import numpy as np
55
import pytest
66

7-
from labelbox.data.annotation_types import (LabelList, LabelGenerator,
8-
ObjectAnnotation, ImageData,
9-
MaskData, Line, Mask, Point, Label)
7+
from labelbox.data.annotation_types import (LabelGenerator, ObjectAnnotation,
8+
ImageData, MaskData, Line, Mask,
9+
Point, Label)
1010
from labelbox import OntologyBuilder, Tool
1111

1212

@@ -61,7 +61,7 @@ def test_generator(list_of_labels):
6161

6262
def test_conversion(list_of_labels):
6363
generator = LabelGenerator(list_of_labels)
64-
label_collection = generator.as_list()
64+
label_collection = list(generator)
6565
assert len(label_collection) == len(list_of_labels)
6666
assert [x for x in label_collection] == list_of_labels
6767

@@ -83,9 +83,6 @@ def test_adding_schema_ids():
8383
])
8484
generator = LabelGenerator([label]).assign_feature_schema_ids(ontology)
8585
assert next(generator).annotations[0].feature_schema_id == feature_schema_id
86-
labels = LabelList([label]).assign_feature_schema_ids(ontology)
87-
assert next(labels).annotations[0].feature_schema_id == feature_schema_id
88-
assert labels[0].annotations[0].feature_schema_id == feature_schema_id
8986

9087

9188
def test_adding_urls(signer):
@@ -98,15 +95,6 @@ def test_adding_urls(signer):
9895
assert next(generator).data.url == uuid
9996
assert label.data.url == uuid
10097

101-
label = Label(data=ImageData(arr=np.random.random((32, 32,
102-
3)).astype(np.uint8)),
103-
annotations=[])
104-
assert label.data.url != uuid
105-
labels = LabelList([label]).add_url_to_data(signer(uuid))
106-
assert label.data.url == uuid
107-
assert next(labels).data.url == uuid
108-
assert labels[0].data.url == uuid
109-
11098

11199
def test_adding_to_dataset(signer):
112100
dataset = FakeDataset()
@@ -122,22 +110,6 @@ def test_adding_to_dataset(signer):
122110
assert generated_label.data.uid == dataset.uid
123111
assert label.data.url == uuid
124112

125-
dataset = FakeDataset()
126-
label = Label(data=ImageData(arr=np.random.random((32, 32,
127-
3)).astype(np.uint8)),
128-
annotations=[])
129-
assert label.data.url != uuid
130-
assert label.data.external_id == None
131-
assert label.data.uid != dataset.uid
132-
labels = LabelList([label]).add_to_dataset(dataset, signer(uuid))
133-
assert label.data.url == uuid
134-
assert label.data.external_id != None
135-
assert label.data.uid == dataset.uid
136-
generated_label = next(labels)
137-
assert generated_label.data.url == uuid
138-
assert generated_label.data.external_id != None
139-
assert generated_label.data.uid == dataset.uid
140-
141113

142114
def test_adding_to_masks(signer):
143115
label = Label(
@@ -154,17 +126,3 @@ def test_adding_to_masks(signer):
154126
assert label.annotations[0].value.mask.url != uuid
155127
assert next(generator).annotations[0].value.mask.url == uuid
156128
assert label.annotations[0].value.mask.url == uuid
157-
158-
label = Label(
159-
data=ImageData(arr=np.random.random((32, 32, 3)).astype(np.uint8)),
160-
annotations=[
161-
ObjectAnnotation(name="1234",
162-
value=Mask(mask=MaskData(
163-
arr=np.random.random((32, 32,
164-
3)).astype(np.uint8)),
165-
color=[255, 255, 255]))
166-
])
167-
assert label.annotations[0].value.mask.url != uuid
168-
labels = LabelList([label]).add_url_to_masks(signer(uuid))
169-
assert next(labels).annotations[0].value.mask.url == uuid
170-
assert labels[0].annotations[0].value.mask.url == uuid

tests/data/annotation_types/test_metrics.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
from labelbox.data.annotation_types.metrics import ConfusionMatrixAggregation, ScalarMetricAggregation
55
from labelbox.data.annotation_types.metrics import ConfusionMatrixMetric, ScalarMetric
6-
from labelbox.data.annotation_types.collection import LabelList
76
from labelbox.data.annotation_types import ScalarMetric, Label, ImageData
87
from labelbox.data.annotation_types.metrics.scalar import RESERVED_METRIC_NAMES
98

@@ -34,7 +33,6 @@ def test_legacy_scalar_metric():
3433
'uid': None
3534
}
3635
assert label.dict() == expected
37-
assert next(LabelList([label])).dict() == expected
3836

3937

4038
# TODO: Test with confidence
@@ -96,7 +94,6 @@ def test_custom_scalar_metric(feature_name, subclass_name, aggregation, value):
9694
}
9795

9896
assert label.dict() == expected
99-
assert next(LabelList([label])).dict() == expected
10097

10198

10299
@pytest.mark.parametrize('feature_name,subclass_name,aggregation,value', [
@@ -152,7 +149,6 @@ def test_custom_confusison_matrix_metric(feature_name, subclass_name,
152149
'uid': None
153150
}
154151
assert label.dict() == expected
155-
assert next(LabelList([label])).dict() == expected
156152

157153

158154
def test_name_exists():

tests/data/serialization/labelbox_v1/test_tiled_image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_image(file_path):
2020
payload = json.load(f)
2121

2222
collection = LBV1Converter.deserialize(payload)
23-
collection_as_list = collection.as_list()
23+
collection_as_list = list(collection)
2424

2525
assert len(collection_as_list) == 2
2626

0 commit comments

Comments
 (0)