fix: worker reads face_settings from job and sets env vars for face processor
- job_worker.rs: Read face_settings from monitor_jobs before processing - job_worker.rs: Set FACE_MIN_CONFIDENCE and FACE_MIN_SIZE env vars - job_worker.rs: Restore env vars after processing completes - Add detailed logging: [WORKER] face_settings and env var changes This ensures the executor receives the correct face settings from the job.
This commit is contained in:
@@ -461,6 +461,37 @@ impl JobWorker {
|
|||||||
|
|
||||||
info!("Processing job: {} ({})", job.uuid, job.id);
|
info!("Processing job: {} ({})", job.uuid, job.id);
|
||||||
|
|
||||||
|
// Read face_settings from job and set environment variables for face processor
|
||||||
|
let mut face_settings_backup: Option<(String, String)> = None;
|
||||||
|
if let Some(ref fs) = job.face_settings {
|
||||||
|
let min_confidence = fs.get("min_confidence").and_then(|v| v.as_f64()).unwrap_or(0.75);
|
||||||
|
let min_size = fs.get("min_size").and_then(|v| v.as_i64()).unwrap_or(64) as i32;
|
||||||
|
tracing::info!(
|
||||||
|
"[WORKER] Job {} face_settings: CONFIDENCE={}, SIZE={}",
|
||||||
|
job.uuid,
|
||||||
|
min_confidence,
|
||||||
|
min_size
|
||||||
|
);
|
||||||
|
|
||||||
|
// Backup current env vars
|
||||||
|
let current_conf = std::env::var("FACE_MIN_CONFIDENCE").ok();
|
||||||
|
let current_size = std::env::var("FACE_MIN_SIZE").ok();
|
||||||
|
face_settings_backup = Some((
|
||||||
|
current_conf.unwrap_or_default(),
|
||||||
|
current_size.unwrap_or_default(),
|
||||||
|
));
|
||||||
|
|
||||||
|
// Set env vars for face processor
|
||||||
|
std::env::set_var("FACE_MIN_CONFIDENCE", format!("{}", min_confidence));
|
||||||
|
std::env::set_var("FACE_MIN_SIZE", format!("{}", min_size));
|
||||||
|
tracing::info!(
|
||||||
|
"[WORKER] Set FACE_MIN_CONFIDENCE={}, FACE_MIN_SIZE={} for job {}",
|
||||||
|
min_confidence,
|
||||||
|
min_size,
|
||||||
|
job.uuid
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Determine which processors to run based on job.processors field
|
// Determine which processors to run based on job.processors field
|
||||||
let mut processors_to_run: Vec<crate::core::db::ProcessorType> =
|
let mut processors_to_run: Vec<crate::core::db::ProcessorType> =
|
||||||
if job.processors.is_empty() {
|
if job.processors.is_empty() {
|
||||||
@@ -1532,6 +1563,26 @@ impl JobWorker {
|
|||||||
self.check_and_complete_job(job.id, &job.uuid, &job.processors, expected_count)
|
self.check_and_complete_job(job.id, &job.uuid, &job.processors, expected_count)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
// Restore environment variables after processing
|
||||||
|
if let Some((conf_backup, size_backup)) = face_settings_backup {
|
||||||
|
if conf_backup.is_empty() {
|
||||||
|
std::env::remove_var("FACE_MIN_CONFIDENCE");
|
||||||
|
} else {
|
||||||
|
std::env::set_var("FACE_MIN_CONFIDENCE", &conf_backup);
|
||||||
|
}
|
||||||
|
if size_backup.is_empty() {
|
||||||
|
std::env::remove_var("FACE_MIN_SIZE");
|
||||||
|
} else {
|
||||||
|
std::env::set_var("FACE_MIN_SIZE", &size_backup);
|
||||||
|
}
|
||||||
|
tracing::info!(
|
||||||
|
"[WORKER] Restored FACE_MIN_CONFIDENCE={:?}, FACE_MIN_SIZE={:?} after job {}",
|
||||||
|
if conf_backup.is_empty() { None } else { Some(&conf_backup) },
|
||||||
|
if size_backup.is_empty() { None } else { Some(&size_backup) },
|
||||||
|
job.uuid
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user