feat: face fix deployment + trace_* regeneration + executor stderr filter fix
- swift_face.swift: frame rounding (.rounded()), conf 0.75, min_size 64 - trace_* directories regenerated for KOBA (37 traces, start_frame 5307) - executor.rs: stderr filter now logs all non-empty stderr (was discarding) - VAD not skippable in ASRX (main_fixed.py Step 2 always runs) - Step 2.5 sentence boundary refinement added - Cluster agent async endpoints + similarity transparency - Keyword search: relationship text extraction, priority ordering - Face fix handoff doc for Studio team
This commit is contained in:
+105
-67
@@ -96,7 +96,13 @@ pub struct IngestionState {
|
||||
pub const STAGE_1_PROCESSORS: &[&str] = &["asr", "ocr", "face"];
|
||||
|
||||
/// Stage 2 processors (depend on stage 1)
|
||||
pub const STAGE_2_PROCESSORS: &[&str] = &["asrx", "face_vector", "face_trace", "speaker_vector", "face_cluster"];
|
||||
pub const STAGE_2_PROCESSORS: &[&str] = &[
|
||||
"asrx",
|
||||
"face_vector",
|
||||
"face_trace",
|
||||
"speaker_vector",
|
||||
"face_cluster",
|
||||
];
|
||||
|
||||
/// Stage 3 processors (depend on stage 2 or face)
|
||||
pub const STAGE_3_PROCESSORS: &[&str] = &["pose", "appearance"];
|
||||
@@ -104,9 +110,16 @@ pub const STAGE_3_PROCESSORS: &[&str] = &["pose", "appearance"];
|
||||
/// All processors in order
|
||||
pub const ALL_PROCESSORS: &[&str] = &[
|
||||
"cut", // Registration
|
||||
"asr", "ocr", "face", // Stage 1
|
||||
"asrx", "face_vector", "face_trace", "speaker_vector", "face_cluster", // Stage 2
|
||||
"pose", "appearance", // Stage 3
|
||||
"asr",
|
||||
"ocr",
|
||||
"face", // Stage 1
|
||||
"asrx",
|
||||
"face_vector",
|
||||
"face_trace",
|
||||
"speaker_vector",
|
||||
"face_cluster", // Stage 2
|
||||
"pose",
|
||||
"appearance", // Stage 3
|
||||
];
|
||||
|
||||
/// Get processor dependencies
|
||||
@@ -140,22 +153,22 @@ impl FileLifecycle {
|
||||
/// Create a new lifecycle for a file
|
||||
pub fn new(file_uuid: &str) -> Self {
|
||||
let now = chrono::Utc::now().to_rfc3339();
|
||||
|
||||
|
||||
let mut stage_1_processors = HashMap::new();
|
||||
for proc in STAGE_1_PROCESSORS {
|
||||
stage_1_processors.insert(proc.to_string(), ProcessorState::new("pending"));
|
||||
}
|
||||
|
||||
|
||||
let mut stage_2_processors = HashMap::new();
|
||||
for proc in STAGE_2_PROCESSORS {
|
||||
stage_2_processors.insert(proc.to_string(), ProcessorState::new("pending"));
|
||||
}
|
||||
|
||||
|
||||
let mut stage_3_processors = HashMap::new();
|
||||
for proc in STAGE_3_PROCESSORS {
|
||||
stage_3_processors.insert(proc.to_string(), ProcessorState::new("pending"));
|
||||
}
|
||||
|
||||
|
||||
Self {
|
||||
version: LIFECYCLE_VERSION.to_string(),
|
||||
file_uuid: file_uuid.to_string(),
|
||||
@@ -185,16 +198,22 @@ impl FileLifecycle {
|
||||
/// Create lifecycle from existing outputs (for recovery)
|
||||
pub fn from_existing_outputs(output_dir: &str, file_uuid: &str) -> Self {
|
||||
let mut lifecycle = Self::new(file_uuid);
|
||||
|
||||
|
||||
// Check registration outputs
|
||||
let has_profile = Path::new(output_dir).join(format!("{}.profile.json", file_uuid)).exists();
|
||||
let has_probe = Path::new(output_dir).join(format!("{}.probe.json", file_uuid)).exists();
|
||||
let has_cut = Path::new(output_dir).join(format!("{}.cut.json", file_uuid)).exists();
|
||||
|
||||
let has_profile = Path::new(output_dir)
|
||||
.join(format!("{}.profile.json", file_uuid))
|
||||
.exists();
|
||||
let has_probe = Path::new(output_dir)
|
||||
.join(format!("{}.probe.json", file_uuid))
|
||||
.exists();
|
||||
let has_cut = Path::new(output_dir)
|
||||
.join(format!("{}.cut.json", file_uuid))
|
||||
.exists();
|
||||
|
||||
if has_profile && has_probe && has_cut {
|
||||
lifecycle.mark_stage_completed("registration");
|
||||
}
|
||||
|
||||
|
||||
// Check stage 1 processors
|
||||
for proc in STAGE_1_PROCESSORS {
|
||||
let path = Path::new(output_dir).join(format!("{}.{}.json", file_uuid, proc));
|
||||
@@ -202,33 +221,41 @@ impl FileLifecycle {
|
||||
lifecycle.mark_processor_completed(proc, None);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check stage 2 processors
|
||||
let has_asrx = Path::new(output_dir).join(format!("{}.asrx.json", file_uuid)).exists();
|
||||
let has_asrx = Path::new(output_dir)
|
||||
.join(format!("{}.asrx.json", file_uuid))
|
||||
.exists();
|
||||
if has_asrx {
|
||||
lifecycle.mark_processor_completed("asrx", None);
|
||||
// speaker_vector comes from asrx
|
||||
lifecycle.mark_processor_completed("speaker_vector", None);
|
||||
}
|
||||
|
||||
|
||||
// face_vector: check if face.json exists (vectors stored in Qdrant)
|
||||
let has_face = Path::new(output_dir).join(format!("{}.face.json", file_uuid)).exists();
|
||||
let has_face = Path::new(output_dir)
|
||||
.join(format!("{}.face.json", file_uuid))
|
||||
.exists();
|
||||
if has_face {
|
||||
lifecycle.mark_processor_completed("face_vector", None);
|
||||
}
|
||||
|
||||
|
||||
// face_trace: check face_traced.json (continuous face tracking)
|
||||
let has_face_traced = Path::new(output_dir).join(format!("{}.face_traced.json", file_uuid)).exists();
|
||||
let has_face_traced = Path::new(output_dir)
|
||||
.join(format!("{}.face_traced.json", file_uuid))
|
||||
.exists();
|
||||
if has_face_traced {
|
||||
lifecycle.mark_processor_completed("face_trace", None);
|
||||
}
|
||||
|
||||
|
||||
// face_cluster: check face_cluster.json (deduplication of traces)
|
||||
let has_face_cluster = Path::new(output_dir).join(format!("{}.face_cluster.json", file_uuid)).exists();
|
||||
let has_face_cluster = Path::new(output_dir)
|
||||
.join(format!("{}.face_cluster.json", file_uuid))
|
||||
.exists();
|
||||
if has_face_cluster {
|
||||
lifecycle.mark_processor_completed("face_cluster", None);
|
||||
}
|
||||
|
||||
|
||||
// Check stage 3 processors
|
||||
for proc in STAGE_3_PROCESSORS {
|
||||
let path = Path::new(output_dir).join(format!("{}.{}.json", file_uuid, proc));
|
||||
@@ -236,7 +263,7 @@ impl FileLifecycle {
|
||||
lifecycle.mark_processor_completed(proc, None);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lifecycle.update_group_status();
|
||||
lifecycle
|
||||
}
|
||||
@@ -251,8 +278,7 @@ impl FileLifecycle {
|
||||
/// Save lifecycle to disk
|
||||
pub fn save_to_disk(&self, output_dir: &str) -> Result<()> {
|
||||
let path = Self::lifecycle_path(output_dir, &self.file_uuid);
|
||||
let json = serde_json::to_string_pretty(self)
|
||||
.context("Failed to serialize lifecycle")?;
|
||||
let json = serde_json::to_string_pretty(self).context("Failed to serialize lifecycle")?;
|
||||
std::fs::write(&path, json)
|
||||
.with_context(|| format!("Failed to write lifecycle to {}", path.display()))?;
|
||||
tracing::debug!("[Lifecycle] Saved for {}", self.file_uuid);
|
||||
@@ -278,7 +304,7 @@ impl FileLifecycle {
|
||||
pub fn mark_stage_started(&mut self, stage: &str) {
|
||||
let now = chrono::Utc::now().to_rfc3339();
|
||||
self.updated_at = now.clone();
|
||||
|
||||
|
||||
match stage {
|
||||
"registration" => {
|
||||
self.stages.registration.status = "in_progress".to_string();
|
||||
@@ -313,7 +339,7 @@ impl FileLifecycle {
|
||||
pub fn mark_stage_completed(&mut self, stage: &str) {
|
||||
let now = chrono::Utc::now().to_rfc3339();
|
||||
self.updated_at = now.clone();
|
||||
|
||||
|
||||
match stage {
|
||||
"registration" => {
|
||||
self.stages.registration.status = "completed".to_string();
|
||||
@@ -343,7 +369,7 @@ impl FileLifecycle {
|
||||
pub fn mark_processor_started(&mut self, processor: &str) {
|
||||
let now = chrono::Utc::now().to_rfc3339();
|
||||
self.updated_at = now.clone();
|
||||
|
||||
|
||||
let stage = get_stage(processor);
|
||||
let group = match stage {
|
||||
"stage_1" => &mut self.stages.stage_1_processors,
|
||||
@@ -351,12 +377,12 @@ impl FileLifecycle {
|
||||
"stage_3" => &mut self.stages.stage_3_processors,
|
||||
_ => return,
|
||||
};
|
||||
|
||||
|
||||
if let Some(proc_state) = group.processors.get_mut(processor) {
|
||||
proc_state.status = "running".to_string();
|
||||
proc_state.started_at = Some(now);
|
||||
}
|
||||
|
||||
|
||||
// Update group status
|
||||
group.status = "in_progress".to_string();
|
||||
}
|
||||
@@ -365,7 +391,7 @@ impl FileLifecycle {
|
||||
pub fn mark_processor_completed(&mut self, processor: &str, output_count: Option<i64>) {
|
||||
let now = chrono::Utc::now().to_rfc3339();
|
||||
self.updated_at = now.clone();
|
||||
|
||||
|
||||
let stage = get_stage(processor);
|
||||
let group = match stage {
|
||||
"stage_1" => &mut self.stages.stage_1_processors,
|
||||
@@ -373,13 +399,13 @@ impl FileLifecycle {
|
||||
"stage_3" => &mut self.stages.stage_3_processors,
|
||||
_ => return,
|
||||
};
|
||||
|
||||
|
||||
if let Some(proc_state) = group.processors.get_mut(processor) {
|
||||
proc_state.status = "completed".to_string();
|
||||
proc_state.completed_at = Some(now);
|
||||
proc_state.output_count = output_count;
|
||||
}
|
||||
|
||||
|
||||
self.update_group_status();
|
||||
}
|
||||
|
||||
@@ -387,7 +413,7 @@ impl FileLifecycle {
|
||||
pub fn mark_processor_failed(&mut self, processor: &str, error: &str, retry_count: i32) {
|
||||
let now = chrono::Utc::now().to_rfc3339();
|
||||
self.updated_at = now.clone();
|
||||
|
||||
|
||||
let stage = get_stage(processor);
|
||||
let group = match stage {
|
||||
"stage_1" => &mut self.stages.stage_1_processors,
|
||||
@@ -395,20 +421,20 @@ impl FileLifecycle {
|
||||
"stage_3" => &mut self.stages.stage_3_processors,
|
||||
_ => return,
|
||||
};
|
||||
|
||||
|
||||
if let Some(proc_state) = group.processors.get_mut(processor) {
|
||||
proc_state.status = "failed".to_string();
|
||||
proc_state.error = Some(error.to_string());
|
||||
proc_state.retry_count = Some(retry_count);
|
||||
}
|
||||
|
||||
|
||||
self.update_group_status();
|
||||
}
|
||||
|
||||
/// Update processor progress
|
||||
pub fn update_processor_progress(&mut self, processor: &str, current: i64, total: i64) {
|
||||
self.updated_at = chrono::Utc::now().to_rfc3339();
|
||||
|
||||
|
||||
let stage = get_stage(processor);
|
||||
let group = match stage {
|
||||
"stage_1" => &mut self.stages.stage_1_processors,
|
||||
@@ -416,7 +442,7 @@ impl FileLifecycle {
|
||||
"stage_3" => &mut self.stages.stage_3_processors,
|
||||
_ => return,
|
||||
};
|
||||
|
||||
|
||||
if let Some(proc_state) = group.processors.get_mut(processor) {
|
||||
proc_state.progress = Some(ProgressInfo { current, total });
|
||||
}
|
||||
@@ -427,11 +453,11 @@ impl FileLifecycle {
|
||||
// Update stage 1
|
||||
let stage_1 = &mut self.stages.stage_1_processors;
|
||||
stage_1.status = compute_group_status(&stage_1.processors);
|
||||
|
||||
|
||||
// Update stage 2
|
||||
let stage_2 = &mut self.stages.stage_2_processors;
|
||||
stage_2.status = compute_group_status(&stage_2.processors);
|
||||
|
||||
|
||||
// Update stage 3
|
||||
let stage_3 = &mut self.stages.stage_3_processors;
|
||||
stage_3.status = compute_group_status(&stage_3.processors);
|
||||
@@ -445,7 +471,7 @@ impl FileLifecycle {
|
||||
if deps.is_empty() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
for dep in deps {
|
||||
if !self.is_processor_completed(dep) {
|
||||
return false;
|
||||
@@ -463,8 +489,10 @@ impl FileLifecycle {
|
||||
"stage_3" => &self.stages.stage_3_processors,
|
||||
_ => return processor == "cut" && self.stages.registration.status == "completed",
|
||||
};
|
||||
|
||||
group.processors.get(processor)
|
||||
|
||||
group
|
||||
.processors
|
||||
.get(processor)
|
||||
.map(|p| p.status == "completed")
|
||||
.unwrap_or(false)
|
||||
}
|
||||
@@ -472,40 +500,40 @@ impl FileLifecycle {
|
||||
/// Get next processors to run
|
||||
pub fn get_next_processors(&self) -> Vec<String> {
|
||||
let mut next = Vec::new();
|
||||
|
||||
|
||||
// Check stage 1
|
||||
if self.stages.registration.status != "completed" {
|
||||
return next; // Registration must complete first
|
||||
}
|
||||
|
||||
|
||||
for proc in STAGE_1_PROCESSORS {
|
||||
if !self.is_processor_completed(proc) && self.can_run_processor(proc) {
|
||||
next.push(proc.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if !next.is_empty() {
|
||||
return next;
|
||||
}
|
||||
|
||||
|
||||
// Check stage 2
|
||||
for proc in STAGE_2_PROCESSORS {
|
||||
if !self.is_processor_completed(proc) && self.can_run_processor(proc) {
|
||||
next.push(proc.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if !next.is_empty() {
|
||||
return next;
|
||||
}
|
||||
|
||||
|
||||
// Check stage 3
|
||||
for proc in STAGE_3_PROCESSORS {
|
||||
if !self.is_processor_completed(proc) && self.can_run_processor(proc) {
|
||||
next.push(proc.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
next
|
||||
}
|
||||
|
||||
@@ -546,13 +574,13 @@ impl FileLifecycle {
|
||||
pub fn overall_progress(&self) -> f64 {
|
||||
let mut completed = 0;
|
||||
let mut total = 0;
|
||||
|
||||
|
||||
// Registration
|
||||
total += 1;
|
||||
if self.stages.registration.status == "completed" {
|
||||
completed += 1;
|
||||
}
|
||||
|
||||
|
||||
// Stage 1
|
||||
for proc in STAGE_1_PROCESSORS {
|
||||
total += 1;
|
||||
@@ -560,7 +588,7 @@ impl FileLifecycle {
|
||||
completed += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Stage 2
|
||||
for proc in STAGE_2_PROCESSORS {
|
||||
total += 1;
|
||||
@@ -568,7 +596,7 @@ impl FileLifecycle {
|
||||
completed += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Stage 3
|
||||
for proc in STAGE_3_PROCESSORS {
|
||||
total += 1;
|
||||
@@ -576,14 +604,24 @@ impl FileLifecycle {
|
||||
completed += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Rules
|
||||
total += 3;
|
||||
if self.stages.rule_1_ingestion.status == "completed" { completed += 1; }
|
||||
if self.stages.rule_2_ingestion.status == "completed" { completed += 1; }
|
||||
if self.stages.rule_3_ingestion.status == "completed" { completed += 1; }
|
||||
|
||||
if total == 0 { 0.0 } else { (completed as f64 / total as f64) * 100.0 }
|
||||
if self.stages.rule_1_ingestion.status == "completed" {
|
||||
completed += 1;
|
||||
}
|
||||
if self.stages.rule_2_ingestion.status == "completed" {
|
||||
completed += 1;
|
||||
}
|
||||
if self.stages.rule_3_ingestion.status == "completed" {
|
||||
completed += 1;
|
||||
}
|
||||
|
||||
if total == 0 {
|
||||
0.0
|
||||
} else {
|
||||
(completed as f64 / total as f64) * 100.0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -630,7 +668,7 @@ fn compute_group_status(processors: &HashMap<String, ProcessorState>) -> String
|
||||
let mut has_failed = false;
|
||||
let mut has_pending = false;
|
||||
let mut completed_count = 0;
|
||||
|
||||
|
||||
for proc in processors.values() {
|
||||
match proc.status.as_str() {
|
||||
"running" => has_running = true,
|
||||
@@ -640,7 +678,7 @@ fn compute_group_status(processors: &HashMap<String, ProcessorState>) -> String
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if has_running {
|
||||
"in_progress".to_string()
|
||||
} else if has_failed {
|
||||
@@ -678,14 +716,14 @@ mod tests {
|
||||
#[test]
|
||||
fn test_can_run_processor() {
|
||||
let mut lifecycle = FileLifecycle::new("test");
|
||||
|
||||
|
||||
// Initially, asrx cannot run (needs cut + asr)
|
||||
assert!(!lifecycle.can_run_processor("asrx"));
|
||||
|
||||
|
||||
// After registration, still cannot run (needs asr)
|
||||
lifecycle.mark_stage_completed("registration");
|
||||
assert!(!lifecycle.can_run_processor("asrx"));
|
||||
|
||||
|
||||
// After asr completes, can run
|
||||
lifecycle.mark_processor_completed("asr", Some(10));
|
||||
assert!(lifecycle.can_run_processor("asrx"));
|
||||
@@ -695,7 +733,7 @@ mod tests {
|
||||
fn test_overall_progress() {
|
||||
let mut lifecycle = FileLifecycle::new("test");
|
||||
assert_eq!(lifecycle.overall_progress(), 0.0);
|
||||
|
||||
|
||||
lifecycle.mark_stage_completed("registration");
|
||||
let progress = lifecycle.overall_progress();
|
||||
assert!(progress > 0.0 && progress < 100.0);
|
||||
|
||||
Reference in New Issue
Block a user