fix: recompute FaceResult status/total_faces after config-driven parse
The config-driven swift/python branches in run_face_with_config parsed face.json into FaceResult without calling compute_status(). swift_face outputs frames[].faces but no top-level 'status'/'total_faces' fields, so the resulting FaceResult always reported 0 total faces and status=None even when the file contained faces (e.g. 212 faces in 020.mp4). This broke the whole downstream pipeline for any file processed via the config-driven swift path: - worker logged 'FACE completed, status=, 162 frames, 0 total faces' - has_faces=false in P4 TKG trigger (face.json status mismatch) - face_cluster / qdrant_face ingestion gates never satisfied - job stuck in 'waiting for ingestion' forever Fix: call compute_status() after parsing in both swift and python config-driven branches, matching the existing face.json / mediapipe paths. Adds test_compute_status_recalculates_total_faces to lock the behavior.
This commit is contained in:
@@ -410,8 +410,9 @@ async fn run_face_with_config(
|
||||
|
||||
let json_str = std::fs::read_to_string(output_path)
|
||||
.context("Failed to read Swift FACE output")?;
|
||||
let result: FaceResult = serde_json::from_str(&json_str)
|
||||
let mut result: FaceResult = serde_json::from_str(&json_str)
|
||||
.context("Failed to parse Swift FACE output")?;
|
||||
result.compute_status();
|
||||
|
||||
return Ok(Some(result));
|
||||
}
|
||||
@@ -432,8 +433,9 @@ async fn run_face_with_config(
|
||||
|
||||
let json_str = std::fs::read_to_string(output_path)
|
||||
.context("Failed to read Python FACE output")?;
|
||||
let result: FaceResult = serde_json::from_str(&json_str)
|
||||
let mut result: FaceResult = serde_json::from_str(&json_str)
|
||||
.context("Failed to parse Python FACE output")?;
|
||||
result.compute_status();
|
||||
|
||||
return Ok(Some(result));
|
||||
}
|
||||
@@ -525,6 +527,29 @@ mod tests {
|
||||
assert!(result.frames[0].faces[0].attributes.is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_compute_status_recalculates_total_faces() {
|
||||
let json = r#"{
|
||||
"fps": 30.0,
|
||||
"frame_count": 2,
|
||||
"frames": [
|
||||
{"frame": 0, "timestamp": 0.0, "faces": [
|
||||
{"confidence": 0.9, "bbox": {"x": 1, "y": 2, "width": 3, "height": 4}}
|
||||
]},
|
||||
{"frame": 1, "timestamp": 0.03, "faces": [
|
||||
{"confidence": 0.8, "bbox": {"x": 5, "y": 6, "width": 7, "height": 8}},
|
||||
{"confidence": 0.7, "bbox": {"x": 9, "y": 10, "width": 11, "height": 12}}
|
||||
]}
|
||||
]
|
||||
}"#;
|
||||
let mut result: FaceResult = serde_json::from_str(json).unwrap();
|
||||
assert_eq!(result.total_faces, 0, "json has no total_faces field");
|
||||
assert!(result.status.is_none(), "json has no status field");
|
||||
result.compute_status();
|
||||
assert_eq!(result.total_faces, 3);
|
||||
assert_eq!(result.status.unwrap(), FaceStatus::HasFaces);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_face_result_empty_frames() {
|
||||
let result = FaceResult {
|
||||
|
||||
Reference in New Issue
Block a user