phase 4
This commit is contained in:
@@ -5,7 +5,7 @@ import json
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from detect.models import BoundingBox, BrandDetection, Frame, PipelineStats, TextCandidate
|
||||
from core.detect.models import BoundingBox, BrandDetection, Frame, PipelineStats, TextCandidate
|
||||
from core.schema.serializers._common import safe_construct
|
||||
from core.schema.serializers.pipeline import (
|
||||
serialize_frame_meta,
|
||||
@@ -163,34 +163,39 @@ def test_all_serialized_is_json_compatible():
|
||||
assert roundtrip["frame_meta"]["sequence"] == frame.sequence
|
||||
|
||||
|
||||
# --- OverrideProfile ---
|
||||
# --- Config overrides (dict merging, replaces OverrideProfile) ---
|
||||
|
||||
def test_override_profile_region_analysis():
|
||||
"""OverrideProfile must patch region_analysis_config with overrides."""
|
||||
from detect.checkpoint.replay import OverrideProfile
|
||||
from detect.profiles.soccer import SoccerBroadcastProfile
|
||||
from detect.profiles.base import RegionAnalysisConfig
|
||||
def test_config_override_region_analysis():
|
||||
"""Config overrides must patch stage config values."""
|
||||
from core.detect.profile import get_profile, get_stage_config
|
||||
from core.detect.stages.models import RegionAnalysisConfig
|
||||
|
||||
base = SoccerBroadcastProfile()
|
||||
original = base.region_analysis_config()
|
||||
profile = get_profile("soccer_broadcast")
|
||||
original = RegionAnalysisConfig(**get_stage_config(profile, "detect_edges"))
|
||||
|
||||
overrides = {"region_analysis": {"edge_canny_low": 25, "edge_canny_high": 200}}
|
||||
wrapped = OverrideProfile(base, overrides)
|
||||
patched = wrapped.region_analysis_config()
|
||||
overrides = {"detect_edges": {"edge_canny_low": 25, "edge_canny_high": 200}}
|
||||
merged_configs = {**profile["configs"]}
|
||||
merged_configs["detect_edges"] = {**merged_configs["detect_edges"], **overrides["detect_edges"]}
|
||||
patched_profile = {**profile, "configs": merged_configs}
|
||||
|
||||
patched = RegionAnalysisConfig(**get_stage_config(patched_profile, "detect_edges"))
|
||||
|
||||
assert isinstance(patched, RegionAnalysisConfig)
|
||||
assert patched.edge_canny_low == 25
|
||||
assert patched.edge_canny_high == 200
|
||||
# Unmodified fields keep their defaults
|
||||
assert patched.edge_hough_threshold == original.edge_hough_threshold
|
||||
|
||||
|
||||
def test_override_profile_passthrough():
|
||||
"""OverrideProfile without region_analysis key passes through unchanged."""
|
||||
from detect.checkpoint.replay import OverrideProfile
|
||||
from detect.profiles.soccer import SoccerBroadcastProfile
|
||||
def test_config_override_passthrough():
|
||||
"""Overrides for other stages don't affect unrelated stages."""
|
||||
from core.detect.profile import get_profile, get_stage_config
|
||||
from core.detect.stages.models import RegionAnalysisConfig
|
||||
|
||||
base = SoccerBroadcastProfile()
|
||||
wrapped = OverrideProfile(base, {"ocr": {"min_confidence": 0.1}})
|
||||
config = wrapped.region_analysis_config()
|
||||
assert config.edge_canny_low == base.region_analysis_config().edge_canny_low
|
||||
profile = get_profile("soccer_broadcast")
|
||||
original = RegionAnalysisConfig(**get_stage_config(profile, "detect_edges"))
|
||||
|
||||
overrides = {"run_ocr": {"min_confidence": 0.1}}
|
||||
merged_configs = {**profile["configs"], **overrides}
|
||||
patched_profile = {**profile, "configs": merged_configs}
|
||||
|
||||
patched = RegionAnalysisConfig(**get_stage_config(patched_profile, "detect_edges"))
|
||||
assert patched.edge_canny_low == original.edge_canny_low
|
||||
|
||||
Reference in New Issue
Block a user