Skip to content

Commit 58aaf62

Browse files
chore: stan + cursor bugbot changes
1 parent 76bdf35 commit 58aaf62

File tree

5 files changed

+30
-36
lines changed

5 files changed

+30
-36
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,14 @@ def _get_annotations_by_type(self, annotation_type):
8282
def frame_annotations(
8383
self,
8484
) -> Dict[
85-
int,
86-
Union[
87-
VideoObjectAnnotation,
88-
VideoClassificationAnnotation,
89-
TemporalClassificationText,
90-
TemporalClassificationQuestion,
85+
Union[int, None],
86+
List[
87+
Union[
88+
VideoObjectAnnotation,
89+
VideoClassificationAnnotation,
90+
TemporalClassificationText,
91+
TemporalClassificationQuestion,
92+
]
9193
],
9294
]:
9395
"""Get temporal annotations organized by frame

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
from typing import Any, Dict, List, Optional, Tuple, Union
99
from pydantic import BaseModel, Field
1010

11-
from ...annotated_types import Cuid
12-
1311

1412
class TemporalClassificationAnswer(BaseModel):
1513
"""
@@ -23,7 +21,6 @@ class TemporalClassificationAnswer(BaseModel):
2321
frames (List[Tuple[int, int]]): List of (start_frame, end_frame) ranges in milliseconds
2422
classifications (Optional[List[Union[TemporalClassificationText, TemporalClassificationQuestion]]]):
2523
Nested classifications within this answer
26-
feature_schema_id (Optional[Cuid]): Feature schema identifier
2724
extra (Dict[str, Any]): Additional metadata
2825
2926
Example:
@@ -53,7 +50,6 @@ class TemporalClassificationAnswer(BaseModel):
5350
classifications: Optional[
5451
List[Union["TemporalClassificationText", "TemporalClassificationQuestion"]]
5552
] = None
56-
feature_schema_id: Optional[Cuid] = None
5753
extra: Dict[str, Any] = Field(default_factory=dict)
5854

5955

@@ -69,7 +65,6 @@ class TemporalClassificationText(BaseModel):
6965
value (List[Tuple[int, int, str]]): List of (start_frame, end_frame, text_value) tuples
7066
classifications (Optional[List[Union[TemporalClassificationText, TemporalClassificationQuestion]]]):
7167
Nested classifications
72-
feature_schema_id (Optional[Cuid]): Feature schema identifier
7368
extra (Dict[str, Any]): Additional metadata
7469
7570
Example:
@@ -107,7 +102,6 @@ class TemporalClassificationText(BaseModel):
107102
classifications: Optional[
108103
List[Union["TemporalClassificationText", "TemporalClassificationQuestion"]]
109104
] = None
110-
feature_schema_id: Optional[Cuid] = None
111105
extra: Dict[str, Any] = Field(default_factory=dict)
112106

113107

@@ -121,7 +115,8 @@ class TemporalClassificationQuestion(BaseModel):
121115
Args:
122116
name (str): Name of the question/classification
123117
value (List[TemporalClassificationAnswer]): List of answer options with frame ranges
124-
feature_schema_id (Optional[Cuid]): Feature schema identifier
118+
classifications (Optional[List[Union[TemporalClassificationText, TemporalClassificationQuestion]]]):
119+
Nested classifications (typically not used at question level)
125120
extra (Dict[str, Any]): Additional metadata
126121
127122
Note:
@@ -187,7 +182,6 @@ class TemporalClassificationQuestion(BaseModel):
187182
classifications: Optional[
188183
List[Union["TemporalClassificationText", "TemporalClassificationQuestion"]]
189184
] = None
190-
feature_schema_id: Optional[Cuid] = None
191185
extra: Dict[str, Any] = Field(default_factory=dict)
192186

193187

libs/labelbox/src/labelbox/data/serialization/ndjson/label.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
TemporalClassificationText,
3030
TemporalClassificationQuestion,
3131
)
32-
from .temporal import create_temporal_ndjson_annotations
32+
from .temporal import create_temporal_ndjson_classifications
3333
from labelbox.types import DocumentRectangle, DocumentEntity
3434
from .classification import (
3535
NDChecklistSubclass,
@@ -75,7 +75,7 @@ def from_common(
7575
yield from cls._create_relationship_annotations(label)
7676
yield from cls._create_non_video_annotations(label)
7777
yield from cls._create_video_annotations(label)
78-
yield from cls._create_temporal_annotations(label)
78+
yield from cls._create_temporal_classifications(label)
7979

8080
@staticmethod
8181
def _get_consecutive_frames(
@@ -167,7 +167,7 @@ def _create_video_annotations(
167167
yield NDObject.from_common(segments, label.data)
168168

169169
@classmethod
170-
def _create_temporal_annotations(
170+
def _create_temporal_classifications(
171171
cls, label: Label
172172
) -> Generator[BaseModel, None, None]:
173173
"""Create temporal annotations with nested classifications using new temporal classes."""
@@ -182,7 +182,7 @@ def _create_temporal_annotations(
182182
return
183183

184184
# Use the new temporal serializer to create NDJSON annotations
185-
ndjson_annotations = create_temporal_ndjson_annotations(
185+
ndjson_annotations = create_temporal_ndjson_classifications(
186186
temporal_annotations, label.data.global_key
187187
)
188188

libs/labelbox/src/labelbox/data/serialization/ndjson/temporal.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class TemporalNDJSON(BaseModel):
2626
dataRow: Dict[str, str]
2727

2828

29-
def create_temporal_ndjson_annotations(
29+
def create_temporal_ndjson_classifications(
3030
annotations: List[
3131
Union[TemporalClassificationText, TemporalClassificationQuestion]
3232
],
@@ -45,11 +45,10 @@ def create_temporal_ndjson_annotations(
4545
if not annotations:
4646
return []
4747

48-
# Group by classification name/schema_id
48+
# Group by classification name
4949
groups = defaultdict(list)
5050
for ann in annotations:
51-
key = ann.feature_schema_id or ann.name
52-
groups[key].append(ann)
51+
groups[ann.name].append(ann)
5352

5453
results = []
5554
for group_key, group_anns in groups.items():
@@ -267,13 +266,12 @@ def _process_nested_classifications(
267266
"""
268267
Process nested classifications recursively.
269268
270-
Groups by name/schema_id and processes each group.
269+
Groups by name and processes each group.
271270
"""
272271
# Group by name
273272
groups = defaultdict(list)
274273
for cls in classifications:
275-
key = cls.feature_schema_id or cls.name
276-
groups[key].append(cls)
274+
groups[cls.name].append(cls)
277275

278276
results = []
279277
for group_key, group_items in groups.items():

libs/labelbox/tests/data/serialization/ndjson/test_temporal.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import labelbox.types as lb_types
44
from labelbox.data.serialization.ndjson.temporal import (
5-
create_temporal_ndjson_annotations,
5+
create_temporal_ndjson_classifications,
66
)
77

88

@@ -18,7 +18,7 @@ def test_temporal_text_simple():
1818
)
1919
]
2020

21-
result = create_temporal_ndjson_annotations(annotations, "test-global-key")
21+
result = create_temporal_ndjson_classifications(annotations, "test-global-key")
2222

2323
assert len(result) == 1
2424
assert result[0].name == "transcription"
@@ -49,7 +49,7 @@ def test_temporal_question_radio():
4949
)
5050
]
5151

52-
result = create_temporal_ndjson_annotations(annotations, "test-global-key")
52+
result = create_temporal_ndjson_classifications(annotations, "test-global-key")
5353

5454
assert len(result) == 1
5555
assert result[0].name == "speaker"
@@ -78,7 +78,7 @@ def test_temporal_question_checklist():
7878
)
7979
]
8080

81-
result = create_temporal_ndjson_annotations(annotations, "test-global-key")
81+
result = create_temporal_ndjson_classifications(annotations, "test-global-key")
8282

8383
assert len(result) == 1
8484
assert result[0].name == "audio_quality"
@@ -123,7 +123,7 @@ def test_temporal_text_nested():
123123
)
124124
]
125125

126-
result = create_temporal_ndjson_annotations(annotations, "test-global-key")
126+
result = create_temporal_ndjson_classifications(annotations, "test-global-key")
127127

128128
assert len(result) == 1
129129
assert result[0].name == "transcription"
@@ -185,7 +185,7 @@ def test_temporal_question_nested():
185185
)
186186
]
187187

188-
result = create_temporal_ndjson_annotations(annotations, "test-global-key")
188+
result = create_temporal_ndjson_classifications(annotations, "test-global-key")
189189

190190
assert len(result) == 1
191191
answer = result[0].answer[0]
@@ -227,7 +227,7 @@ def test_frame_validation_discard_invalid():
227227
)
228228
]
229229

