Revamp EasyCom floor event review pipeline

This commit is contained in:
Xin Wang
2026-09-14 18:43:58 +08:00
parent 7d9db4af58
commit 4f88806d56
11 changed files with 1081 additions and 965 deletions
+43 -11
View File
@@ -56,11 +56,23 @@ class FloorEventReviewTests(unittest.TestCase):
"clip_stem": "00-00-000",
"source_start_frame": 25,
"dense_start_seconds": 1.2,
"event_time": 1.2,
"candidate_source": "WEARER_ONSET",
"ai_verdict": "POSITIVE",
"ai_event_type": "EOT_RESPONSE",
"ai_subtype": None,
}
)
+ "\n",
encoding="utf-8",
)
(root / "easycom_session_timelines.json").write_text(
json.dumps({"schema_version": 1, "sessions": {"Session_4": [
{"participant_id": 4, "participant_role": "other", "start_seconds": 0.0, "end_seconds": 1.0},
{"participant_id": 2, "participant_role": "wearer", "start_seconds": 1.2, "end_seconds": 2.0},
]}}),
encoding="utf-8",
)
return dataset, events
def test_candidate_detail_resolves_media_and_transcript(self) -> None:
@@ -79,6 +91,7 @@ class FloorEventReviewTests(unittest.TestCase):
self.assertEqual(detail["event_local_seconds"], 1.2)
self.assertEqual(len(detail["transcript"]), 2)
self.assertTrue(detail["transcript"][1]["is_anchor"])
self.assertEqual(len(repository.session_timelines["Session_4"]), 2)
def test_review_store_writes_resumable_jsonl_and_csv(self) -> None:
with tempfile.TemporaryDirectory() as temporary:
@@ -88,15 +101,12 @@ class FloorEventReviewTests(unittest.TestCase):
output = root / "reviews" / "reviews.jsonl"
store = ReviewStore(output, candidates)
review = {
"protocol_disposition": "positive",
"hard_negative_type": "not_applicable",
"validity": "valid",
"onset_function": "backchannel",
"context": "addressed_wearer",
"offset_outcome": "not_applicable",
"anchor_adjustment_bins": 0,
"behavior_adjustment_bins": 0,
"region_end_adjustment_bins": None,
"human_action": "accept",
"human_verdict": None,
"human_event_type": None,
"human_subtype": None,
"exclude_reason": None,
"boundary_correction_seconds": None,
"confidence": "high",
"reviewer": "r1",
"notes": "clear acknowledgement",
@@ -106,9 +116,10 @@ class FloorEventReviewTests(unittest.TestCase):
self.assertTrue(output.with_suffix(".csv").is_file())
resumed = ReviewStore(output, candidates)
self.assertEqual(
resumed.reviews[candidates[0].candidate_id]["review"]["onset_function"],
"backchannel",
resumed.reviews[candidates[0].candidate_id]["review"]["human_event_type"],
"EOT_RESPONSE",
)
self.assertFalse(resumed.reviews[candidates[0].candidate_id]["review"]["relabeled"])
def test_directory_expansion_excludes_output(self) -> None:
with tempfile.TemporaryDirectory() as temporary:
@@ -122,6 +133,27 @@ class FloorEventReviewTests(unittest.TestCase):
[candidate.resolve()],
)
def test_relabel_preserves_ai_and_records_human_decision(self) -> None:
with tempfile.TemporaryDirectory() as temporary:
root = Path(temporary)
_, events = self._fixture(root)
candidates = load_candidates([events])
store = ReviewStore(root / "reviews.jsonl", candidates)
record = store.save(candidates[0].candidate_id, {
"human_action": "relabel",
"human_verdict": "HARD_NEGATIVE",
"human_event_type": None,
"human_subtype": "EOT_WEARER_BACKCHANNEL",
"exclude_reason": None,
"boundary_correction_seconds": None,
"confidence": "medium",
"reviewer": "r2",
"notes": "brief acknowledgement",
})
self.assertEqual(record["ai_event_type"], "EOT_RESPONSE")
self.assertEqual(record["review"]["human_subtype"], "EOT_WEARER_BACKCHANNEL")
self.assertTrue(record["review"]["relabeled"])
def test_byte_ranges(self) -> None:
self.assertEqual(parse_byte_range("bytes=2-5", 10), (2, 5))
self.assertEqual(parse_byte_range("bytes=7-", 10), (7, 9))