Files
Northern-Thailand-Ping-Rive…/.env.example
T
grabowski 7e642555b4 chore: remove the Python service; Python is the training stack only
Phase 4 of docs/RUST_REWRITE.md. Since 2026-10-18 ping-collector (rust/)
collects, forecasts, notifies (ntfy + Matrix) and serves the website/API;
nothing in production ran the Python service code any more.

Removed (~17k lines): the FastAPI app (web_api, schemas, health_check,
metrics, postgres_history, forecast_history, thaiwater), the Python RID
collector and CLI (water_scraper_v3, main, run.py), the notifier and Matrix
alerting (notify, alerting), the multi-backend adapters (SQLite, MySQL,
InfluxDB, VictoriaMetrics) with demo databases, models/validators/exceptions/
logging/rate limiter, ml/skill.py (served by Rust now), the migration tooling
(api_parity, collector_parity, e2e_notify, install_collector.sh,
gen_notify_cases.py, spikes/rust-forecast), Docker/compose/Grafana files,
sql/, the release workflow and the docs for all of that. Their tests went
with them.

Kept in Python: src/ml (training, evaluation harness, export; predict.py as
the reference the Rust forecaster is tested against), the HII and RID-dam
clients/stores for the archive backfills (their live collectors removed),
the backfill scripts, retrain.sh + timer, forecast_parity.py.

- PostgreSQL only: src/config.py is database_url() from POSTGRES_* / .env;
  the stores lost their sqlite/mysql branches (and the 2026-08 column
  migration). The database tests run against a throwaway schema from
  TEST_DATABASE_URL (tests/conftest.py pg_url, skipped without it), as the
  Rust tests do; CI gets a PostgreSQL service. 100 tests (66 without a DB).
- The notifier settings moved from src/notify.py into src/ml/export.py;
  flood_config.json regenerates byte-identical.
- tests/test_dashboard.py checks every path the dashboard fetches against
  ping-collector's router.
- Dependencies: fastapi, uvicorn, pydantic, influxdb, pymysql, psutil,
  schedule, sphinx, pyinstaller, mypy, pytest-asyncio dropped; python-dotenv
  1.1.1 explicit (it came in through uvicorn[standard]).
- Formatting contract extended to scripts/ and tests/ (reformatted once).
- scripts/install.sh is the one installer (fresh host or update, in place in
  a checkout without touching its ownership): binary, units, uv sync, .env
  defaults, removes the retired water-monitor.service and any old
  --alert-check cron job, dry run + forecast check, restart, readiness wait.
- Docs, CLAUDE.md, CONTRIBUTING.md, .env.example, Makefile, unit comments
  and Rust doc comments updated to the Rust service.
2026-10-18 17:15:07 +07:00

86 lines
3.7 KiB
Bash

# Ping River Monitor configuration: copy to .env and fill in.
#
# Read by ping-collector (the service; rust/collector/src/config.rs) and by the
# Python training tools (src/config.py). Under systemd the variables come from
# EnvironmentFile= (systemd's parser); for manual runs both programs load
# ./.env with python-dotenv's rules. Unset keys take the defaults shown.
# --- Database (PostgreSQL only) ---------------------------------------------
# Either a full connection string (URL-encode special characters in the
# password: : %3A @ %40 # %23 ? %3F & %26 / %2F % %25) ...
POSTGRES_CONNECTION_STRING=
# ... or the parts (the password is encoded for you)
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_DB=water_monitoring
POSTGRES_USER=postgres
POSTGRES_PASSWORD=
# --- What the service runs ---------------------------------------------------
# Website and API: the address to listen on (empty = no website)
WEB_LISTEN=0.0.0.0:8000
# Forecast + ntfy/Matrix notifications after each collection (false = collect only)
FORECAST_IN_COLLECTOR=true
# Trained models (models/flood_<station>.json.gz from src/ml/export.py)
# MODELS_DIR=models
# --- Collection ----------------------------------------------------------------
# RID is polled this many minutes past each hour and retried every
# RID_RETRY_MINUTES while the current hour is not published yet
RID_POLL_OFFSET_MINUTES=5
RID_RETRY_MINUTES=10
# RID reports with holes re-fetched at startup (0 = off); older: `ping-collector fill-gaps all`
GAP_FILL_DAYS_ON_START=14
# ENABLE_HII_COLLECTION=true
# ENABLE_RESERVOIR_COLLECTION=true
# ENABLE_RAIN_COLLECTION=true
# HII_BASIN_CODE=6
# REQUEST_TIMEOUT=30
# Runtime station list written by the admin API; falls back to src/data/stations.json
# STATION_CONFIG_PATH=stations.json
LOG_LEVEL=INFO
# --- Notifications (docs/NOTIFICATIONS.md) ------------------------------------
# Public push alerts via self-hosted ntfy; empty NTFY_SERVER = off. Topics:
# <prefix>-<station>-warning|danger, <prefix>-warning|danger,
# <prefix>-p1-outlook, <prefix>-status.
NTFY_SERVER=
# Where the service POSTs (default NTFY_SERVER): the local ntfy address, so
# publishing does not depend on DNS or the reverse proxy
NTFY_PUBLISH_URL=
NTFY_TOPIC_PREFIX=ping
NTFY_TOKEN=
PUBLIC_URL=https://water.buildfor.life/
# Report RID lagging this many hours while ThaiWater telemetry is current (0 = never)
RID_STALE_ALERT_HOURS=18
# Matrix room for a team: the same transitions (docs/MATRIX_QUICK_START.md);
# off while token or room is empty
MATRIX_HOMESERVER=https://matrix.org
MATRIX_ACCESS_TOKEN=
MATRIX_ROOM_ID=
# --- Website and API -------------------------------------------------------------
# X-API-Key for station editing, /config and POST /scrape/trigger (empty = those are off)
ADMIN_API_KEY=
# Comma-separated origins allowed cross-site with credentials (empty: any origin, no credentials)
CORS_ALLOW_ORIGINS=
# ThaiWater API key for /sensors/thaiwater (extra Ping-basin sensors on the map)
THAIWATER_API_KEY=
# Self-hosted Umami: server-side tracking of API calls
# UMAMI_API_URL=https://stats.buildfor.life/api/send
# UMAMI_WEBSITE_ID=00b2be73-8f5f-4400-9029-3be852eb08f7
# UMAMI_TRACK_API=true
# Response cache TTLs (seconds)
# LATEST_CACHE_TTL_SECONDS=45
# HII_CACHE_TTL_SECONDS=120
# HEALTH_CACHE_TTL_SECONDS=30
# A stored forecast older than this is served marked X-Data-Stale: true
# FORECAST_MAX_AGE_SECONDS=7200
# STATIC_DIR=src/static
# Only for `ping-collector serve` running separately from `run`: the status file
# SCRAPING_STATUS_FILE=collector-status.json
# --- Python tools ----------------------------------------------------------------
# Training/evaluation read the database above; this overrides it for them only
# FLOOD_ML_DB_URL=