Skip to content

About

End-to-end weather analytics pipeline: Open-Meteo API → Prefect (orchestration) → SeaweedFS (lakehouse) → DuckDB (query engine) → Streamlit (dashboard).

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

prefect-seaweedfs-duckdb

End-to-end weather analytics pipeline built for portfolio purposes: it orchestrates daily and historical ingestion of weather data from the free Open-Meteo API using Prefect, lands it through a raw → staging → mart layered structure on SeaweedFS (self-hosted, S3-compatible object storage), queries the final layer directly with DuckDB's httpfs (no local copy of the data), and visualizes multi-city trends in a Streamlit dashboard.

Architecture

Architecture

Storage layout:

s3://weather-bucket/
├── raw/openmeteo/city=<city>/dt=YYYY-MM-DD/data.parquet
├── staging/weather/dt=YYYY-MM-DD/data.parquet
└── mart/weather/dt=YYYY-MM-DD/data.parquet

Repo structure

├── common/            # shared config, DuckDB connection, S3/SeaweedFS storage helpers
├── pipeline/
│   ├── tasks/         # extract (Open-Meteo), transform, load — no Prefect dependency
│   └── flows/         # Prefect flows (weather_flow, backfill_flow) + shared task wrappers
├── dashboard/         # Streamlit app querying mart/ via DuckDB httpfs
├── scripts/           # standalone scripts (bucket init)
├── docs/
│   └── screenshots/   # dashboard screenshots (black/, white/ themes)
└── tests/             # pytest unit tests for extract/transform/storage, API/S3 mocked

Setup

  1. Copy .env.example to .env and fill in every value — there are no built-in defaults, and the app fails fast if a variable is missing.
  2. docker compose up -d --build — brings up SeaweedFS (master, volume, filer, s3 gateway on :8333), the Prefect server/UI (:4200), builds the app image, creates the bucket (bucket-init, idempotent), registers deployments (deployments service, see below), then starts the Streamlit dashboard on :8501.

Running the daily flow

docker compose run --rm app python -m pipeline.flows.weather_flow

Runs the Prefect flow directly for yesterday's date (forecast API), with retries on the extract step — bypasses the UI/deployment, useful for local debugging.

Running the backfill (historical load)

Trigger the weather-backfill deployment from the Prefect UI (http://localhost:4200) and set start_date / end_date (YYYY-MM-DD) as run parameters. It loops over CITIES × the date range, pulling from the Open-Meteo Archive API and writing through raw/ → staging/ → mart/, with full Prefect task tracking and retries.

Prefect UI

Available at http://localhost:4200 — trigger and schedule deployments, and see flow runs, task runs, logs, and state history for every run (backed by a persistent prefect-server service, not the ephemeral local server Prefect falls back to when no server is configured).

Dashboard

Already running at http://localhost:8501 once docker compose up -d --build finishes. Shows a temperature heatmap by city, precipitation comparison by city, and summary stats — all queried live from mart/ via DuckDB's httpfs.

Dashboard screenshot for reference:

Temperature heatmap by city

Precipitation comparison by city

Summary stats table

After changing dashboard/app.py, rebuild and restart just that service:

docker compose up -d --build app

No need to bring the rest of the stack down — SeaweedFS, Prefect server, and the deployments service keep running, and existing data is untouched.

Tests

  1. Create and activate a virtual environment:
    python -m venv .venv
    .venv\Scripts\Activate.ps1
    
  2. Install dependencies:
    pip install -r requirements-dev.txt
    
  3. Make sure .env exists (see Setup) — tests read their config from it, there are no test-only defaults.
  4. Run the tests:
    pytest
    

Unit tests cover extract, transform, and storage, with the API/S3 calls mocked.

Stopping

docker compose down

Use docker compose down -v to also remove everything, including SeaweedFS and Prefect server data.

About

End-to-end weather analytics pipeline: Open-Meteo API → Prefect (orchestration) → SeaweedFS (lakehouse) → DuckDB (query engine) → Streamlit (dashboard).

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages