Metadata-Version: 2.5
Name: aice-data-quality
Version: 0.1.0
Summary: Data quality SDK: checks, one result contract, one destination
Author-email: Adanian Labs <engineering@adanianlabs.io>
License: MIT
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Typing :: Typed
Requires-Python: <3.14,>=3.10
Requires-Dist: pydantic>=2
Requires-Dist: pyyaml>=6
Provides-Extra: dbt
Provides-Extra: dev
Requires-Dist: httpx>=0.27; extra == 'dev'
Requires-Dist: jsonschema[format]>=4.21; extra == 'dev'
Requires-Dist: openpyxl>=3.1; extra == 'dev'
Requires-Dist: opentelemetry-api>=1.20; extra == 'dev'
Requires-Dist: opentelemetry-sdk>=1.20; extra == 'dev'
Requires-Dist: pandas>=2; extra == 'dev'
Requires-Dist: psycopg[binary]>=3.1; extra == 'dev'
Requires-Dist: pytest>=8.3; extra == 'dev'
Requires-Dist: sqlalchemy>=2; extra == 'dev'
Provides-Extra: excel
Requires-Dist: openpyxl>=3.1; extra == 'excel'
Requires-Dist: pandas>=2; extra == 'excel'
Provides-Extra: http
Requires-Dist: httpx>=0.27; extra == 'http'
Provides-Extra: otel
Requires-Dist: opentelemetry-api>=1.20; extra == 'otel'
Provides-Extra: pandas
Requires-Dist: pandas>=2; extra == 'pandas'
Provides-Extra: sql
Requires-Dist: psycopg[binary]>=3.1; extra == 'sql'
Requires-Dist: sqlalchemy>=2; extra == 'sql'
Description-Content-Type: text/markdown

# aice-data-quality (SDK)

Check data, record the outcome in the result contract, send it to one destination.
Import name: `dq`. Produces records of contract `1.0` ([`contract/`](contract/README.md)).

```python
from dq import QualityClient, Dataset, Severity, checks as c
from dq.sources import DataFrameSource

client = QualityClient(project="my-project", environment="production")   # or DQ_* env vars
with client.run(pipeline="uploads") as run:
    report = run.validate(DataFrameSource(df), dataset=Dataset("finance_uploads", "statement", "bronze"),
                          owner="finance",
                          checks=[c.not_null("amount", name="amount_set", severity=Severity.BLOCK)])
if report.blocked:
    raise UploadRejected(report.messages())
```

- Full guide: [`docs/user-guide.md`](docs/user-guide.md)
- Runnable example: [`examples/dataframe_example.py`](examples/dataframe_example.py)
- Specification (shared with the server): [`../README.md`](../README.md)

## What belongs here, and what does not

| In the SDK (runs inside each project) | In the server (`../server/`, never here) |
|---|---|
| Sources, checks, suites, privacy rules | Storing results: schema, upserts, retention |
| Contract models, run outcome, dbt mapping | Authentication and token scopes |
| Sinks: `LogSink`, `HttpSink` (the server's client), the local spool | Queries, history for `vs_previous`, dataset and check listings |
| `SqlSource`, which reads the project's own data tables | Alert routing, UI |

The SDK has no results database and no results DDL. `SqlSource` is the only code that talks to a database,
and only to read data being checked.

## Develop

```bash
docker compose up -d --wait      # sample Postgres on :55432 for SqlSource tests only
uv sync --extra dev
uv run pytest                    # SqlSource tests skip themselves if the database is down
```
