mirror of
https://github.com/zvx-echo6/meshai.git
synced 2026-08-26 17:31:34 +00:00
chore(central-ripout 2c): relocate gauge sites to env/gauge_sites.py (#163)
Moves the last non-fire live file out of central/. idaho_gauge_sites.py held USGS stream-gauge site data + threshold ranking — pure hydro/gauge domain, misfiled among the retired Central handlers. Applied the owner's rule with a clean split: - THRESHOLD_RANK (a 5-element list used ONLY by notifications/gating/hydro.py) inlined there — single consumer, belongs next to its use. - The gauge-site lookup (used by env/usgs.py + persistence/curation.py) moved to env/gauge_sites.py, next to the usgs adapter that produces gauge data. - Dropped the redundant "idaho_" prefix (the Idaho scoping is data, not code). Consumers rewired: env/usgs.py, notifications/gating/hydro.py, and tests. central/ is now down to firms_handler.py + wfigs_handler.py (the fire pair, whose relocation is a separate PR because of their cross-file coupling). Move + import-rewire only, no behavior change. Suite: 2059 passed, 0 failed. Co-authored-by: Matt Johnson <mj@k7zvx.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
41178831e4
commit
dd932b4ee9
5 changed files with 25 additions and 19 deletions
|
|
@ -2,7 +2,7 @@
|
|||
JetStream firehose and normalized it into meshai pipeline Events. The NATS
|
||||
consumer is retired (Central is gone); this package now only holds the
|
||||
split-file modules still used by the native adapter paths (firms_handler,
|
||||
wfigs_handler _render, idaho_gauge_sites). The satellite pieces
|
||||
(satpass_handler, tle_handler, pass_predictor) have moved to
|
||||
meshai.env.satellite — they're feed-adapter support code, not consumer
|
||||
leftovers."""
|
||||
wfigs_handler _render). The satellite pieces (satpass_handler, tle_handler,
|
||||
pass_predictor) have moved to meshai.env.satellite, and the gauge-site
|
||||
lookups have moved to meshai.env.gauge_sites — they're feed-adapter support
|
||||
code, not consumer leftovers."""
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
"""v0.6-4 Idaho gauge-site lookups (now backed by gauge_sites table).
|
||||
"""v0.6-4 gauge-site lookups (now backed by gauge_sites table).
|
||||
|
||||
The IDAHO_CURATED_SITES Python dict was migrated to the gauge_sites SQLite
|
||||
table in v8.sql. seed_gauge_sites() (called from init_db on first boot)
|
||||
|
|
@ -6,18 +6,19 @@ populates the table with the original 9 sites. The lookup helpers below
|
|||
read from the table via meshai.persistence.curation.
|
||||
|
||||
Module exports retained for backward-compat with existing tests:
|
||||
lookup_site, normalize_site_id, THRESHOLD_RANK, compute_threshold_state.
|
||||
lookup_site, normalize_site_id, compute_threshold_state.
|
||||
The IDAHO_CURATED_SITES name itself is gone -- new code should call
|
||||
lookup_site() (DB-backed) or the curation accessor directly.
|
||||
|
||||
(Relocated from meshai/central/idaho_gauge_sites.py -- Central is gone;
|
||||
this is pure hydro/gauge domain code, not a Central handler. The "idaho_"
|
||||
prefix was dropped on the move: the data is Idaho-scoped but the code
|
||||
itself is generic gauge/threshold logic. THRESHOLD_RANK, formerly exported
|
||||
here, was inlined into its sole consumer, meshai.notifications.gating.hydro.)
|
||||
"""
|
||||
from typing import Optional
|
||||
|
||||
|
||||
# Ordered list of threshold names from low to high. Used to compare
|
||||
# "is current threshold higher than prior" (upward crossing detection).
|
||||
THRESHOLD_RANK = ["normal", "action", "flood_minor", "flood_moderate", "flood_major"]
|
||||
|
||||
|
||||
def normalize_site_id(raw: Optional[str]) -> Optional[str]:
|
||||
"""Accept 'USGS-13139510', 'USGS:13139510', '13139510', etc. Return the
|
||||
canonical 'USGS-<id>' form so the curation table lookups succeed."""
|
||||
10
work/meshai/env/usgs.py
vendored
10
work/meshai/env/usgs.py
vendored
|
|
@ -39,11 +39,11 @@ def _cfg_str(config, attr: str, default: str) -> str:
|
|||
|
||||
# Maps the flood_status strings _fetch() sets (see severity-classification
|
||||
# block above) onto the ranked threshold_state vocabulary the shared hydro
|
||||
# gating/formatter modules speak (meshai.central.idaho_gauge_sites.
|
||||
# THRESHOLD_RANK / meshai.notifications.gating.hydro / formatters.hydro).
|
||||
# Kept local rather than importing from central.idaho_gauge_sites so this
|
||||
# adapter has no dependency on the (Central-only, reference-only) central
|
||||
# package -- only the string vocabulary is shared, not the code.
|
||||
# gating/formatter modules speak (meshai.notifications.gating.hydro.
|
||||
# THRESHOLD_RANK / formatters.hydro).
|
||||
# Kept local rather than importing from gating.hydro so this adapter has
|
||||
# no dependency on the gating package -- only the string vocabulary is
|
||||
# shared, not the code.
|
||||
_FLOOD_STATUS_TO_THRESHOLD_STATE = {
|
||||
"Action Stage": "action",
|
||||
"Minor Flood": "flood_minor",
|
||||
|
|
|
|||
|
|
@ -74,12 +74,17 @@ import logging
|
|||
from typing import Optional
|
||||
|
||||
from meshai.adapter_config import adapter_config
|
||||
from meshai.central.idaho_gauge_sites import THRESHOLD_RANK
|
||||
from meshai.notifications.gating.base import GateResult
|
||||
from meshai.persistence import get_db
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Ordered list of threshold names from low to high. Used to compare
|
||||
# "is current threshold higher than prior" (upward crossing detection).
|
||||
# Formerly meshai.central.idaho_gauge_sites.THRESHOLD_RANK -- inlined here
|
||||
# since this decider was its only consumer.
|
||||
THRESHOLD_RANK = ["normal", "action", "flood_minor", "flood_moderate", "flood_major"]
|
||||
|
||||
|
||||
def _rank(state: Optional[str]) -> int:
|
||||
"""THRESHOLD_RANK index for *state*, treating unknown as 0 (normal)."""
|
||||
|
|
|
|||
|
|
@ -208,8 +208,8 @@ class TestGateSequenceParity:
|
|||
|
||||
def _canonical(self, fixture):
|
||||
"""Build canonical data from a Central-style fixture (as the deleted
|
||||
handler used to) via the still-live idaho_gauge_sites helpers."""
|
||||
from meshai.central.idaho_gauge_sites import (
|
||||
handler used to) via the still-live gauge_sites helpers."""
|
||||
from meshai.env.gauge_sites import (
|
||||
compute_threshold_state, lookup_site, normalize_site_id,
|
||||
)
|
||||
env = fixture["envelope"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue