Skip to content

Commit 7d82380

Browse files
committed
Removed assign_feature_schema_ids
1 parent de9b3ad commit 7d82380

File tree

5 files changed

+0
-284
lines changed

5 files changed

+0
-284
lines changed

libs/labelbox/src/labelbox/client.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,10 +1644,6 @@ def get_data_row_ids_for_global_keys(
16441644
"""
16451645
Gets data row ids for a list of global keys.
16461646
1647-
Deprecation Notice: This function will soon no longer return 'Deleted Data Rows'
1648-
as part of the 'results'. Global keys for deleted data rows will soon be placed
1649-
under 'Data Row not found' portion.
1650-
16511647
Args:
16521648
A list of global keys
16531649
Returns:

libs/labelbox/src/labelbox/data/annotation_types/collection.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,6 @@ def __init__(self, data: Generator[Label, None, None], *args, **kwargs):
2525
self._fns = {}
2626
super().__init__(data, *args, **kwargs)
2727

28-
def assign_feature_schema_ids(
29-
self, ontology_builder: "ontology.OntologyBuilder"
30-
) -> "LabelGenerator":
31-
def _assign_ids(label: Label):
32-
label.assign_feature_schema_ids(ontology_builder)
33-
return label
34-
35-
warnings.warn(
36-
"This method is deprecated and will be "
37-
"removed in a future release. Feature schema ids"
38-
" are no longer required for importing."
39-
)
40-
self._fns["assign_feature_schema_ids"] = _assign_ids
41-
return self
42-
4328
def add_url_to_masks(
4429
self, signer: Callable[[bytes], str]
4530
) -> "LabelGenerator":

libs/labelbox/src/labelbox/data/annotation_types/label.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -136,42 +136,6 @@ def create_data_row(
136136
self.data.external_id = data_row.external_id
137137
return self
138138

139-
def assign_feature_schema_ids(
140-
self, ontology_builder: ontology.OntologyBuilder
141-
) -> "Label":
142-
"""
143-
Adds schema ids to all FeatureSchema objects in the Labels.
144-
145-
Args:
146-
ontology_builder: The ontology that matches the feature names assigned to objects in this dataset
147-
Returns:
148-
Label. useful for chaining these modifying functions
149-
150-
Note: You can now import annotations using names directly without having to lookup schema_ids
151-
"""
152-
warnings.warn(
153-
"This method is deprecated and will be "
154-
"removed in a future release. Feature schema ids"
155-
" are no longer required for importing."
156-
)
157-
tool_lookup, classification_lookup = get_feature_schema_lookup(
158-
ontology_builder
159-
)
160-
for annotation in self.annotations:
161-
if isinstance(annotation, ClassificationAnnotation):
162-
self._assign_or_raise(annotation, classification_lookup)
163-
self._assign_option(annotation, classification_lookup)
164-
elif isinstance(annotation, ObjectAnnotation):
165-
self._assign_or_raise(annotation, tool_lookup)
166-
for classification in annotation.classifications:
167-
self._assign_or_raise(classification, classification_lookup)
168-
self._assign_option(classification, classification_lookup)
169-
else:
170-
raise TypeError(
171-
f"Unexpected type found for annotation. {type(annotation)}"
172-
)
173-
return self
174-
175139
def _assign_or_raise(self, annotation, lookup: Dict[str, str]) -> None:
176140
if annotation.feature_schema_id is not None:
177141
return

libs/labelbox/tests/data/annotation_types/test_collection.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -72,27 +72,6 @@ def test_conversion(list_of_labels):
7272
assert [x for x in label_collection] == list_of_labels
7373

7474

75-
def test_adding_schema_ids():
76-
name = "line_feature"
77-
label = Label(
78-
data=GenericDataRowData(uid="123456"),
79-
annotations=[
80-
ObjectAnnotation(
81-
value=Line(points=[Point(x=1, y=2), Point(x=2, y=2)]),
82-
name=name,
83-
)
84-
],
85-
)
86-
feature_schema_id = "expected_id"
87-
ontology = OntologyBuilder(
88-
tools=[
89-
Tool(Tool.Type.LINE, name=name, feature_schema_id=feature_schema_id)
90-
]
91-
)
92-
generator = LabelGenerator([label]).assign_feature_schema_ids(ontology)
93-
assert next(generator).annotations[0].feature_schema_id == feature_schema_id
94-
95-
9675
def test_adding_to_masks(signer):
9776
label = Label(
9877
data=GenericDataRowData(uid="12345"),

libs/labelbox/tests/data/annotation_types/test_label.py

Lines changed: 0 additions & 208 deletions
Original file line numberDiff line numberDiff line change
@@ -23,214 +23,6 @@
2323
import pytest
2424

2525

26-
def test_schema_assignment_geometry():
27-
name = "line_feature"
28-
label = Label(
29-
data=MaskData(
30-
arr=np.ones((32, 32, 3), dtype=np.uint8), global_key="test"
31-
),
32-
annotations=[
33-
ObjectAnnotation(
34-
value=Line(points=[Point(x=1, y=2), Point(x=2, y=2)]),
35-
name=name,
36-
)
37-
],
38-
)
39-
feature_schema_id = "expected_id"
40-
ontology = OntologyBuilder(
41-
tools=[
42-
Tool(Tool.Type.LINE, name=name, feature_schema_id=feature_schema_id)
43-
]
44-
)
45-
label.assign_feature_schema_ids(ontology)
46-
47-
assert label.annotations[0].feature_schema_id == feature_schema_id
48-
49-
50-
def test_schema_assignment_classification():
51-
radio_name = "radio_name"
52-
text_name = "text_name"
53-
option_name = "my_option"
54-
55-
label = Label(
56-
data=MaskData(arr=np.ones((32, 32, 3), dtype=np.uint8), uid="test"),
57-
annotations=[
58-
ClassificationAnnotation(
59-
value=Radio(answer=ClassificationAnswer(name=option_name)),
60-
name=radio_name,
61-
),
62-
ClassificationAnnotation(
63-
value=Text(answer="some text"), name=text_name
64-
),
65-
],
66-
)
67-
radio_schema_id = "radio_schema_id"
68-
text_schema_id = "text_schema_id"
69-
option_schema_id = "option_schema_id"
70-
ontology = OntologyBuilder(
71-
tools=[],
72-
classifications=[
73-
OClassification(
74-
class_type=OClassification.Type.RADIO,
75-
name=radio_name,
76-
feature_schema_id=radio_schema_id,
77-
options=[
78-
Option(
79-
value=option_name, feature_schema_id=option_schema_id
80-
)
81-
],
82-
),
83-
OClassification(
84-
class_type=OClassification.Type.TEXT,
85-
name=text_name,
86-
feature_schema_id=text_schema_id,
87-
),
88-
],
89-
)
90-
label.assign_feature_schema_ids(ontology)
91-
assert label.annotations[0].feature_schema_id == radio_schema_id
92-
assert label.annotations[1].feature_schema_id == text_schema_id
93-
assert (
94-
label.annotations[0].value.answer.feature_schema_id == option_schema_id
95-
)
96-
97-
98-
def test_schema_assignment_subclass():
99-
name = "line_feature"
100-
radio_name = "radio_name"
101-
option_name = "my_option"
102-
classification = ClassificationAnnotation(
103-
name=radio_name,
104-
value=Radio(answer=ClassificationAnswer(name=option_name)),
105-
)
106-
label = Label(
107-
data=MaskData(arr=np.ones((32, 32, 3), dtype=np.uint8), uid="test"),
108-
annotations=[
109-
ObjectAnnotation(
110-
value=Line(points=[Point(x=1, y=2), Point(x=2, y=2)]),
111-
name=name,
112-
classifications=[classification],
113-
)
114-
],
115-
)
116-
feature_schema_id = "expected_id"
117-
classification_schema_id = "classification_id"
118-
option_schema_id = "option_schema_id"
119-
ontology = OntologyBuilder(
120-
tools=[
121-
Tool(
122-
Tool.Type.LINE,
123-
name=name,
124-
feature_schema_id=feature_schema_id,
125-
classifications=[
126-
OClassification(
127-
class_type=OClassification.Type.RADIO,
128-
name=radio_name,
129-
feature_schema_id=classification_schema_id,
130-
options=[
131-
Option(
132-
value=option_name,
133-
feature_schema_id=option_schema_id,
134-
)
135-
],
136-
)
137-
],
138-
)
139-
]
140-
)
141-
label.assign_feature_schema_ids(ontology)
142-
assert label.annotations[0].feature_schema_id == feature_schema_id
143-
assert (
144-
label.annotations[0].classifications[0].feature_schema_id
145-
== classification_schema_id
146-
)
147-
assert (
148-
label.annotations[0].classifications[0].value.answer.feature_schema_id
149-
== option_schema_id
150-
)
151-
152-
153-
def test_highly_nested():
154-
name = "line_feature"
155-
radio_name = "radio_name"
156-
nested_name = "nested_name"
157-
option_name = "my_option"
158-
nested_option_name = "nested_option_name"
159-
classification = ClassificationAnnotation(
160-
name=radio_name,
161-
value=Radio(answer=ClassificationAnswer(name=option_name)),
162-
classifications=[
163-
ClassificationAnnotation(
164-
value=Radio(
165-
answer=ClassificationAnswer(name=nested_option_name)
166-
),
167-
name=nested_name,
168-
)
169-
],
170-
)
171-
label = Label(
172-
data=MaskData(
173-
arr=np.ones((32, 32, 3), dtype=np.uint8), global_key="test"
174-
),
175-
annotations=[
176-
ObjectAnnotation(
177-
value=Line(points=[Point(x=1, y=2), Point(x=2, y=2)]),
178-
name=name,
179-
classifications=[classification],
180-
)
181-
],
182-
)
183-
feature_schema_id = "expected_id"
184-
classification_schema_id = "classification_id"
185-
nested_classification_schema_id = "nested_classification_schema_id"
186-
option_schema_id = "option_schema_id"
187-
ontology = OntologyBuilder(
188-
tools=[
189-
Tool(
190-
Tool.Type.LINE,
191-
name=name,
192-
feature_schema_id=feature_schema_id,
193-
classifications=[
194-
OClassification(
195-
class_type=OClassification.Type.RADIO,
196-
name=radio_name,
197-
feature_schema_id=classification_schema_id,
198-
options=[
199-
Option(
200-
value=option_name,
201-
feature_schema_id=option_schema_id,
202-
options=[
203-
OClassification(
204-
class_type=OClassification.Type.RADIO,
205-
name=nested_name,
206-
feature_schema_id=nested_classification_schema_id,
207-
options=[
208-
Option(
209-
value=nested_option_name,
210-
feature_schema_id=nested_classification_schema_id,
211-
)
212-
],
213-
)
214-
],
215-
)
216-
],
217-
)
218-
],
219-
)
220-
]
221-
)
222-
label.assign_feature_schema_ids(ontology)
223-
assert label.annotations[0].feature_schema_id == feature_schema_id
224-
assert (
225-
label.annotations[0].classifications[0].feature_schema_id
226-
== classification_schema_id
227-
)
228-
assert (
229-
label.annotations[0].classifications[0].value.answer.feature_schema_id
230-
== option_schema_id
231-
)
232-
233-
23426
def test_schema_assignment_confidence():
23527
name = "line_feature"
23628
label = Label(

0 commit comments

Comments
 (0)