Skip to content

feat: Open-Meteo ensemble integration, bug fixes, dependency updates, security hardening - #103

Draft
simreaney with Copilot wants to merge 3 commits into
mainfrom
copilot/add-open-meteo-api
Draft

simreaney with Copilot wants to merge 3 commits into
mainfrom
copilot/add-open-meteo-api

Conversation

Copilot AI commented Aug 7, 2026

Copy link
Copy Markdown

Replaces the GEFS/pygrib weather pipeline with Open-Meteo ensemble forecasts (free, no API key), fixes several latent bugs in gefs.py and tasks.py, bumps stale/insecure dependencies, and removes hardcoded credential defaults.

Open-Meteo ensemble integration

  • New calculations/open_meteo.py — fetches all ensemble members from https://ensemble-api.open-meteo.com/v1/ensemble, decomposes wind speed+direction into U/V components, derives daily min/max from hourly temperatures (stored in K for schema consistency), bulk-inserts into NoaaForecast
  • dailyModelUpdate() branches on WEATHER_SOURCE setting ("open_meteo" default, "gefs" for legacy)
  • New settings: WEATHER_SOURCE, OPEN_METEO_MODEL (default gfs_seamless), OPEN_METEO_ENSEMBLE_MEMBERS (0 = all)

Bug fixes (gefs.py, tasks.py)

  • datetime.astimezone(obj, tz=...)obj.astimezone(tz=...) (was raising TypeError at runtime)
  • GRIB field variables initialised to None before loop; raises ValueError naming missing fields instead of UnboundLocalError
  • GRIB temp file written to tempfile.mkstemp() and deleted in finally; gefsData.close() also moved to finally
  • Removed spurious app = Celery() in tasks.py (created a second Celery instance alongside the project-level one)
  • open(filename)open(filename, encoding="utf-8-sig")

Dependencies (config/manyFEWS.base.yml, Dockerfile)

  • retrying (unmaintained since 2014) → tenacity; xlrd (.xls-only, deprecated) removed
  • Pins: numpy>=1.24,<2, pandas>=2.0, celery>=5.4, django>=4.2,<5.1 (LTS)
  • Added requests, tenacity
  • Base images: node:alpine3.15node:lts-alpine, miniconda3:4.12.0 → latest, debian:bullseye-slimdebian:bookworm-slim
  • black pre-commit: 22.3.024.10.0

Security

  • DB_PASSWORD and SECRET_KEY no longer have insecure hardcoded defaults — both are now required env vars (will raise at startup if unset)

Copilot AI and others added 2 commits August 7, 2026 04:01
- Add open_meteo.py with ensemble forecast fetching via Open-Meteo API
- Add WEATHER_SOURCE, OPEN_METEO_MODEL, OPEN_METEO_ENSEMBLE_MEMBERS settings
- Update dailyModelUpdate() to branch on WEATHER_SOURCE
- Fix gefs.py: date bug, unbound variables, temp file leak, retrying→tenacity
- Remove spurious Celery() instantiation from tasks.py
- Fix bare open() encoding in tasks.py
- Remove insecure SECRET_KEY and DB_PASSWORD defaults from settings.py
- Update conda env: bump numpy/pandas/celery/django, drop xlrd/retrying, add tenacity/requests
- Bump Dockerfile base images: node:lts-alpine, miniconda3 latest, debian:bookworm-slim
- Bump black pre-commit hook to 24.10.0"

Co-authored-by: simreaney <7837361+simreaney@users.noreply.github.com>
- Move defaultdict import to top of open_meteo.py
- Fix Point(lat, lon) → Point(lon, lat) (GIS x/y convention)
- Move gefsData.close() into finally block to prevent handle leak

Co-authored-by: simreaney <7837361+simreaney@users.noreply.github.com>
Copilot AI changed the title feat: Open-Meteo ensemble integration + security/bug fixes feat: Open-Meteo ensemble integration, bug fixes, dependency updates, security hardening Aug 7, 2026
Copilot AI requested a review from simreaney August 7, 2026 04:03
…fety

Co-authored-by: simreaney <7837361+simreaney@users.noreply.github.com>
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