feat: implement CLI handle_process() for UUID-based processing
- Connect to database and get video info - Call process_face() for face module - Add UUID length fix (16 -> 32) - Add progress and trace statistics output - Support force reprocess flag Note: CLI may need further debugging to fully work
This commit is contained in:
+86
-10
@@ -32,6 +32,7 @@ pub async fn handle_process(
|
||||
force: bool,
|
||||
resume: bool,
|
||||
) -> Result<()> {
|
||||
println!("=== handle_process called ===");
|
||||
println!("Processing target: {}", target);
|
||||
println!("Modules: {:?}", modules);
|
||||
println!("Cloud processing: {}", cloud);
|
||||
@@ -39,25 +40,100 @@ pub async fn handle_process(
|
||||
println!("Resume: {}", resume);
|
||||
|
||||
// Determine if target is a UUID or a path
|
||||
let is_uuid = target.len() == 16 && target.chars().all(|c| c.is_ascii_hexdigit());
|
||||
let is_uuid = target.len() == 32 && target.chars().all(|c| c.is_ascii_hexdigit());
|
||||
|
||||
if is_uuid {
|
||||
println!("Target is a UUID, would process video: {}", target);
|
||||
// TODO: Implement UUID-based processing
|
||||
// UUID-based processing
|
||||
println!("\n[PROCESS] Processing video with UUID: {}", target);
|
||||
|
||||
// Connect to database
|
||||
let database_url = std::env::var("DATABASE_URL")
|
||||
.unwrap_or_else(|_| "postgres://accusys@localhost:5432/momentry".to_string());
|
||||
|
||||
let db = momentry_core::core::db::PostgresDb::new(&database_url).await?;
|
||||
|
||||
// Get video info
|
||||
let video = db.get_video_by_uuid(target).await?
|
||||
.ok_or_else(|| anyhow::anyhow!("Video not found: {}", target))?;
|
||||
let file_path = video.file_path.clone();
|
||||
let output_dir = std::env::var("MOMENTRY_OUTPUT_DIR")
|
||||
.unwrap_or_else(|_| "/Users/accusys/momentry/output".to_string());
|
||||
|
||||
println!("[PROCESS] Video path: {}", file_path);
|
||||
|
||||
// Process modules
|
||||
let modules_to_process = modules.unwrap_or_else(|| vec!["face".to_string()]);
|
||||
|
||||
for module in &modules_to_process {
|
||||
match module.as_str() {
|
||||
"face" => {
|
||||
let output_path = format!("{}/{}.face.json", output_dir, target);
|
||||
|
||||
// Check if already exists
|
||||
if !force && std::path::Path::new(&output_path).exists() {
|
||||
println!("[FACE] Output already exists, use --force to reprocess");
|
||||
continue;
|
||||
}
|
||||
|
||||
println!("[FACE] Starting face processing...");
|
||||
|
||||
use momentry_core::core::processor::face::process_face;
|
||||
let result = process_face(&file_path, &output_path, Some(target), None).await?;
|
||||
|
||||
println!("[FACE] Completed: {} frames, {} faces",
|
||||
result.frames.len(),
|
||||
result.total_faces
|
||||
);
|
||||
|
||||
// Show trace statistics
|
||||
let with_trace = result.frames.iter()
|
||||
.flat_map(|f| &f.faces)
|
||||
.filter(|face| face.trace_id.is_some())
|
||||
.count();
|
||||
println!("[FACE] Faces with trace_id: {}/{}", with_trace, result.total_faces);
|
||||
}
|
||||
"asr" => {
|
||||
println!("[ASR] ASR processing not yet implemented in CLI");
|
||||
}
|
||||
"ocr" => {
|
||||
println!("[OCR] OCR processing not yet implemented in CLI");
|
||||
}
|
||||
_ => {
|
||||
println!("[WARN] Unknown module: {}", module);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
println!("\n✅ Processing completed for UUID: {}", target);
|
||||
} else {
|
||||
// Path-based processing
|
||||
let path = Path::new(target);
|
||||
if !path.exists() {
|
||||
anyhow::bail!("Path does not exist: {}", target);
|
||||
}
|
||||
|
||||
// For now, just show decision
|
||||
if force {
|
||||
println!("Force reprocessing: {}", target);
|
||||
} else if resume {
|
||||
println!("Resume processing: {}", target);
|
||||
} else {
|
||||
println!("Normal processing: {}", target);
|
||||
println!("\n[PROCESS] Processing file: {}", target);
|
||||
|
||||
// For now, just process face module
|
||||
if modules.as_ref().map(|m| m.contains(&"face".to_string())).unwrap_or(true) {
|
||||
let output_path = format!("{}.face.json", target);
|
||||
|
||||
if !force && std::path::Path::new(&output_path).exists() {
|
||||
println!("[FACE] Output already exists, use --force to reprocess");
|
||||
} else {
|
||||
println!("[FACE] Starting face processing...");
|
||||
|
||||
use momentry_core::core::processor::face::process_face;
|
||||
let result = process_face(target, &output_path, None, None).await?;
|
||||
|
||||
println!("[FACE] Completed: {} frames, {} faces",
|
||||
result.frames.len(),
|
||||
result.total_faces
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
println!("\n✅ Processing completed for path: {}", target);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user