1313logger = logging .getLogger (__name__ )
1414
1515
16- class LabelCollection :
16+ class LabelList :
1717 """
1818 A container for interacting with a collection of labels.
1919 Less memory efficient than LabelGenerator but more performant and convenient to use.
@@ -25,16 +25,15 @@ def __init__(self, data: Iterable[Label]):
2525 self ._index = 0
2626
2727 def assign_schema_ids (
28- self ,
29- ontology_builder : "ontology.OntologyBuilder" ) -> "LabelCollection" :
28+ self , ontology_builder : "ontology.OntologyBuilder" ) -> "LabelList" :
3029 """
3130 Adds schema ids to all FeatureSchema objects in the Labels.
3231 This is necessary for MAL.
3332
3433 Args:
35- ontology_builder: The ontology that matches the feature names assigned to objects in this LabelCollection
34+ ontology_builder: The ontology that matches the feature names assigned to objects in this LabelList
3635 Returns:
37- LabelCollection . useful for chaining these modifying functions
36+ LabelList . useful for chaining these modifying functions
3837 """
3938 for label in self ._data :
4039 label .assign_schema_ids (ontology_builder )
@@ -43,7 +42,7 @@ def assign_schema_ids(
4342 def add_to_dataset (self ,
4443 dataset : "Entity.Dataset" ,
4544 signer : Callable [[bytes ], str ],
46- max_concurrency = 20 ) -> "LabelCollection " :
45+ max_concurrency = 20 ) -> "LabelList " :
4746 """
4847 Creates data rows from each labels data object and attaches the data to the given dataset.
4948 Updates the label's data object to have the same external_id and uid as the data row.
@@ -56,7 +55,7 @@ def add_to_dataset(self,
5655 dataset: labelbox dataset object to add the new data row to
5756 signer: A function that accepts bytes and returns a signed url.
5857 Returns:
59- LabelCollection with updated references to new data rows
58+ LabelList with updated references to new data rows
6059 """
6160 self ._ensure_unique_external_ids ()
6261 self .add_url_to_data (signer , max_concurrency = max_concurrency )
@@ -74,9 +73,9 @@ def add_to_dataset(self,
7473 label .data .uid = data_row_lookup [label .data .external_id ]
7574 return self
7675
77- def add_url_to_masks (self , signer , max_concurrency = 20 ) -> "LabelCollection " :
76+ def add_url_to_masks (self , signer , max_concurrency = 20 ) -> "LabelList " :
7877 """
79- Creates signed urls for all masks in the LabelCollection .
78+ Creates signed urls for all masks in the LabelList .
8079 Multiple masks can reference the same RasterData mask so this makes sure we only upload that url once.
8180 Only uploads url if one doesn't already exist.
8281
@@ -85,15 +84,15 @@ def add_url_to_masks(self, signer, max_concurrency=20) -> "LabelCollection":
8584 max_concurrency: how many threads to use for uploading.
8685 Should be balanced to match the signing services capabilities.
8786 Returns:
88- LabelCollection with updated references to the new mask urls
87+ LabelList with updated references to the new mask urls
8988 """
9089 for row in self ._apply_threaded (
9190 [label .add_url_to_masks for label in self ._data ], max_concurrency ,
9291 signer ):
9392 ...
9493 return self
9594
96- def add_url_to_data (self , signer , max_concurrency = 20 ) -> "LabelCollection " :
95+ def add_url_to_data (self , signer , max_concurrency = 20 ) -> "LabelList " :
9796 """
9897 Creates signed urls for the data
9998 Only uploads url if one doesn't already exist.
@@ -103,7 +102,7 @@ def add_url_to_data(self, signer, max_concurrency=20) -> "LabelCollection":
103102 max_concurrency: how many threads to use for uploading.
104103 Should be balanced to match the signing services capabilities.
105104 Returns:
106- LabelCollection with updated references to the new data urls
105+ LabelList with updated references to the new data urls
107106 """
108107 for row in self ._apply_threaded (
109108 [label .add_url_to_data for label in self ._data ], max_concurrency ,
@@ -123,7 +122,7 @@ def _ensure_unique_external_ids(self) -> None:
123122 )
124123 external_ids .add (label .data .external_id )
125124
126- def __iter__ (self ) -> "LabelCollection " :
125+ def __iter__ (self ) -> "LabelList " :
127126 self ._index = 0
128127 return self
129128
@@ -156,15 +155,15 @@ class LabelGenerator(PrefetchGenerator):
156155 A container for interacting with a collection of labels.
157156
158157 Use this class if you have larger data. It is slightly harder to work with
159- than the LabelCollection but will be much more memory efficient.
158+ than the LabelList but will be much more memory efficient.
160159 """
161160
162161 def __init__ (self , data : Generator [Label , None , None ], * args , ** kwargs ):
163162 self ._fns = {}
164163 super ().__init__ (data , * args , ** kwargs )
165164
166- def as_collection (self ) -> "LabelCollection " :
167- return LabelCollection (data = list (self ))
165+ def as_list (self ) -> "LabelList " :
166+ return LabelList (data = list (self ))
168167
169168 def assign_schema_ids (
170169 self ,
@@ -202,7 +201,7 @@ def add_to_dataset(self, dataset: "Entity.Dataset",
202201 Creates data rows from each labels data object and attaches the data to the given dataset.
203202 Updates the label's data object to have the same external_id and uid as the data row.
204203
205- This is a lot slower than LabelCollection .add_to_dataset but also more memory efficient.
204+ This is a lot slower than LabelList .add_to_dataset but also more memory efficient.
206205
207206 Args:
208207 dataset: labelbox dataset object to add the new data row to
@@ -272,4 +271,4 @@ def __next__(self):
272271 return self ._process (value )
273272
274273
275- LabelContainer = Union [LabelCollection , LabelGenerator ]
274+ LabelCollection = Union [LabelList , LabelGenerator ]
0 commit comments