230-
result = create_temporal_ndjson_annotations(annotations, "test-global-key")
230+
result = create_temporal_ndjson_classifications(annotations, "test-global-key")
231231

232232
# Find the nested notes classification
233233
answer = result[0].answer[0]
@@ -251,7 +251,7 @@ def test_frame_deduplication():
251251
)
252252
]
253253

254-
result = create_temporal_ndjson_annotations(annotations, "test-global-key")
254+
result = create_temporal_ndjson_classifications(annotations, "test-global-key")
255255

256256
# Should only have one entry
257257
assert len(result[0].answer) == 1
@@ -291,7 +291,7 @@ def test_mixed_text_and_question_nesting():
291291
)
292292
]
293293

294-
result = create_temporal_ndjson_annotations(annotations, "test-global-key")
294+
result = create_temporal_ndjson_classifications(annotations, "test-global-key")
295295

296296
assert len(result) == 1
297297
answer = result[0].answer[0]
@@ -341,7 +341,7 @@ def test_inductive_structure_text_with_shared_nested_radio():
341341
)
342342
]
343343

344-
result = create_temporal_ndjson_annotations(annotations, "test-global-key")
344+
result = create_temporal_ndjson_classifications(annotations, "test-global-key")
345345

346346
assert len(result) == 1
347347
assert result[0].name == "content_notes"
@@ -416,7 +416,7 @@ def test_inductive_structure_checklist_with_multiple_text_values():
416416
)
417417
]
418418

419-
result = create_temporal_ndjson_annotations(annotations, "test-global-key")
419+
result = create_temporal_ndjson_classifications(annotations, "test-global-key")
420420

421421
assert len(result) == 1
422422
assert result[0].name == "checklist_class"

0 commit comments

Comments
 (0)