| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- """DemandAgent PG Pattern V2 query facade.
- Historically this module opened the MySQL Pattern compatibility schema. The PG
- migration keeps the function names used by DemandAgent, but all
- Pattern evidence reads now go through `pg_pattern_repository` and are read-only.
- """
- from __future__ import annotations
- from examples.demand.pg_pattern_repository import (
- DEFAULT_DEMAND_PLATFORM,
- normalize_platform,
- query_case_ids_by_post_ids,
- query_category_level,
- query_element_bindings_for_items,
- query_execution_for_evidence,
- query_itemset_evidence,
- query_itemset_items_with_categories,
- query_seed_points_for_sources,
- query_latest_success_execution_id,
- query_seed_points_for_itemsets,
- query_source_elements,
- query_video_ids_by_names,
- )
- class DatabaseManager:
- """Legacy guard.
- PG Pattern V2 does not expose a SQLAlchemy MySQL session. Old prepare paths
- must be migrated before production use; local MVP uses explicit PG
- execution_id and never calls `get_session()`.
- """
- def get_session(self):
- raise RuntimeError(
- "DatabaseManager MySQL session was removed; use PG Pattern V2 "
- "repository functions instead"
- )
- def exist_cluster_tree(merge_level2: str) -> bool:
- """Return whether a successful PG Pattern V2 execution is available.
- The old implementation checked MySQL cluster tree state by merge_level2.
- The PG-only MVP consumes existing Pattern V2 executions instead, so this is
- a conservative readiness check used only by legacy web guards.
- """
- del merge_level2
- return query_latest_success_execution_id() is not None
- __all__ = [
- "DatabaseManager",
- "DEFAULT_DEMAND_PLATFORM",
- "exist_cluster_tree",
- "normalize_platform",
- "query_case_ids_by_post_ids",
- "query_category_level",
- "query_element_bindings_for_items",
- "query_execution_for_evidence",
- "query_itemset_evidence",
- "query_itemset_items_with_categories",
- "query_latest_success_execution_id",
- "query_seed_points_for_itemsets",
- "query_seed_points_for_sources",
- "query_source_elements",
- "query_video_ids_by_names",
- ]
|