Skip to main content

The dbt of data contracts — define, enforce, and evolve data contracts

Project description

WarePact

The dbt of data contracts. Define, enforce, and evolve contracts between data producers and consumers — as code, in CI, with zero vendor lock-in.

pip install warepact[duckdb]

Quick start

# Scaffold a contracts/ directory
warepact init

# Check a contract against your warehouse
warepact check orders

# Check all contracts
warepact check --all

# Generate a contract from a live table
warepact generate analytics.core.orders --warehouse snowflake

# Watch contracts continuously
warepact watch --interval 300

Contract format

version: 1
name: orders
owner: data-team@company.com
warehouse: snowflake
table: analytics.core.orders

schema:
  - column: order_id
    type: integer
    not_null: true
    unique: true
  - column: status
    type: string
    allowed_values: [pending, shipped, delivered, cancelled]
  - column: amount
    type: float

sla:
  freshness_hours: 6
  min_rows: 1000
  max_null_rate: 0.01

alerts:
  - channel: slack
    webhook_url: "${SLACK_WEBHOOK}"
    on: [breach, recovery]

custom_checks:
  - name: no_negative_amounts
    sql: "SELECT COUNT(*) FROM {table} WHERE amount < 0"
    expected: 0

Supported warehouses

Warehouse Install extra
DuckDB pip install warepact[duckdb]
Snowflake pip install warepact[snowflake]
BigQuery pip install warepact[bigquery]
Redshift pip install warepact[redshift]
Postgres pip install warepact[postgres]
Databricks pip install warepact[databricks]

Configuration

WarePact reads warehouse credentials from environment variables. No secrets belong in contract YAML files.

Warehouse Required env vars
snowflake SNOWFLAKE_ACCOUNT, SNOWFLAKE_USER, SNOWFLAKE_PASSWORD, SNOWFLAKE_WAREHOUSE, SNOWFLAKE_DATABASE, SNOWFLAKE_SCHEMA
bigquery GOOGLE_APPLICATION_CREDENTIALS, BIGQUERY_PROJECT
redshift REDSHIFT_HOST, REDSHIFT_PORT, REDSHIFT_DATABASE, REDSHIFT_USER, REDSHIFT_PASSWORD
postgres PGHOST, PGPORT, PGDATABASE, PGUSER, PGPASSWORD
databricks DATABRICKS_HOST, DATABRICKS_TOKEN, DATABRICKS_HTTP_PATH
duckdb DUCKDB_DATABASE (path to .duckdb file, or :memory:)

warepact init automatically detects your warehouse from these env vars and prints the full list of required variables.

Supported alert channels

  • Slack — Block Kit webhook
  • Email — SMTP
  • PagerDuty — Events API v2
  • Webhook — Generic JSON POST/PUT
  • Teams — Adaptive Cards webhook

CLI reference

Command Description
warepact init Scaffold contracts/ with an example contract
warepact check <name> Check one contract
warepact check --all Check every contract in contracts/
warepact check --all --json Output results as JSON
warepact generate <table> Generate a contract YAML from a live table
warepact watch Continuously re-check on a schedule
warepact diff <name> <fileA> <fileB> Diff two contract versions
warepact report Generate an HTML health dashboard
warepact publish <name> Publish a contract to the local registry
warepact mcp Start the MCP server for Claude/Cursor integration

Python API

from warepact import ContractEngine
from warepact.parsers import YAMLParser

parser = YAMLParser()
contract = parser.parse_file("contracts/orders.contract.yaml")

engine = ContractEngine()
result = engine.check(contract)

print(result.to_human_readable())
# Contract 'orders': PASSED
#   ✓ Schema matches expected definition
#   ✓ Row count 45231 is within bounds [1000, ∞)
#   ✓ Data is fresh (last updated 2.1 hours ago)
#   ✓ Null rates are within acceptable limits

MCP integration

Start the MCP server and connect it to Claude or Cursor:

warepact mcp

Available tools: check_contract, list_contracts, explain_breach, get_contract_health, suggest_contract.


Writing a custom adapter

from warepact.core.registry import PluginRegistry
from warepact.interfaces.warehouse import WarehouseAdapter

@PluginRegistry.register_warehouse("mydb")
class MyDBAdapter(WarehouseAdapter):
    def connect(self, credentials: dict) -> None: ...
    def get_schema(self, table: str) -> list[dict]: ...
    def get_row_count(self, table: str) -> int: ...
    def get_last_updated(self, table: str): ...
    def run_query(self, sql: str) -> list[dict]: ...
    def get_null_rates(self, table: str, columns: list[str]) -> dict: ...

Drop the file in warepact/plugins/ or install it as a package — PluginRegistry.autodiscover() will pick it up automatically.


License

Apache 2.0 — free forever, no monetization.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

warepact-0.1.3.tar.gz (76.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

warepact-0.1.3-py3-none-any.whl (71.7 kB view details)

Uploaded Python 3

File details

Details for the file warepact-0.1.3.tar.gz.

File metadata

  • Download URL: warepact-0.1.3.tar.gz
  • Upload date:
  • Size: 76.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for warepact-0.1.3.tar.gz
Algorithm Hash digest
SHA256 a959f5e54a1eeac83a1634c8b6f4ee6283b89f5399d8b8e253cffba115b65391
MD5 378eb3b27100355529d0233c1af71868
BLAKE2b-256 329b9b96de6e82f8c11253d86c9bac93205776d2e63d3e98055c2a6786037abc

See more details on using hashes here.

File details

Details for the file warepact-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: warepact-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 71.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for warepact-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 554b97920339c68cc9a136cf1157c86e187ad55f821b844532eea9fb24f90890
MD5 756af17e6673055a329e26718b3b1a54
BLAKE2b-256 7d18dff0a9498e152cd7ff2215622588701638efe24d7f4d397bc65c819fdbd9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page