Skip to content

Commit 9675c73

Browse files
chore: update tests
1 parent 538ba66 commit 9675c73

File tree

3 files changed

+2
-512
lines changed

3 files changed

+2
-512
lines changed

libs/labelbox/tests/data/annotation_import/conftest.py

Lines changed: 2 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,82 +1630,6 @@ def video_checklist_inference(prediction_id_mapping):
16301630
return checklists
16311631

16321632

1633-
@pytest.fixture
1634-
def audio_checklist_inference(prediction_id_mapping):
1635-
"""Audio temporal checklist inference with frame-based timing"""
1636-
checklists = []
1637-
for feature in prediction_id_mapping:
1638-
if "checklist" not in feature:
1639-
continue
1640-
checklist = feature["checklist"].copy()
1641-
checklist.update(
1642-
{
1643-
"answers": [
1644-
{"name": "first_checklist_answer"},
1645-
{"name": "second_checklist_answer"},
1646-
],
1647-
"frame": 2500, # 2.5 seconds in milliseconds
1648-
}
1649-
)
1650-
del checklist["tool"]
1651-
checklists.append(checklist)
1652-
return checklists
1653-
1654-
1655-
@pytest.fixture
1656-
def audio_text_inference(prediction_id_mapping):
1657-
"""Audio temporal text inference with frame-based timing"""
1658-
texts = []
1659-
for feature in prediction_id_mapping:
1660-
if "text" not in feature:
1661-
continue
1662-
text = feature["text"].copy()
1663-
text.update({
1664-
"answer": "free form text...",
1665-
"frame": 5000, # 5.0 seconds in milliseconds
1666-
})
1667-
del text["tool"]
1668-
texts.append(text)
1669-
return texts
1670-
1671-
1672-
@pytest.fixture
1673-
def audio_radio_inference(prediction_id_mapping):
1674-
"""Audio temporal radio inference with frame-based timing"""
1675-
radios = []
1676-
for feature in prediction_id_mapping:
1677-
if "radio" not in feature:
1678-
continue
1679-
radio = feature["radio"].copy()
1680-
radio.update({
1681-
"answer": {"name": "first_radio_answer"},
1682-
"frame": 7500, # 7.5 seconds in milliseconds
1683-
})
1684-
del radio["tool"]
1685-
radios.append(radio)
1686-
return radios
1687-
1688-
1689-
@pytest.fixture
1690-
def audio_text_entity_inference(prediction_id_mapping):
1691-
"""Audio temporal text entity inference with frame-based timing"""
1692-
entities = []
1693-
for feature in prediction_id_mapping:
1694-
if "text" not in feature:
1695-
continue
1696-
entity = feature["text"].copy()
1697-
entity.update({
1698-
"frame": 3000, # 3.0 seconds in milliseconds
1699-
"location": {
1700-
"start": 0,
1701-
"end": 11,
1702-
}
1703-
})
1704-
del entity["tool"]
1705-
entities.append(entity)
1706-
return entities
1707-
1708-
17091633
@pytest.fixture
17101634
def message_single_selection_inference(
17111635
prediction_id_mapping, mmc_example_data_row_message_ids
@@ -1843,18 +1767,9 @@ def annotations_by_media_type(
18431767
radio_inference,
18441768
radio_inference_index_mmc,
18451769
text_inference_index_mmc,
1846-
audio_checklist_inference,
1847-
audio_text_inference,
1848-
audio_radio_inference,
1849-
audio_text_entity_inference,
18501770
):
18511771
return {
1852-
MediaType.Audio: [
1853-
audio_checklist_inference,
1854-
audio_text_inference,
1855-
audio_radio_inference,
1856-
audio_text_entity_inference
1857-
],
1772+
MediaType.Audio: [checklist_inference, text_inference],
18581773
MediaType.Conversational: [
18591774
checklist_inference_index,
18601775
text_inference_index,
@@ -2094,7 +2009,7 @@ def _convert_to_plain_object(obj):
20942009

20952010
@pytest.fixture
20962011
def annotation_import_test_helpers() -> Type[AnnotationImportTestHelpers]:
2097-
return AnnotationImportTestHelpers
2012+
return AnnotationImportTestHelpers()
20982013

20992014

21002015
@pytest.fixture()
@@ -2176,7 +2091,6 @@ def expected_export_v2_audio():
21762091
{
21772092
"name": "checklist",
21782093
"value": "checklist",
2179-
"frame": 2500,
21802094
"checklist_answers": [
21812095
{
21822096
"name": "first_checklist_answer",
@@ -2193,34 +2107,11 @@ def expected_export_v2_audio():
21932107
{
21942108
"name": "text",
21952109
"value": "text",
2196-
"frame": 5000,
21972110
"text_answer": {
21982111
"content": "free form text...",
21992112
"classifications": [],
22002113
},
22012114
},
2202-
{
2203-
"name": "radio",
2204-
"value": "radio",
2205-
"frame": 7500,
2206-
"radio_answer": {
2207-
"name": "first_radio_answer",
2208-
"classifications": [],
2209-
},
2210-
},
2211-
],
2212-
"objects": [
2213-
{
2214-
"name": "text",
2215-
"value": "text",
2216-
"frame": 3000,
2217-
"annotation_kind": "TextEntity",
2218-
"classifications": [],
2219-
"location": {
2220-
"start": 0,
2221-
"end": 11,
2222-
},
2223-
}
22242115
],
22252116
"segments": {},
22262117
"timestamp": {},

libs/labelbox/tests/data/annotation_import/test_generic_data_types.py

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -268,94 +268,6 @@ def test_import_mal_annotations(
268268
# MAL Labels cannot be exported and compared to input labels
269269

270270

271-
def test_audio_temporal_annotations_fixtures():
272-
"""Test that audio temporal annotation fixtures are properly structured"""
273-
# This test verifies our fixtures work without requiring the full integration environment
274-
275-
# Mock prediction_id_mapping structure that our fixtures expect
276-
mock_prediction_id_mapping = [
277-
{
278-
"checklist": {
279-
"tool": "checklist_tool",
280-
"name": "checklist",
281-
"value": "checklist",
282-
},
283-
"text": {"tool": "text_tool", "name": "text", "value": "text"},
284-
"radio": {"tool": "radio_tool", "name": "radio", "value": "radio"},
285-
}
286-
]
287-
288-
# Test that our fixtures can process the mock data
289-
# Note: We can't actually call the fixtures directly in a unit test,
290-
# but we can verify the structure is correct by checking the fixture definitions
291-
292-
# Verify that our fixtures are properly defined and accessible
293-
from .conftest import (
294-
audio_checklist_inference,
295-
audio_text_inference,
296-
audio_radio_inference,
297-
audio_text_entity_inference,
298-
)
299-
300-
# Check that all required fixtures exist
301-
assert audio_checklist_inference is not None
302-
assert audio_text_inference is not None
303-
assert audio_radio_inference is not None
304-
assert audio_text_entity_inference is not None
305-
306-
# Verify the fixtures are callable (they should be functions)
307-
assert callable(audio_checklist_inference)
308-
assert callable(audio_text_inference)
309-
assert callable(audio_radio_inference)
310-
assert callable(audio_text_entity_inference)
311-
312-
313-
def test_audio_temporal_annotations_integration(
314-
client: Client,
315-
configured_project: Project,
316-
annotations_by_media_type,
317-
media_type=MediaType.Audio,
318-
):
319-
"""Test that audio temporal annotations work correctly in the integration framework"""
320-
# Filter to only audio annotations
321-
audio_annotations = annotations_by_media_type[MediaType.Audio]
322-
323-
# Verify we have the expected audio temporal annotations
324-
assert len(audio_annotations) == 4 # checklist, text, radio, text_entity
325-
326-
# Check that temporal annotations have frame information
327-
for annotation in audio_annotations:
328-
if "frame" in annotation:
329-
assert isinstance(annotation["frame"], int)
330-
assert annotation["frame"] >= 0
331-
# Verify frame values are in milliseconds (reasonable range for audio)
332-
assert annotation["frame"] <= 600000 # 10 minutes max
333-
334-
# Test import with audio temporal annotations
335-
label_import = lb.LabelImport.create_from_objects(
336-
client,
337-
configured_project.uid,
338-
f"test-import-audio-temporal-{uuid.uuid4()}",
339-
audio_annotations,
340-
)
341-
label_import.wait_until_done()
342-
343-
# Verify import was successful
344-
assert label_import.state == AnnotationImportState.FINISHED
345-
assert len(label_import.errors) == 0
346-
347-
# Verify all annotations were imported successfully
348-
all_annotations = sorted([a["uuid"] for a in audio_annotations])
349-
successful_annotations = sorted(
350-
[
351-
status["uuid"]
352-
for status in label_import.statuses
353-
if status["status"] == "SUCCESS"
354-
]
355-
)
356-
assert successful_annotations == all_annotations
357-
358-
359271
@pytest.mark.parametrize(
360272
"configured_project_by_global_key, media_type",
361273
[

0 commit comments

Comments
 (0)