update: pipeline, search, clip, embedding fixes

This commit is contained in:
Accusys
2026-05-17 19:46:35 +08:00
parent eec2eea880
commit 3164a65554
36 changed files with 4313 additions and 4061 deletions

View File

@@ -84,9 +84,9 @@ fn load_checksums(scripts_dir: &PathBuf) -> HashMap<String, String> {
pub fn validate_python_env() -> Result<()> {
let python_path = std::env::var("MOMENTRY_PYTHON_PATH")
.unwrap_or_else(|_| "/opt/homebrew/bin/python3.11".to_string());
let venv_python = PathBuf::from(&python_path);
let python_bin = PathBuf::from(&python_path);
if !venv_python.exists() {
if !python_bin.exists() {
anyhow::bail!(
"Python not found at {} (set MOMENTRY_PYTHON_PATH env var)",
python_path
@@ -95,7 +95,7 @@ pub fn validate_python_env() -> Result<()> {
let rt = tokio::runtime::Runtime::new()?;
let output = rt
.block_on(async { Command::new(&venv_python).arg("--version").output().await })
.block_on(async { Command::new(&python_bin).arg("--version").output().await })
.context("Failed to run Python")?;
if !output.status.success() {
@@ -124,7 +124,7 @@ pub fn validate_python_env() -> Result<()> {
}
pub struct PythonExecutor {
venv_python: PathBuf,
python_path: PathBuf,
scripts_dir: PathBuf,
checksums: HashMap<String, String>,
}
@@ -139,10 +139,10 @@ impl PythonExecutor {
manifest.join("scripts").to_string_lossy().to_string()
});
let venv_python = PathBuf::from(&python_path);
let python_bin = PathBuf::from(&python_path);
let scripts_path = PathBuf::from(&scripts_dir);
if !venv_python.exists() {
if !python_bin.exists() {
anyhow::bail!(
"Python not found at {} (set MOMENTRY_PYTHON_PATH env var)",
python_path
@@ -160,7 +160,7 @@ impl PythonExecutor {
let checksums = load_checksums(&scripts_path);
Ok(Self {
venv_python,
python_path: python_bin,
scripts_dir: scripts_path,
checksums,
})
@@ -201,7 +201,7 @@ impl PythonExecutor {
let rt = tokio::runtime::Runtime::new()?;
let output = rt
.block_on(async {
Command::new(&self.venv_python)
Command::new(&self.python_path)
.arg("--version")
.output()
.await
@@ -251,7 +251,7 @@ impl PythonExecutor {
}
}
let mut cmd = Command::new(&self.venv_python);
let mut cmd = Command::new(&self.python_path);
cmd.arg(&script_path);
for arg in args {
@@ -467,7 +467,7 @@ impl PythonExecutor {
}
pub fn python_path(&self) -> &PathBuf {
&self.venv_python
&self.python_path
}
}
@@ -482,11 +482,11 @@ mod tests {
use super::*;
#[test]
fn test_python_executor_new_with_venv() {
fn test_python_executor_new() {
let executor = PythonExecutor::new();
assert!(
executor.is_ok(),
"PythonExecutor should create successfully with venv"
"PythonExecutor should create successfully"
);
}
@@ -499,10 +499,6 @@ mod tests {
"Python path should exist: {:?}",
python_path
);
assert!(
python_path.to_string_lossy().contains("venv"),
"Should be in venv"
);
}
#[test]

View File

@@ -284,10 +284,21 @@ pub async fn process_visual_chunk_advanced(
});
}
let yolo_path = uuid.map(|u| {
std::path::PathBuf::from(crate::core::config::OUTPUT_DIR.as_str())
.join(format!("{}.yolo.json", u))
.to_string_lossy()
.to_string()
});
let args: &[&str] = if let Some(ref yp) = yolo_path {
&[video_path, output_path, "--yolo-result", yp]
} else {
&[video_path, output_path]
};
let result = match executor
.run(
"visual_chunk_processor.py",
&[video_path, output_path],
args,
uuid,
"VisualChunk",
Some(VISUAL_CHUNK_TIMEOUT),