refactor: remove legacy demo code, integrate metrics via pipeline context
- Remove ~700 lines of legacy code from app.py (run_demo_mode, run_pipeline_demo, run_preset_mode, font picker, effects picker) - HUD now reads metrics from pipeline context (first-class citizen) with fallback to global monitor for backwards compatibility - Add validate_signal_flow() for PureData-style type validation in presets - Update MicSensor documentation (self-contained, doesn't use MicMonitor) - Delete test_app.py (was testing removed legacy code) - Update AGENTS.md with pipeline architecture documentation
This commit is contained in:
1008
engine/app.py
1008
engine/app.py
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@ Gracefully degrades if sounddevice/numpy are unavailable.
|
||||
|
||||
.. deprecated::
|
||||
For pipeline integration, use :class:`engine.sensors.mic.MicSensor` instead.
|
||||
MicMonitor is still used as the backend for MicSensor.
|
||||
MicSensor is a self-contained implementation and does not use MicMonitor.
|
||||
"""
|
||||
|
||||
import atexit
|
||||
|
||||
@@ -152,6 +152,64 @@ def validate_preset(preset: dict[str, Any]) -> list[str]:
|
||||
return errors
|
||||
|
||||
|
||||
def validate_signal_flow(stages: list[dict]) -> list[str]:
|
||||
"""Validate signal flow based on inlet/outlet types.
|
||||
|
||||
This validates that the preset's stage configuration produces valid
|
||||
data flow using the PureData-style type system.
|
||||
|
||||
Args:
|
||||
stages: List of stage configs with 'name', 'category', 'inlet_types', 'outlet_types'
|
||||
|
||||
Returns:
|
||||
List of errors (empty if valid)
|
||||
"""
|
||||
errors: list[str] = []
|
||||
|
||||
if not stages:
|
||||
errors.append("Signal flow is empty")
|
||||
return errors
|
||||
|
||||
# Define expected types for each category
|
||||
type_map = {
|
||||
"source": {"inlet": "NONE", "outlet": "SOURCE_ITEMS"},
|
||||
"data": {"inlet": "ANY", "outlet": "SOURCE_ITEMS"},
|
||||
"transform": {"inlet": "SOURCE_ITEMS", "outlet": "TEXT_BUFFER"},
|
||||
"effect": {"inlet": "TEXT_BUFFER", "outlet": "TEXT_BUFFER"},
|
||||
"overlay": {"inlet": "TEXT_BUFFER", "outlet": "TEXT_BUFFER"},
|
||||
"camera": {"inlet": "TEXT_BUFFER", "outlet": "TEXT_BUFFER"},
|
||||
"display": {"inlet": "TEXT_BUFFER", "outlet": "NONE"},
|
||||
"render": {"inlet": "SOURCE_ITEMS", "outlet": "TEXT_BUFFER"},
|
||||
}
|
||||
|
||||
# Check stage order and type compatibility
|
||||
for i, stage in enumerate(stages):
|
||||
category = stage.get("category", "unknown")
|
||||
name = stage.get("name", f"stage_{i}")
|
||||
|
||||
if category not in type_map:
|
||||
continue # Skip unknown categories
|
||||
|
||||
expected = type_map[category]
|
||||
|
||||
# Check against previous stage
|
||||
if i > 0:
|
||||
prev = stages[i - 1]
|
||||
prev_category = prev.get("category", "unknown")
|
||||
if prev_category in type_map:
|
||||
prev_outlet = type_map[prev_category]["outlet"]
|
||||
inlet = expected["inlet"]
|
||||
|
||||
# Validate type compatibility
|
||||
if inlet != "ANY" and prev_outlet != "ANY" and inlet != prev_outlet:
|
||||
errors.append(
|
||||
f"Type mismatch at '{name}': "
|
||||
f"expects {inlet} but previous stage outputs {prev_outlet}"
|
||||
)
|
||||
|
||||
return errors
|
||||
|
||||
|
||||
def validate_signal_path(stages: list[str]) -> list[str]:
|
||||
"""Validate signal path for circular dependencies and connectivity.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user