Skip to content
Charan Kumar Reddy
Data & MLAI & AgentsCompleteSynthetic data

FeatureHub + DataGuard

ML feature store behind data contracts, schema diffs and Great Expectations gates

Feature store plus data-reliability layer: contracts, schema diffing and Great Expectations gates run before features reach Redis, with point-in-time training joins and incident tracking. Synthetic data.

p99 Redis feature lookup (local, single client)
1.62 ms
featurehub/benchmarks/final_results.json
Great Expectations validation on 100k rows
~355k rows/s
dataguard/benchmarks/final_quality_results.json
FeatureHub and DataGuard dashboard showing feature counts, data contracts, pipelines and quality checks

The problem

Feature pipelines fail silently: a schema change, a burst of nulls or a training join that picks up future values can reach a model unnoticed.

The approach

Data contracts, schema diffing and Great Expectations gates run before features are written to Redis; point-in-time joins build training sets, and a failed gate emits an OpenLineage event and files an incident.

Architecture

  1. 01

    Synthetic source data

    scripts/seed_data.py generates synthetic customers, accounts, merchants and transactions; PostgreSQL 16 stores contracts, pipeline runs and incidents.

  2. 02

    Feature computation

    A pandas engine computes windowed aggregates for the feature definitions in featurehub/feature_definitions/definitions.py and writes them to a Parquet offline store.

  3. 03

    DataGuard gates

    YAML contracts in dataguard/contracts are validated, a schema diff engine classifies changes as SAFE, WARNING or BREAKING, and Great Expectations 1.x suites check nulls, ranges, row counts and freshness.

  4. 04

    Lineage and incidents

    Runs emit OpenLineage-format START, COMPLETE and FAIL events (Pydantic models) with column lineage; failures open incidents in PostgreSQL with severity, owner and a deduplicating failure signature.

  5. 05

    Online materialization

    Only when all gates pass are feature vectors written to a Redis 7.2 online store under featurehub:<entity>:<id> keys; on failure the offline and Redis writes are skipped.

  6. 06

    Serving and orchestration

    FastAPI exposes online feature lookup and a /predict endpoint backed by a scikit-learn RandomForest; Airflow 2.9 DAGs orchestrate the pipelines and a Streamlit dashboard presents the platform.

Key decisions

  • Builds training sets with pandas merge_asof in the backward direction, so each observation only joins feature values at or before its timestamp, then asserts no leakage (raising DataLeakageError) and nulls features older than a TTL; this runs in memory on one machine.
  • Classifies contract changes with explicit rules (adding a nullable column or widening integer to bigint is SAFE, tightening nullability or narrowing float to integer is BREAKING) and runs a GitHub Actions gate on contract-related paths that blocks merges on BREAKING changes.
  • Places DataGuard in front of materialization as a circuit breaker: a failed contract, schema or quality stage skips the offline and Redis writes, so the last validated features in Redis are not overwritten by suspect data.
  • Deduplicates incidents with a SHA-256 signature over dataset, pipeline, check, expectation type and column, so a repeating failure maps to the already open incident instead of creating a new one.
  • Uses Redis for online lookups and PostgreSQL for contracts, runs and incidents (docs/DECISIONS.md), trading RAM for in-memory point lookups. The Redis client falls back to an in-process dictionary when no server is reachable, which keeps tests running but is not shared across processes.
  • Chose Streamlit over a React or Next.js front end for development speed, accepting that Streamlit re-executes the script on each interaction (docs/DECISIONS.md).

Results

  • Benchmark results for Redis lookups, the prediction API and Great Expectations are committed as JSON together with the OS, CPU, Python and Redis versions used.
  • The documented schema-breaking experiment blocks every breaking scenario in its scenario set and approves the safe ones.
  • The integrated flow shows a failed gate emitting an OpenLineage FAIL event and filing an incident instead of writing features to Redis.
Measured results and the files they come from
MetricValueSource
Redis online lookup0.77 ms p50 / 1.62 ms p99featurehub/benchmarks/final_results.json
Great Expectations validation~355k rows/s on 100k rowsdataguard/benchmarks/final_quality_results.json
Prediction API6.62 ms p99 at 228.5 req/sfeaturehub/benchmarks/final_results.json
Registered features122featurehub/benchmarks/final_results.json
Versioned YAML data contracts25README.md
Pipeline definitions orchestrated with Airflow26docs/PIPELINE_INVENTORY.md
Breaking schema changes blocked by the CI gate5 of 5 (8-scenario suite)scripts/schema_breaking_experiment.py

How it is tested

  • About 280 pytest functions across featurehub, dataguard, the integration layer and the dashboard clients, covering the point-in-time join, contract registry, schema diff and type compatibility, the Great Expectations runner, lineage, incidents, Airflow DAG definitions and CI gating.
  • A CI workflow seeds data, computes offline features, runs the point-in-time leakage tests as a separate step, then runs the main test suites.
  • A pull-request workflow runs scripts/ci_contract_gate.py against the base branch when contract, schema, quality or CI code changes, followed by the CI gating tests.
  • PostgreSQL-backed tests live in separate *_postgres files and need a live database; the CI workflows do not start a PostgreSQL service. Docker Compose configuration is validated in CI.

Limits, stated plainly

  • All data is synthetic, generated by scripts/seed_data.py.
  • Latency benchmarks come from one local Windows laptop with Redis over loopback and a single client (concurrency 1); networked deployments would add latency.
  • Feature computation, quality suites and materialization run on one machine with pandas and PyArrow, not a distributed engine.
  • The incident-triage time reduction is documented as an unverified design goal, not a measured result.
  • The public demo mode exposes deterministic demo entities rather than the full stack, and there is no SSO or role-based access control.

Stack

PythonFastAPIRedisPostgreSQLApache AirflowGreat Expectationspandasscikit-learnStreamlit