- models_core 패키지 신설 — BaseDetectionModel / ModelContext / ModelResult + Registry (ACTIVE 버전 인스턴스화, DAG 순환 검출, topo 플랜) + DAGExecutor (PRIMARY→ctx.shared 주입, SHADOW persist-only 오염 차단) + params_loader (5분 TTL 캐시), feature_flag (PREDICTION_USE_MODEL_REGISTRY) - V034 스키마 정합성 사전 검증 + silent error 3건 선제 방어 · model_id VARCHAR(64) 초과 시 __init__ 에서 즉시 ValueError · metric_key VARCHAR(64) 초과는 경고 후 drop (다른 metric 는 저장) · persist 가 ctx.conn 재사용 (pool maxconn=5 고갈 방지) - scheduler.py — 10단계 feature flag 분기 (기본 0, 구 경로 보존) - partition_manager — detection_model_run_outputs 월별 파티션 자동 생성/DROP - 유닛테스트 15 케이스 전체 통과 (DAG 순환, SHADOW 오염 차단, 길이 검증) - snapshot 스크립트 (hourly/diagnostic) 개선 · spoofing gt0/gt03/gt05/gt07 세분화 — 'silent fault' vs 'no signal' 구분 · V030 gear_identity_collisions 원시 섹션 (CRITICAL 51건 OPEN 포착) · V034 detection_model_* 모니터링 섹션 (Phase 2 대비) · stage timing 집계 + stats_hourly vs events category drift 감시 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
"""Detection Model Registry feature flag.
|
|
|
|
신·구 prediction 경로를 공존시키는 동안 환경변수로 토글한다.
|
|
초기 배포에서는 **0 (구 경로 유지)** 가 기본 — Phase 2 PoC 이 신·구 diff=0
|
|
동치성을 확인한 뒤 1 로 전환하는 별도 릴리즈를 내는 전략.
|
|
|
|
환경변수:
|
|
PREDICTION_USE_MODEL_REGISTRY '1' 이면 DAGExecutor 기반 신 경로 사용
|
|
PREDICTION_CONCURRENT_SHADOWS '1' 이면 SHADOW/CHALLENGER 를 스레드풀 동시 실행
|
|
(기본 0 — 순차 실행, psycopg2 pool 안전)
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
|
|
|
|
def _bool_env(key: str, default: str = '0') -> bool:
|
|
raw = os.getenv(key, default).strip().lower()
|
|
return raw in ('1', 'true', 'yes', 'on')
|
|
|
|
|
|
def use_model_registry() -> bool:
|
|
"""models_core Registry·Executor 기반 경로 사용 여부."""
|
|
return _bool_env('PREDICTION_USE_MODEL_REGISTRY', '0')
|
|
|
|
|
|
def concurrent_shadows() -> bool:
|
|
"""SHADOW/CHALLENGER 를 ThreadPoolExecutor 로 동시 실행할지."""
|
|
return _bool_env('PREDICTION_CONCURRENT_SHADOWS', '0')
|