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.5.tar.gz (77.9 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.5-py3-none-any.whl (72.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: warepact-0.1.5.tar.gz
  • Upload date:
  • Size: 77.9 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.5.tar.gz
Algorithm Hash digest
SHA256 769086c65b95b523572739a0273fdd73415144b8686a22459f83e8563c75e929
MD5 f0bd9637058d1e1349cac49a491f6770
BLAKE2b-256 78779fc006c00690ad457900cf0fa266e59514bcf2f62efde9dc67287031cb5d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: warepact-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 72.3 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 dbf2a549e8a9446a2ed02a9141381c417f02bd9df98c5429c26272765b727cbf
MD5 40de54ed6919c4c09dc34a1ec3093c81
BLAKE2b-256 af75765b8e2d7a8eff6f0fe5a99ae993bdf03e286af6c3ae00ef3d96e98e0165

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