Apache Airflow provider for the Data Contract CLI: run data contract tests as quality gates in your DAGs
Project description
Data Contract Provider for Apache Airflow
Run Data Contract CLI tests as quality gates in your Airflow DAGs.
Features
DataContractTestOperatorrunsdatacontract testagainst a contract and fails the task when the contract is violated, so bad data stops before it propagates downstream.- Per-check results are rendered in the task log (pass/fail, reason, model/field).
- Structured results are pushed to XCom (key
datacontract_result), so downstream tasks can branch on the outcome. - On Airflow 3, a "Data Contract Results" view in the UI shows recent test runs across all DAGs.
- A "Test Results" button on the task instance links to the published results, e.g. in Entropy Data.
Installation
pip install airflow-provider-datacontract
Extras are passed through to the Data Contract CLI, e.g. for Snowflake:
pip install "airflow-provider-datacontract[snowflake]"
Available extras: duckdb (local files, csv/parquet), snowflake, databricks, bigquery, postgres, s3, azure, kafka, trino.
Usage
from datetime import datetime
from airflow.sdk import dag
from datacontract_provider.operators.datacontract import DataContractTestOperator
@dag(schedule="0 2 * * *", start_date=datetime(2026, 1, 1), catchup=False)
def nightly_datacontract_test():
DataContractTestOperator(
task_id="test_orders_contract",
data_contract_file="https://demo.datacontract.com/orders-latest/datacontract.yaml",
server="production",
)
nightly_datacontract_test()
Operator parameters
| Parameter | Description |
|---|---|
data_contract_file |
Path or URL of the data contract YAML (templated) |
data_contract_str |
Contract as a YAML string, alternative to data_contract_file |
server |
Server key from the contract's servers section to test against |
schema_name |
Schema/model to test, defaults to all |
check_categories |
Subset of schema, quality, servicelevel, custom |
publish_url |
URL to publish test results to (optional) |
results_web_url |
Web page of the published results, shown as a "Test Results" button (optional) |
include_failed_samples |
Collect samples of failing rows |
fail_on_warning |
Also fail the task on result warning |
datacontract_kwargs |
Extra kwargs for the DataContract constructor, e.g. spark |
Credentials for the server under test are read from environment variables by the
Data Contract CLI, e.g. DATACONTRACT_SNOWFLAKE_USERNAME. Set them on the
worker (secret-backed where possible).
XCom
The operator pushes two XCom entries:
datacontract_result:{result, data_contract_file, server, checks_total, checks_failed, checks: [{name, result, category, type, model, field, reason}]}datacontract_results_url: theresults_web_url, if configured
Results view in the Airflow UI (Airflow 3)
The provider ships a plugin that adds a Data Contract Results entry to the
navigation, rendering the most recent test runs across all DAGs with
expandable check details. It is served under /datacontract/results by the
API server and reads the results from XCom. On Airflow 2 the plugin degrades
gracefully and only registers the extra link.
Entropy Data (optional)
To publish test results to Entropy Data (formerly
Data Mesh Manager), set the ENTROPY_DATA_API_KEY environment variable on
the worker and configure:
DataContractTestOperator(
task_id="test_orders_contract",
data_contract_file="...",
server="production",
publish_url="https://api.entropy-data.com/api/test-results",
results_web_url="https://app.entropy-data.com/...", # optional deep link
)
Version support
- Apache Airflow 2.10+ and 3.x (the UI results view requires Airflow 3)
- Python 3.10+
Development
pip install -e ".[dev]"
ruff check src tests
pytest
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file airflow_provider_datacontract-0.1.1.tar.gz.
File metadata
- Download URL: airflow_provider_datacontract-0.1.1.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e27adad81fcb82df5b98c7eeb2c052987bb2e3278f365a0bb4173f14cfb920c
|
|
| MD5 |
041bc2f86056dc5f9e2ed345d8906672
|
|
| BLAKE2b-256 |
fc689e3e90e55c783271b7056f9b005a943c57a6e1e51b83d2702a9bde2bfbae
|
Provenance
The following attestation bundles were made for airflow_provider_datacontract-0.1.1.tar.gz:
Publisher:
release.yml on datacontract/airflow-provider-datacontract
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
airflow_provider_datacontract-0.1.1.tar.gz -
Subject digest:
0e27adad81fcb82df5b98c7eeb2c052987bb2e3278f365a0bb4173f14cfb920c - Sigstore transparency entry: 2314236061
- Sigstore integration time:
-
Permalink:
datacontract/airflow-provider-datacontract@ec520bd778de58a8fd7fee672545158ab533d792 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/datacontract
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ec520bd778de58a8fd7fee672545158ab533d792 -
Trigger Event:
release
-
Statement type:
File details
Details for the file airflow_provider_datacontract-0.1.1-py3-none-any.whl.
File metadata
- Download URL: airflow_provider_datacontract-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13723e5159c51cda697bc6969587a5b52f26653790324094cf96831fd2c6939b
|
|
| MD5 |
7812e7a6c65325391225a53d64450009
|
|
| BLAKE2b-256 |
d3dc754b5c883cd67048d0daf0472ab0ce415cf0b8927dde74891702321070dc
|
Provenance
The following attestation bundles were made for airflow_provider_datacontract-0.1.1-py3-none-any.whl:
Publisher:
release.yml on datacontract/airflow-provider-datacontract
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
airflow_provider_datacontract-0.1.1-py3-none-any.whl -
Subject digest:
13723e5159c51cda697bc6969587a5b52f26653790324094cf96831fd2c6939b - Sigstore transparency entry: 2314236080
- Sigstore integration time:
-
Permalink:
datacontract/airflow-provider-datacontract@ec520bd778de58a8fd7fee672545158ab533d792 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/datacontract
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ec520bd778de58a8fd7fee672545158ab533d792 -
Trigger Event:
release
-
Statement type: