classpulse-edge / core /orchestrator.py
thegoatcc's picture
Upload ClassPulse Edge codebase, Dockerfile, and model weights
af70f62 verified
Raw History Blame Contribute Delete
1.29 kB
from __future__ import annotations
import logging
from core.base_module import PipelineModule
from core.config_manager import ConfigManager
from core.state import FrameContext
logger = logging.getLogger("classpulse.orchestrator")
class PipelineOrchestrator:
"""Executes registered Lego modules sequentially over a shared FrameContext."""
def __init__(self, config: ConfigManager, modules: list[PipelineModule]) -> None:
self.config = config
self.modules = modules
def startup(self) -> None:
for mod in self.modules:
logger.info("Initializing module: %s (branch=%s)", mod.name, mod.branch or "core")
mod.initialize()
def process_frame(self, context: FrameContext) -> FrameContext:
for mod in self.modules:
try:
context = mod.execute(context)
except Exception as exc:
logger.exception("Module '%s' failed on frame %d: %s", mod.name, context.frame_index, exc)
return context
def shutdown(self) -> None:
for mod in reversed(self.modules):
try:
mod.shutdown()
except Exception as exc:
logger.warning("Error shutting down module '%s': %s", mod.name, exc)