Glossary: treetracker-airflow-dags
Generated by .github/scripts/build-glossary.mjs from domain-graph.json (source commit a537231). Do not edit by hand.
This glossary lists the business terms of treetracker-airflow-dags. Each term links to its domain, which says what the domain does, its rules, and its flows. The estate glossary shows which other repos use the same terms.
Terms
- active_tree_region view: Web-Map Precompute
- Airflow Variable: Platform & Orchestration
- capture: Data Export, Data Migration
- capture image: Species Identification
- CKAN dataset: Data Export
- country leader board: Reporting & Analytics
- DAG: Platform & Orchestration
- earnings: Data Export
- entity: Data Migration
- FCC contract earnings: Reporting & Analytics
- grower: Data Export
- map tile: Web-Map Precompute
- messaging author: Platform & Orchestration
- organization: Data Export
- organization_location view: Web-Map Precompute
- PID lock: Platform & Orchestration
- planter: Data Export, Data Migration
- planter_location view: Web-Map Precompute
- prediction: Species Identification
- reporting schema: Reporting & Analytics
- S3 manifest: Species Identification
- SageMaker batch transform job: Species Identification
- session_segment: Reporting & Analytics
- Slack channel: Platform & Orchestration
- species stat view: Web-Map Precompute
- stakeholder: Data Migration
- tree cluster: Web-Map Precompute
- tree_denormalized: Reporting & Analytics
- validation set: Species Identification
- wallet token: Platform & Orchestration
Domains
Data Export
Extracts Treetracker records (tree captures, growers, earnings, planter info) from Postgres and publishes them to external destinations. Most exports stream batched query results into CSV and upload to the CKAN open-data portal; planter info uploads over FTP.
Terms: capture, grower, earnings, planter, CKAN dataset, organization
Rules:
- Exports run per organization for a monthly date window
- Inputs (organization id, date) are validated before any query runs
- Query results are streamed in batches to bound memory usage
- Planter info upload supports a dry-run mode that skips the FTP transfer
Flows:
- Monthly Capture Export (
capture_export_dag.py (monthly schedule)): Exports monthly tree-capture data for an organization to CSV and uploads it to the CKAN data portal. - Grower Export (
grower_export_dag.py): Queries grower records for an organization and date, builds a CSV payload, and uploads it to a CKAN datastore over HTTP. - Monthly Earnings Export (
earnings_export_dag.py (monthly schedule)): Computes the previous-month window, queries earnings for that range, and pushes the dataset to a CKAN endpoint. - Planter Info FTP Upload (
upload_planter_info_dag.py (daily)): Queries planter info from Postgres, builds a CSV byte stream, and uploads it to an FTP server on a daily schedule.
Data Migration
Moves and reshapes legacy Treetracker data into the current domain database. Migrates legacy capture records daily and consolidates the stakeholder and entity tables, reconciling entity-stakeholder relationships transactionally.
Terms: capture, stakeholder, entity, planter
Rules:
- Capture migration runs on a daily schedule via Kubernetes pod operators
- Entity-stakeholder reconciliation runs inside a single transaction with commit or rollback
- The sync routine supports a dry-run mode
Flows:
- Migrate Captures (
migrate_captures_dag.py (daily)): Migrates legacy capture data into the new domain database daily using Postgres and Kubernetes pod operators. - Migrate Stakeholders (
migrate_stakeholders_dag.py): Consolidates the stakeholder and entity tables and reconciles entity-stakeholder relationships transactionally.
Reporting & Analytics
Computes aggregates and denormalized reporting data in-database. Populates the reporting schema and tree_denormalized table, ranks countries by planted trees with PostGIS, computes FCC contract earnings per term, and chops sessions into time segments.
Terms: country leader board, FCC contract earnings, reporting schema, tree_denormalized, session_segment
Rules:
- Leaderboard ranking uses PostGIS spatial SQL (ST_Contains, ST_Area) over country geometries
- FCC earnings are computed per contract term bounded by start and end dates
- Reporting jobs compute results in-database rather than exporting raw data
Flows:
- Country Leaderboard Refresh (
country_learder_board_dag.py): Ranks countries by planted trees using PostGIS spatial SQL, fetches centroids, and persists the leader board back to the database. - FCC Contract Earnings (
contracts-earnings-fcc.py (daily)): Computes daily earnings for FCC (Freetown) planters by creating planter entities, syncing stakeholders, and aggregating contract earnings per term. - Populate Reports Schema (
populate-reports-schema.py): Populates the reporting schema and the tree_denormalized table in Postgres via a sequence of SQL and Python tasks for downstream analytics. - Session Time Chopping (
session_time_chopping_dag.py): Computes the session_segment for each raw_capture within a session and writes UUID-keyed segments to Postgres. - Reporting Card Cache Warming (
pre_request_reporting_card.py): Pre-warms the reporting capture-statistics endpoint using the K8S_DOMAIN Airflow Variable and the current date.
Web-Map Precompute
Keeps the Greenstand web map fast by precomputing tiles and tree clusters. Warms tile and cluster caches on a short schedule, assigns newly captured trees to clusters, removes deactivated trees, and refreshes webmap materialized views.
Terms: map tile, tree cluster, active_tree_region view, organization_location view, planter_location view, species stat view
Rules:
- Tile and cluster caches are warmed every 5 minutes for the most-visited views
- Cluster assignment runs staged SQL within a transaction and rolls back on error
- Deactivated trees are removed from cluster counts before views refresh
Flows:
- Map Tile Cache Warming (
pre_request_map_client_dag.py (every 5 min)): Pre-warms the web-map client tile cache for the most-visited views every five minutes by issuing GET requests over a fixed URL list. - Map Cluster Cache Warming (
pre_request_map_clusters_dag.py): Pre-warms map cluster tile endpoints across multiple zoom levels by repeatedly calling the pre_request helper. - Assign New Trees to Clusters (
map/assign-new-trees-to-clusters.py): Assigns newly captured active trees to their nearest map cluster by running staged SQL against Postgres within a transaction. - Update Clusters for Deactivated Trees (
map/update-clusters-for-deactivated-trees.py): Removes deactivated trees from cluster counts, refreshes the active_tree_region materialized view, and recomputes map clusters. - Refresh Webmap Materialized Views (
refresh_webmap_*_dag.py): Refreshes the organization_location, planter_location, and species-statistics materialized views in the webmap database.
Species Identification
Machine-learning pipeline that identifies tree species from capture images. Pulls capture image URLs within a geographic bounding box, stages images in S3, runs a SageMaker batch transform inference job, and builds a validation set from accepted predictions.
Terms: capture image, S3 manifest, SageMaker batch transform job, prediction, validation set
Rules:
- Image URLs are selected by geographic bounding box and date range
- Predictions are filtered by an acceptance threshold before entering the validation set
- S3 staging buckets are cleaned up after each inference run
Flows:
- Species ID Batch Inference (
species_id_dag.py): Runs the species-identification pipeline: selects capture images, stages them in S3, builds a manifest, runs a SageMaker batch transform job, and builds a validation set before cleaning up S3.
Platform & Orchestration
Cross-cutting scheduling and platform jobs. Airflow default_args wire a shared Slack failure callback into every DAG, cron shell wrappers run Node jobs with PID locking, and small platform jobs provision messaging authors and wallet tokens.
Terms: DAG, Airflow Variable, Slack channel, messaging author, wallet token, PID lock
Rules:
- A task failure triggers a Slack notification via the shared on_failure_callback
- Cron wrappers use a PID lock file to prevent overlapping runs
- Messaging authors are created only for approved growers/organizations
Flows:
- Task Failure Notification (
on_failure_callback (Airflow task failure)): When any DAG task fails, the shared on_failure_callback builds task context and posts an alert to Slack. - Cron Wrapper Execution (
map/scripts/*.sh (cron)): Shell cron wrappers acquire a PID lock to prevent overlapping runs, invoke a Node map task, and log output to a system log file. - Messaging Author Provisioning (
create-authors.py (hourly)): Hourly job that reads approved growers/organizations and inserts corresponding messaging-system author records. - Wallet Token Creation (
create-tokens.py): Creates wallet tokens by reading run configuration and inserting rows into the wallet database.