Spaces:
Paused
Paused
Create readme.md
Browse files
readme.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Yunusobod ETA Monitor
|
| 3 |
+
emoji: 🍕
|
| 4 |
+
colorFrom: red
|
| 5 |
+
colorTo: yellow
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: "4.44.0"
|
| 8 |
+
app_file: app.py
|
| 9 |
+
pinned: false
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# Yunusobod cook_min live monitor
|
| 13 |
+
|
| 14 |
+
Runs `eta_monitor.py` (the real-time ETA monitor, renamed from `4_monitor.py`
|
| 15 |
+
because Python module names can't start with a digit) continuously in a
|
| 16 |
+
background thread, with a Gradio dashboard showing live status.
|
| 17 |
+
|
| 18 |
+
## Repo layout expected
|
| 19 |
+
|
| 20 |
+
```
|
| 21 |
+
app.py <- Gradio dashboard + background thread starter
|
| 22 |
+
eta_monitor.py <- renamed 4_monitor.py (unchanged otherwise)
|
| 23 |
+
eta_common.py <- your existing DB-credential/config module
|
| 24 |
+
eta_common_v2.py <- your existing feature-engineering module
|
| 25 |
+
eta_common_v2_live.py <- your existing RollingCookBuffer module
|
| 26 |
+
Yunusobod_data/
|
| 27 |
+
cook_time_model_opdb.pkl <- only needed if MODEL_SOURCE=local
|
| 28 |
+
requirements.txt
|
| 29 |
+
README.md (this file)
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
## Required setup, in order
|
| 33 |
+
|
| 34 |
+
1. **Settings -> Variables and secrets -> add secrets** (never commit these
|
| 35 |
+
to the repo): everything `eta_common.get_op_config()` /
|
| 36 |
+
`get_dwh_config()` already reads from the environment locally --
|
| 37 |
+
`OP_DB_HOST`, `OP_DB_PORT`, `OP_DB_NAME`, `OP_DB_USER`, `OP_DB_PASSWORD`,
|
| 38 |
+
`OP_DB_SSLMODE`, and the `DWH_DB_*` equivalents. Also your MLflow
|
| 39 |
+
tracking URI/credentials if `MODEL_SOURCE=mlflow` (default).
|
| 40 |
+
|
| 41 |
+
2. **Optional plain Variables** (not secret, override defaults in
|
| 42 |
+
`app.py`'s `build_args()`): `POLL_SECONDS`, `HISTORY_HOURS`, `ORG_ID`
|
| 43 |
+
(strongly recommended -- skips the slow `resolve_org_id()` DWH
|
| 44 |
+
aggregation on every restart), `MODEL_SOURCE`, `MODEL_STAGE`,
|
| 45 |
+
`MODEL_PATH`, `WRITE_DB`.
|
| 46 |
+
|
| 47 |
+
3. **Settings -> Sleep time -> set to "Never" (Always-On, paid).** This is
|
| 48 |
+
not optional for 24/7 behaviour -- a default/free Space sleeps after a
|
| 49 |
+
period without visitors, which stops the polling loop exactly like
|
| 50 |
+
closing a laptop lid does. This is the direct fix for "it stops when I
|
| 51 |
+
turn my computer off."
|
| 52 |
+
|
| 53 |
+
4. Confirm your DB/MLflow endpoints accept inbound connections from the
|
| 54 |
+
Space's egress IPs (or from the internet generally, if that's already
|
| 55 |
+
the case) -- Spaces don't publish a fixed IP range, so an IP allowlist
|
| 56 |
+
isn't practical; either leave the DB reachable from the internet (as
|
| 57 |
+
confirmed) or use a DB-side auth mechanism (password + SSL, which
|
| 58 |
+
`eta_common`'s `sslmode` already supports) rather than IP restriction.
|
| 59 |
+
|
| 60 |
+
## What's ephemeral vs. durable
|
| 61 |
+
|
| 62 |
+
- The local `monitor_heartbeat.json` and `live_feature_log_*.csv` files
|
| 63 |
+
live on the Space's container filesystem and are **wiped on every
|
| 64 |
+
rebuild/restart** unless you add HF's persistent storage add-on. The
|
| 65 |
+
Gradio dashboard reads these for a live view only.
|
| 66 |
+
- `--write-db` (default on, via `WRITE_DB=true`) is what actually
|
| 67 |
+
persists predictions/actuals durably, to your DWH monitor table --
|
| 68 |
+
that's the source of truth to build any historical reporting on top of,
|
| 69 |
+
not the CSV.
|