Dagster pipeline that fetches country data from the REST Countries API, lands it raw in Garage (S3-compatible object storage), cleans it into an Iceberg staging table (via Lakekeeper + Trino), and builds Iceberg datamart tables for a HoloViz Panel dashboard.
Layers: raw (JSON in Garage) → staging (Iceberg table) → datamart (Iceberg tables).
.
├── dagster_project/ # Dagster pipeline code
│ ├── assets/ # raw/staging/reference/datamart asset definitions
│ ├── io_managers/ # Iceberg/Garage IO managers
│ └── resources/ # API, Garage, and Trino resource definitions
├── panel_app/ # HoloViz Panel dashboard app (custom HTML/CSS, no charting library)
├── shared/ # Code shared between dagster_project and panel_app (Trino connection setup)
├── docs/ # Architecture diagram and dashboard screenshots
│ └── screenshots/
├── garage/ # Garage (S3-compatible storage) config
├── scripts/ # One-off setup scripts (e.g. Lakekeeper warehouse init)
├── tests/ # Unit tests for the pipeline assets
└── trino/
└── catalog/ # Trino catalog configuration
- Docker + Docker Compose
- A REST Countries API key (
API_TOKENin.env) - Python 3.11+ (needed to run
scripts/init_lakekeeper_warehouse.py, and for Dagster/tests outside Docker). Use a virtualenv so these don't pollute your global Python:python -m venv .venv # Windows: .venv\Scripts\activate # macOS/Linux: source .venv/bin/activate pip install -e .
-
Copy the env template and fill in real credentials:
cp .env.example .env
GARAGE_ACCESS_KEY_IDmust follow Garage's own format:GKfollowed by 24 hex characters (e.g. generate one withecho "GK$(openssl rand -hex 12)") — Garage rejects any other format when the key is registered in step 4. -
Start every service:
docker compose up -d
-
Confirm all services are healthy:
docker compose ps
-
Bootstrap the cluster: assigns the Garage layout, registers the access key, creates the raw/staging/datamart buckets, and creates the Lakekeeper warehouse (reads
.envitself, works the same in PowerShell or bash):python scripts/init_lakekeeper_warehouse.py
-
Verify Trino can see the Iceberg catalog:
docker compose exec trino trino --execute "SHOW CATALOGS"
-
Open the Dagster UI at http://localhost:3000 and materialize all assets (or click "Materialize all" on the asset graph), or run:
docker compose exec dagster dagster job execute -m dagster_project -j countries_pipeline_job -
Open the Panel dashboard at http://localhost:3001. It connects to Trino on startup (host
trino, port8080, catalogiceberg, userdagster, no password/SSL — seepanel_app/trino_client.py) and renders stat tiles, ranked lists and grids built directly from the datamart tables below. A snapshot date selector at the top of the page lists everysnapshot_datethat exists indm_countries(most recent first, selected by default) and re-queries all datamart tables for that date when changed — useful for comparing a given day against history once the daily schedule has accumulated more than one snapshot. Region totals and the top-10 cuts (most populous, most densely populated) aren't separate tables — the dashboard derives them at query time fromdm_subregion_summaryanddm_countriesrespectively:datamart.dm_currency_distribution— countries per currency, with the currency's full name joined in fromreference.dim_currencydatamart.dm_language_distribution— countries per languagedatamart.dm_subregion_summary— population/area/country count per subregion (and, rolled up further, per region)datamart.dm_countries— one row per country: population, area, population density, capitalreference.dim_currency— static ISO 4217 currency code → name lookup (not derived from the API; seedagster_project/assets/reference.py)
Reload the page after re-running the pipeline to pick up the newest snapshot; the dashboard has no database of its own, so nothing needs re-configuring.
The daily schedule (daily_countries_pipeline, 06:00) re-runs the full
raw → staging → datamart pipeline automatically once enabled in the Dagster UI.
- Full refresh (fresh raw data): materialize
raw_countries(overwrites the same raw JSON object in Garage) and let its downstream assets (stg_countries,dm_*) re-materialize. - Partial run (staging/datamart only): select just
stg_countriesand thedm_*assets in the Dagster UI to reprocess the existing raw JSON without re-hitting the API.
Every staging/datamart table carries a snapshot_date column and is written
as one dated snapshot per run (delete + insert, keyed on snapshot_date), so
history accumulates across days instead of being overwritten — re-running
multiple times on the same day just replaces that day's snapshot, staying
idempotent. Datamart queries (and the daily schedule) only ever read the
current day's staging snapshot, so numbers reflect one point in time rather
than the full history.
# activate the venv from Prerequisites first
pip install -e ".[dev]"
pytestEvery asset's external resources (api, garage, trino) are Dagster
resources injected at runtime, so tests mock them directly instead of hitting
real services.
Dashboard screenshot for reference:
To run the Panel app outside Docker (with live reload) against an already
running trino service:
pip install -e ".[dashboard]"
export TRINO_HOST=localhost TRINO_PORT=8080 TRINO_USER=dagster TRINO_CATALOG=iceberg TRINO_SCHEMA_DATAMART=datamart
panel serve panel_app/dashboard.py --autoreload --showdocker compose downStops and removes the containers, but keeps all data (Postgres, Garage,
Dagster home) in their named volumes — a later docker compose up -d
picks up right where you left off. The Panel dashboard itself is stateless
(it only reads from Trino), so there's no dashboard data to preserve.
To also wipe all data (raw/staging/datamart tables, everything) and start clean:
docker compose down -v
