Skip to content

Excessive API calls bugfix - #2

Merged
nawinds merged 2 commits into
mainfrom
development
May 26, 2026
Merged

Excessive API calls bugfix#2
nawinds merged 2 commits into
mainfrom
development

Conversation

@nawinds

@nawinds nawinds commented May 26, 2026

Copy link
Copy Markdown
Member

No description provided.

BeganovR added 2 commits May 26, 2026 22:55
Two bugs fixed:

1. Forecaster was making zones×slots API calls (up to 720+) per run.
   Each predict_for_zone() call triggered a separate load_recent_observations()
   and weather.get_at() → most timed out → only 1-2 zones got forecasts.
   Fix: pre-fetch recent_hourly once per zone in forecaster.run(), pass it
   through predict() → predict_for_zone() so the thread pool does pure math.
   Also cache zone→camera map in weather module (one get_zones call per process).

2. Forecasts beyond ~25h were always identical (static) because
   load_recent_observations(zone, future_ts, 25h) returns empty —
   all lag/MA features were constant FALLBACK=0.5 regardless of hour.
   Fix: store per-zone per-hour historical averages in zone_meta.json at
   training time; use them as lag/MA fallback so 3am and 4pm get
   meaningfully different feature vectors.
When recent data exists but is sparse (e.g. 1-2 readings in 25h window),
all get_lag() calls were resolving to the same last-known value, making
every prediction slot produce identical feature vectors and therefore
identical forecasts.

Fix: when no observation exists at the exact lag timestamp, use the
per-zone per-hour historical average instead of the last known reading.
Same logic applied to MA windows when the window is empty.
Result: 3am and 4pm now get meaningfully different lag/MA values.
@nawinds
nawinds merged commit 919f6c4 into main May 26, 2026
6 checks passed
nawinds added a commit that referenced this pull request Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants