phase 3
This commit is contained in:
@@ -1,17 +1,20 @@
|
||||
"""
|
||||
ContentTypeProfile protocol and config dataclasses.
|
||||
|
||||
The pipeline graph is fixed — what varies per content type is configuration
|
||||
and hooks. Each profile provides stage configs, a brand dictionary,
|
||||
VLM prompt templates, and an aggregation strategy.
|
||||
Each profile defines the pipeline topology (as a JSONB blob), stage configs,
|
||||
brand dictionary, VLM prompt templates, and aggregation strategy.
|
||||
|
||||
When profiles are persisted, the pipeline field is a JSONB column.
|
||||
For now, profiles are code-only and pipeline_config() returns a hardcoded value.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Protocol
|
||||
from typing import Any, Dict, Protocol
|
||||
|
||||
from detect.models import BrandDetection, DetectionReport
|
||||
from core.schema.models.pipeline_config import PipelineConfig, StageRef, Edge
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -64,9 +67,24 @@ class CropContext:
|
||||
position_hint: str = ""
|
||||
|
||||
|
||||
def pipeline_config_from_dict(data: Dict[str, Any]) -> PipelineConfig:
|
||||
"""Deserialize a PipelineConfig from a JSONB dict."""
|
||||
stages = [StageRef(**s) for s in data.get("stages", [])]
|
||||
edges = [Edge(**e) for e in data.get("edges", [])]
|
||||
return PipelineConfig(
|
||||
name=data.get("name", ""),
|
||||
profile_name=data.get("profile_name", ""),
|
||||
stages=stages,
|
||||
edges=edges,
|
||||
routing_rules=data.get("routing_rules", {}),
|
||||
)
|
||||
|
||||
|
||||
class ContentTypeProfile(Protocol):
|
||||
name: str
|
||||
pipeline: Dict[str, Any] # JSONB blob — PipelineConfig shape
|
||||
|
||||
def pipeline_config(self) -> PipelineConfig: ...
|
||||
def frame_extraction_config(self) -> FrameExtractionConfig: ...
|
||||
def scene_filter_config(self) -> SceneFilterConfig: ...
|
||||
def region_analysis_config(self) -> RegionAnalysisConfig: ...
|
||||
|
||||
Reference in New Issue
Block a user