predictions ON CONFLICT: overwrite xgb/lstm/confidence/ensemble too
Browse filesAfter cutting HeatWavePredictor, pipeline started writing NULL for
trigger_probability_7d on conflict. But the ON CONFLICT clause only
listed 5 columns for update -- xgb_probability, lstm_probability,
prediction_confidence, and ensemble_method were left out, so every
existing predictions row kept the last XGBoost-era values forever
(e.g. DAR-JAN on 04-21 was still carrying xgb_probability=0.0403
from a pre-cut run).
Expanded UPDATE SET to overwrite all of those plus predicted_at=NOW()
so next run fully heals the stale fields.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- src/database/crud.py +6 -1
src/database/crud.py
CHANGED
|
@@ -500,10 +500,15 @@ def insert_prediction(conn, record: dict) -> Optional[int]:
|
|
| 500 |
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
|
| 501 |
ON CONFLICT (zone_id, date) DO UPDATE SET
|
| 502 |
trigger_probability_7d = EXCLUDED.trigger_probability_7d,
|
|
|
|
| 503 |
model_tier = EXCLUDED.model_tier,
|
|
|
|
|
|
|
|
|
|
| 504 |
annual_cost_per_worker = EXCLUDED.annual_cost_per_worker,
|
| 505 |
payout_factor = EXCLUDED.payout_factor,
|
| 506 |
-
learned_frequency = EXCLUDED.learned_frequency
|
|
|
|
| 507 |
RETURNING id
|
| 508 |
""",
|
| 509 |
(record["zone_id"], _to_date(record["date"]),
|
|
|
|
| 500 |
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
|
| 501 |
ON CONFLICT (zone_id, date) DO UPDATE SET
|
| 502 |
trigger_probability_7d = EXCLUDED.trigger_probability_7d,
|
| 503 |
+
prediction_confidence = EXCLUDED.prediction_confidence,
|
| 504 |
model_tier = EXCLUDED.model_tier,
|
| 505 |
+
xgb_probability = EXCLUDED.xgb_probability,
|
| 506 |
+
lstm_probability = EXCLUDED.lstm_probability,
|
| 507 |
+
ensemble_method = EXCLUDED.ensemble_method,
|
| 508 |
annual_cost_per_worker = EXCLUDED.annual_cost_per_worker,
|
| 509 |
payout_factor = EXCLUDED.payout_factor,
|
| 510 |
+
learned_frequency = EXCLUDED.learned_frequency,
|
| 511 |
+
predicted_at = NOW()
|
| 512 |
RETURNING id
|
| 513 |
""",
|
| 514 |
(record["zone_id"], _to_date(record["date"]),
|