feat: add ProcessorConfigV3 module for CLI-first configuration
新增:
- processor_config_v3.rs: V3 配置解析模組
- 支持動態讀取 processor_tools_v3.json
- 支持變量替換 ({video_path}, {file_uuid}, etc.)
結構:
- ProcessorConfigV3: 主配置
- Implementation: 實現配置 (tool, model, priority)
- CommandConfig: 命令配置 (executable, args)
- ProcessorConfigManager: 配置管理器
功能:
- load(): 加載配置文件
- get_processor(): 獲取處理器配置
- get_implementation(): 獲取特定實現
- resolve_command(): 解析命令路徑和參數
配置驗證:
- ✅ 9 processors 配置
- ✅ 6 CLI-first (priority 0, enabled)
- ✅ Rust CLI: 3 (pose, face_trace, cut)
- ✅ Swift CLI: 3 (face, asrx, ocr)
待實現:
- 集成到 ToolSelector
- 更新 Worker 使用 V3 配置
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
use momentry_core::core::processor::processor_config_v3::ProcessorConfigManager;
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_load_config() {
|
||||
let manager = ProcessorConfigManager::load().await;
|
||||
assert!(manager.is_ok(), "Failed to load config");
|
||||
|
||||
let manager = manager.unwrap();
|
||||
let processors = manager.get_all_processors();
|
||||
|
||||
assert!(!processors.is_empty(), "No processors found");
|
||||
println!("Processors: {:?}", processors);
|
||||
|
||||
// Test POSE processor
|
||||
let pose_impls = manager.get_implementations_by_priority("pose");
|
||||
assert!(!pose_impls.is_empty(), "No POSE implementations");
|
||||
|
||||
let first_impl = &pose_impls[0];
|
||||
assert_eq!(first_impl.tool, "rust", "First POSE implementation should be Rust");
|
||||
assert_eq!(first_impl.priority, 0);
|
||||
assert!(first_impl.enabled);
|
||||
|
||||
println!("POSE implementations: {:#?}", pose_impls);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_resolve_command() {
|
||||
let manager = ProcessorConfigManager::load().await.unwrap();
|
||||
|
||||
let mut variables = std::collections::HashMap::new();
|
||||
variables.insert("video_path".to_string(), "/path/to/video.mp4".to_string());
|
||||
variables.insert("output_path".to_string(), "/path/to/output.json".to_string());
|
||||
variables.insert("file_uuid".to_string(), "test-uuid".to_string());
|
||||
|
||||
// Test Rust POSE
|
||||
let result = manager.resolve_command("pose", "rust", &variables);
|
||||
assert!(result.is_ok(), "Failed to resolve command");
|
||||
|
||||
if let Ok(Some((executable, args))) = result {
|
||||
println!("Executable: {:?}", executable);
|
||||
println!("Args: {:?}", args);
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_get_default() {
|
||||
let manager = ProcessorConfigManager::load().await.unwrap();
|
||||
|
||||
let default = manager.get_default_implementation("pose");
|
||||
assert!(default.is_some(), "No default implementation for POSE");
|
||||
|
||||
let default = default.unwrap();
|
||||
println!("Default POSE implementation: {:?}", default.tool);
|
||||
}
|
||||
Reference in New Issue
Block a user