feat: declarative pipeline config, non-blocking Scene VLM, rust_asrx
Consolidated snapshot (previously WIP in working tree). - core/pipeline_config: new module loading config/pipeline_flows.json as the source of truth for stage execution mode (parallel/blocking) and dependencies - worker/job_worker: dispatch Scene VLM to a background task when the stage is declared parallel, unblocking the worker poll loop; resolve processor dependencies from pipeline_flows.json (fallback to built-in) - config/pipeline_flows.json: asrx depends on [cut, asr] - scripts/fix_stuck_jobs: fix UTC timezone comparison, raise default threshold to 6h, skip jobs with recent processor activity - rust_asrx: Rust speaker diarization CLI + processor wiring - processor metadata helper; fast_face_clustering script; file_progress pipeline API; scan API; VAD updates
This commit is contained in:
@@ -0,0 +1,173 @@
|
||||
# Pipeline Configuration
|
||||
|
||||
**File**: `config/pipeline_flows.json`
|
||||
|
||||
---
|
||||
|
||||
## 📋 Purpose
|
||||
|
||||
This configuration file defines the processing pipeline for video analysis tasks. It controls:
|
||||
|
||||
- Which processors run and in what order
|
||||
- Tool selection and parameters
|
||||
- Execution conditions and dependencies
|
||||
- Failure handling and timeouts
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Quick Start
|
||||
|
||||
### View Current Configuration
|
||||
|
||||
```bash
|
||||
# View pipeline configuration
|
||||
cat config/pipeline_flows.json | jq
|
||||
|
||||
# Check specific flow
|
||||
jq '.flows.register' config/pipeline_flows.json
|
||||
```
|
||||
|
||||
### Modify Configuration
|
||||
|
||||
1. Edit `config/pipeline_flows.json`
|
||||
2. Validate JSON syntax: `jq . config/pipeline_flows.json`
|
||||
3. Restart worker: `launchctl restart gui/$(id -u)/com.momentry.worker`
|
||||
|
||||
---
|
||||
|
||||
## 📊 Configuration Structure
|
||||
|
||||
```
|
||||
pipeline_flows.json
|
||||
├── version # Schema version
|
||||
├── enabled # Global enable/disable
|
||||
├── max_concurrent_stages # Concurrency limit
|
||||
├── default_timeout_secs # Default timeout
|
||||
└── flows # Pipeline definitions
|
||||
├── register # Full registration pipeline
|
||||
├── reprocess # Selective reprocessing
|
||||
└── phase1_pack # Packaging pipeline
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Available Flows
|
||||
|
||||
### register
|
||||
|
||||
**Purpose**: Complete video processing pipeline
|
||||
|
||||
**Stages**: cut → asr → face → ocr → scene → asrx
|
||||
|
||||
**Usage**: Automatically triggered during video registration
|
||||
|
||||
---
|
||||
|
||||
### reprocess
|
||||
|
||||
**Purpose**: Selective reprocessing of specific processors
|
||||
|
||||
**Usage**: Manually triggered via Admin Panel or API
|
||||
|
||||
---
|
||||
|
||||
### phase1_pack
|
||||
|
||||
**Purpose**: Package Phase 1 results
|
||||
|
||||
**Usage**: Triggered after register completes
|
||||
|
||||
---
|
||||
|
||||
## 🔀 Execution Mode: Parallel vs Blocking
|
||||
|
||||
Each stage's `parallel` flag is the **single source of truth** for how the worker
|
||||
executes that stage. The worker reads it at runtime (via
|
||||
`src/core/pipeline_config.rs`) instead of hardcoding the mode per processor.
|
||||
|
||||
| `parallel` | Meaning | Worker behavior |
|
||||
|------------|---------|-----------------|
|
||||
| `true` | Non-blocking | Stage is dispatched to the background (pool or `tokio::spawn`); the worker poll loop continues. |
|
||||
| `false` | Blocking | Stage runs inline; the caller waits for it to finish before continuing. |
|
||||
|
||||
Unknown / missing stages default to `true` (parallel), so a missing entry never
|
||||
reintroduces blocking.
|
||||
|
||||
**Scene VLM example**: the `scene` stage is declared `"parallel": true`, so Scene
|
||||
VLM (which can run for hours on a large file) is spawned as a background task
|
||||
instead of being awaited inline. A semaphore (1 concurrent) and an in-flight set
|
||||
guard against duplicate spawns across poll cycles. Setting `"parallel": false`
|
||||
would restore the previous inline/blocking behavior.
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ Tool Selection
|
||||
|
||||
### Priority System
|
||||
|
||||
- **0**: Highest priority (preferred tool)
|
||||
- **1-99**: Fallback tools
|
||||
|
||||
### Example
|
||||
|
||||
```json
|
||||
{
|
||||
"tools": [
|
||||
{
|
||||
"name": "swift_face",
|
||||
"priority": 0,
|
||||
"description": "ANE accelerated"
|
||||
},
|
||||
{
|
||||
"name": "python_insightface",
|
||||
"priority": 1,
|
||||
"description": "CPU fallback"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📚 Documentation
|
||||
|
||||
- **Full Guide**: `docs_v1.0/OPERATIONS/Pipeline_Configuration_Guide.md`
|
||||
- **Processor Reference**: `docs_v1.0/OPERATIONS/Processor_Commands_Reference.md`
|
||||
- **Tool Selector**: `docs_v1.0/DESIGN/Tool_Selector_V1.0.md`
|
||||
|
||||
---
|
||||
|
||||
## 🔍 Debugging
|
||||
|
||||
### Check Pipeline Status
|
||||
|
||||
```bash
|
||||
# View worker logs
|
||||
tail -f logs/worker_3002.log | grep -E "Pipeline|Stage"
|
||||
|
||||
# Check processor jobs
|
||||
psql -U accusys -d momentry -c "SELECT uuid, processor_type, status FROM processor_jobs ORDER BY created_at DESC LIMIT 10;"
|
||||
```
|
||||
|
||||
### Test Configuration
|
||||
|
||||
```bash
|
||||
# Validate JSON
|
||||
jq . config/pipeline_flows.json
|
||||
|
||||
# Check specific processor
|
||||
jq '.flows.register.stages[] | select(.name == "face")' config/pipeline_flows.json
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ⚠️ Important
|
||||
|
||||
1. **Always validate JSON** before saving
|
||||
2. **Restart worker** after configuration changes
|
||||
3. **Backup configuration** before major changes
|
||||
4. **Test changes** in development environment first
|
||||
|
||||
---
|
||||
|
||||
**Last Updated**: 2026-10-14
|
||||
@@ -0,0 +1,340 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"updated_at": "2026-10-14T19:00:00Z",
|
||||
"updated_by": "core_team",
|
||||
"enabled": true,
|
||||
"max_concurrent_stages": 3,
|
||||
"default_timeout_secs": 3600,
|
||||
"phases": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "基础分析",
|
||||
"name_en": "Foundation",
|
||||
"description": "场景切分与分析",
|
||||
"progress_weight": 0.15,
|
||||
"color": "#4CAF50",
|
||||
"icon": "foundation",
|
||||
"parallel_strategy": "sequential",
|
||||
"processors": ["cut"]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "核心处理",
|
||||
"name_en": "Core Processing",
|
||||
"description": "语音识别、人脸检测、文字识别",
|
||||
"progress_weight": 0.60,
|
||||
"color": "#2196F3",
|
||||
"icon": "processing",
|
||||
"parallel_strategy": "limited_parallel",
|
||||
"max_concurrent": 3,
|
||||
"processors": ["asr", "face", "ocr"]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "深度分析",
|
||||
"name_en": "Deep Analysis",
|
||||
"description": "说话人识别、场景描述、人脸聚类",
|
||||
"progress_weight": 0.20,
|
||||
"color": "#9C27B0",
|
||||
"icon": "analysis",
|
||||
"parallel_strategy": "limited_parallel",
|
||||
"max_concurrent": 3,
|
||||
"processors": ["asrx", "scene", "face_cluster"]
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"name": "知识构建",
|
||||
"name_en": "Knowledge Building",
|
||||
"description": "时序知识图谱构建",
|
||||
"progress_weight": 0.05,
|
||||
"color": "#FF9800",
|
||||
"icon": "knowledge",
|
||||
"parallel_strategy": "sequential",
|
||||
"processors": ["tkg"]
|
||||
}
|
||||
],
|
||||
"flows": {
|
||||
"register": {
|
||||
"name": "Video Registration Pipeline",
|
||||
"description": "Complete video processing pipeline for new video files",
|
||||
"version": "2.0.0",
|
||||
"enabled": true,
|
||||
"stages": [
|
||||
{
|
||||
"name": "cut",
|
||||
"processor_type": "cut",
|
||||
"phase": 1,
|
||||
"phase_name": "基础分析",
|
||||
"phase_name_en": "Foundation",
|
||||
"progress_weight": 1.0,
|
||||
"display_name": "场景切分",
|
||||
"display_name_en": "Scene Cut Detection",
|
||||
"description": "Scene cut detection using ffmpeg or Python scenedetect",
|
||||
"required": true,
|
||||
"enabled": true,
|
||||
"timeout_secs": 3600,
|
||||
"parallel": false,
|
||||
"estimated_time_secs": 5,
|
||||
"resource_type": "cpu",
|
||||
"dependencies": [],
|
||||
"tool": {
|
||||
"name": "rust_cut",
|
||||
"priority": 0,
|
||||
"description": "High-performance Rust-based scene detection",
|
||||
"parameters": {
|
||||
"min_scene_duration": 0.5,
|
||||
"threshold": 0.3
|
||||
},
|
||||
"usage_notes": "Uses ffmpeg for native detection. Falls back to Python scenedetect if unavailable."
|
||||
},
|
||||
"condition": {
|
||||
"skip_if_exists": "*.cut.json"
|
||||
},
|
||||
"on_failure": "continue"
|
||||
},
|
||||
{
|
||||
"name": "asr",
|
||||
"processor_type": "asr",
|
||||
"phase": 2,
|
||||
"phase_name": "核心处理",
|
||||
"phase_name_en": "Core Processing",
|
||||
"progress_weight": 0.35,
|
||||
"display_name": "语音识别",
|
||||
"display_name_en": "Speech Recognition",
|
||||
"description": "Automatic Speech Recognition using Whisper",
|
||||
"required": false,
|
||||
"enabled": true,
|
||||
"timeout_secs": 3600,
|
||||
"parallel": true,
|
||||
"estimated_time_secs": 20,
|
||||
"resource_type": "gpu",
|
||||
"dependencies": [],
|
||||
"tool": {
|
||||
"name": "whisper_mlx",
|
||||
"priority": 0,
|
||||
"description": "MLX-accelerated Whisper for Apple Silicon",
|
||||
"parameters": {
|
||||
"model": "small",
|
||||
"language": "auto"
|
||||
},
|
||||
"usage_notes": "Optimized for Apple Silicon. Falls back to whisper.cpp if unavailable."
|
||||
},
|
||||
"condition": {
|
||||
"skip_if_exists": "*.asr.json"
|
||||
},
|
||||
"on_failure": "continue"
|
||||
},
|
||||
{
|
||||
"name": "face",
|
||||
"processor_type": "face",
|
||||
"phase": 2,
|
||||
"phase_name": "核心处理",
|
||||
"phase_name_en": "Core Processing",
|
||||
"progress_weight": 0.35,
|
||||
"display_name": "人脸检测",
|
||||
"display_name_en": "Face Detection",
|
||||
"description": "Face detection and tracking",
|
||||
"required": false,
|
||||
"enabled": true,
|
||||
"timeout_secs": 7200,
|
||||
"parallel": true,
|
||||
"estimated_time_secs": 15,
|
||||
"resource_type": "ane",
|
||||
"dependencies": [],
|
||||
"tool": {
|
||||
"name": "swift_face",
|
||||
"priority": 0,
|
||||
"description": "Apple Vision framework face detection (ANE accelerated)",
|
||||
"parameters": {
|
||||
"min_confidence": 0.5,
|
||||
"min_size": 1
|
||||
},
|
||||
"usage_notes": "Uses Apple Neural Engine for acceleration. Falls back to Python InsightFace if unavailable."
|
||||
},
|
||||
"condition": {
|
||||
"skip_if_exists": "*.face.json"
|
||||
},
|
||||
"on_failure": "continue"
|
||||
},
|
||||
{
|
||||
"name": "ocr",
|
||||
"processor_type": "ocr",
|
||||
"phase": 2,
|
||||
"phase_name": "核心处理",
|
||||
"phase_name_en": "Core Processing",
|
||||
"progress_weight": 0.30,
|
||||
"display_name": "文字识别",
|
||||
"display_name_en": "OCR",
|
||||
"description": "OCR text extraction using Apple Vision Framework",
|
||||
"required": false,
|
||||
"enabled": true,
|
||||
"timeout_secs": 7200,
|
||||
"parallel": true,
|
||||
"estimated_time_secs": 10,
|
||||
"resource_type": "ane",
|
||||
"dependencies": [],
|
||||
"tool": {
|
||||
"name": "swift_ocr",
|
||||
"priority": 0,
|
||||
"description": "Apple Vision VNRecognizeTextRequest (ANE accelerated)",
|
||||
"parameters": {
|
||||
"recognition_level": "accurate",
|
||||
"uses_language_correction": true
|
||||
},
|
||||
"usage_notes": "Uses Apple Neural Engine for acceleration. Supports multiple languages with real-time recognition. 2.5x faster than Python (2s vs 5s)."
|
||||
},
|
||||
"condition": {
|
||||
"skip_if_exists": "*.ocr.json"
|
||||
},
|
||||
"on_failure": "continue"
|
||||
},
|
||||
{
|
||||
"name": "asrx",
|
||||
"processor_type": "asrx",
|
||||
"phase": 3,
|
||||
"phase_name": "深度分析",
|
||||
"phase_name_en": "Deep Analysis",
|
||||
"progress_weight": 0.40,
|
||||
"display_name": "说话人识别",
|
||||
"display_name_en": "Speaker Diarization",
|
||||
"description": "Speaker diarization using Swift (Apple Vision + ANE)",
|
||||
"required": false,
|
||||
"enabled": true,
|
||||
"timeout_secs": 1800,
|
||||
"parallel": true,
|
||||
"estimated_time_secs": 15,
|
||||
"resource_type": "ane",
|
||||
"dependencies": ["cut", "asr"],
|
||||
"tool": {
|
||||
"name": "swift_asrx",
|
||||
"priority": 0,
|
||||
"description": "Apple Vision speaker diarization (ANE accelerated)",
|
||||
"parameters": {},
|
||||
"usage_notes": "Uses Apple Neural Engine for acceleration. Falls back to Python pyannote if unavailable."
|
||||
},
|
||||
"condition": {
|
||||
"depends_on": ["cut", "asr"],
|
||||
"skip_if_exists": "*.asrx.json"
|
||||
},
|
||||
"on_failure": "continue"
|
||||
},
|
||||
{
|
||||
"name": "scene",
|
||||
"processor_type": "scene",
|
||||
"phase": 3,
|
||||
"phase_name": "深度分析",
|
||||
"phase_name_en": "Deep Analysis",
|
||||
"progress_weight": 0.35,
|
||||
"display_name": "场景描述",
|
||||
"display_name_en": "Scene Description",
|
||||
"description": "Scene VLM analysis for scene descriptions",
|
||||
"required": false,
|
||||
"enabled": true,
|
||||
"timeout_secs": 7200,
|
||||
"parallel": true,
|
||||
"estimated_time_secs": 10,
|
||||
"resource_type": "gpu",
|
||||
"dependencies": ["cut"],
|
||||
"tool": {
|
||||
"name": "gemma_vlm",
|
||||
"priority": 0,
|
||||
"description": "Gemma 4 12B with mmproj for vision-language analysis",
|
||||
"parameters": {
|
||||
"max_tokens": 900,
|
||||
"temperature": 0.1
|
||||
},
|
||||
"usage_notes": "Generates scene descriptions in multiple languages. Requires mmproj loaded."
|
||||
},
|
||||
"condition": {
|
||||
"depends_on": "cut",
|
||||
"skip_if_exists": "*.scenes.json"
|
||||
},
|
||||
"on_failure": "continue"
|
||||
},
|
||||
{
|
||||
"name": "face_cluster",
|
||||
"processor_type": "face_cluster",
|
||||
"phase": 3,
|
||||
"phase_name": "深度分析",
|
||||
"phase_name_en": "Deep Analysis",
|
||||
"progress_weight": 0.25,
|
||||
"display_name": "人脸聚类",
|
||||
"display_name_en": "Face Clustering",
|
||||
"description": "Face clustering and grouping",
|
||||
"required": false,
|
||||
"enabled": true,
|
||||
"timeout_secs": 3600,
|
||||
"parallel": true,
|
||||
"estimated_time_secs": 5,
|
||||
"resource_type": "cpu",
|
||||
"dependencies": ["face"],
|
||||
"condition": {
|
||||
"depends_on": "face",
|
||||
"skip_if_exists": "*.face_cluster.json"
|
||||
},
|
||||
"on_failure": "continue"
|
||||
},
|
||||
{
|
||||
"name": "tkg",
|
||||
"processor_type": "tkg",
|
||||
"phase": 4,
|
||||
"phase_name": "知识构建",
|
||||
"phase_name_en": "Knowledge Building",
|
||||
"progress_weight": 1.0,
|
||||
"display_name": "知识图谱",
|
||||
"display_name_en": "Knowledge Graph",
|
||||
"description": "Temporal knowledge graph construction",
|
||||
"required": false,
|
||||
"enabled": true,
|
||||
"timeout_secs": 3600,
|
||||
"parallel": false,
|
||||
"estimated_time_secs": 5,
|
||||
"resource_type": "cpu",
|
||||
"dependencies": ["asrx", "face_cluster"],
|
||||
"condition": {
|
||||
"depends_on": ["asrx", "face_cluster"],
|
||||
"skip_if_exists": "*.tkg.json"
|
||||
},
|
||||
"on_failure": "continue"
|
||||
}
|
||||
]
|
||||
},
|
||||
"reprocess": {
|
||||
"name": "Reprocessing Pipeline",
|
||||
"description": "Selective reprocessing of specific processors",
|
||||
"version": "2.0.0",
|
||||
"enabled": true,
|
||||
"stages": []
|
||||
},
|
||||
"phase1_pack": {
|
||||
"name": "Phase 1 Packaging Pipeline",
|
||||
"description": "Package Phase 1 results for delivery",
|
||||
"version": "2.0.0",
|
||||
"enabled": true,
|
||||
"stages": [
|
||||
{
|
||||
"name": "pack",
|
||||
"processor_type": "pack",
|
||||
"phase": 4,
|
||||
"phase_name": "知识构建",
|
||||
"phase_name_en": "Knowledge Building",
|
||||
"progress_weight": 1.0,
|
||||
"display_name": "打包",
|
||||
"display_name_en": "Pack",
|
||||
"description": "Create release package with all Phase 1 outputs",
|
||||
"required": true,
|
||||
"enabled": true,
|
||||
"timeout_secs": 600,
|
||||
"parallel": false,
|
||||
"estimated_time_secs": 10,
|
||||
"resource_type": "cpu",
|
||||
"dependencies": [],
|
||||
"parameters": {
|
||||
"phase": 1,
|
||||
"include_metadata": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -198,15 +198,32 @@
|
||||
"asrx": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "swift",
|
||||
"tool": "rust",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "tools/cli/rust/target/release/rust_asrx",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.asrx.json",
|
||||
"timeout": 1800
|
||||
},
|
||||
{
|
||||
"tool": "swift",
|
||||
"model": null,
|
||||
"priority": 1,
|
||||
"enabled": false,
|
||||
"command": {
|
||||
"executable": "scripts/swift_processors/.build/release/asrx_swift",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"--output",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
@@ -219,7 +236,7 @@
|
||||
{
|
||||
"tool": "python",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"priority": 2,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
@@ -237,7 +254,7 @@
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "swift",
|
||||
"tool": "rust",
|
||||
"model": null
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user