Metadata-Version: 2.5
Name: dataproduct-sdk
Version: 0.1.0rc1
Summary: Turn an ODCS data contract plus pure transforms into a running, quality-gated, multi-target data product
Author-email: Leandro Kellermann de Oliveira <lkellermann@leandroasaservice.com>
License-Expression: LicenseRef-Proprietary
License-File: LICENSE
Keywords: data-contract,data-mesh,data-product,databricks,duckdb,ibis,odcs,write-audit-publish
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: Pytest
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Database
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Requires-Python: >=3.12
Requires-Dist: datacontract-cli[duckdb]>=1.0.13
Requires-Dist: pyyaml>=6.0
Provides-Extra: api
Requires-Dist: fastapi>=0.139.2; extra == 'api'
Requires-Dist: uvicorn>=0.51.0; extra == 'api'
Provides-Extra: databricks
Requires-Dist: datacontract-cli[databricks]>=1.0.13; extra == 'databricks'
Description-Content-Type: text/markdown

# Data Product SDK

Turn an [ODCS](https://bitol-io.github.io/open-data-contract-standard/) data contract plus a set
of pure transforms into a running, quality-gated, multi-target data product. One codebase runs on
**DuckDB** locally and **Databricks/Spark** in production, behind a ports/adapters seam, with a
**Write-Audit-Publish** quality gate derived entirely from the contract.

> **Proprietary software.** This package is *not* open source. Installing it grants you the right
> to use it; it does not grant the right to redistribute it or to create derivative works. See the
> `LICENSE` file inside the distribution for the full terms.

## Install

```bash
pip install dataproduct-sdk                 # DuckDB target (default)
pip install "dataproduct-sdk[databricks]"   # + the Databricks/Spark production target
pip install "dataproduct-sdk[api]"          # + serve a published port as a REST endpoint
```

Requires Python 3.12+.

## Scaffold a product

```bash
dataproduct init            # interview -> a complete, green product repo
cd <your-product>
dataproduct check           # the fitness-function battery
dataproduct run             # transform -> audit -> publish
```

## What a product looks like

```python
# product.py
from dataproduct import Product
import transforms as T

product = Product(name="orders", domain="sales")

@product.table("orders")
def orders(src):
    return T.build_orders(src.read("orders_raw"))

@product.view("public_orders", reads=["orders"])
def public_orders(orders):
    return T.build_public_orders(orders)

product.enable_observability()
```

You write three things: **transformation logic** (pure `ibis` expression-to-expression functions),
**declared constraints** (an ODCS contract), and **topology** (which output ports exist and what
feeds them). The SDK supplies everything else.

## What the SDK does for you

| | |
|---|---|
| **Contract-derived quality** | Row and dataset rules are projected from the ODCS contract — no second place to keep them in sync. Each rule maps to an action: warn, quarantine the row, or hard-fail the dataset. |
| **Write-Audit-Publish** | Every port is staged, audited, and only then published — by shape. Tables get an atomic swap, views are defined only after the audit passes, APIs get a black-box audit. A failed gate leaves the last good data serving. |
| **Forensic quarantine** | Rejected rows are kept with the rule that rejected them, and completeness is accounted for so nothing silently disappears. |
| **Portability** | Core and transforms are written against the `ibis` expression API only, so the identical pipeline and the identical gate run on DuckDB and on Databricks. Enforced, not just intended. |
| **Fitness functions** | `dataproduct check` runs a battery of architectural checks — transform purity, module boundaries, WAP coverage, contract lint, schema conformance, placement drift. |
| **Schema evolution** | `dataproduct evolve` plans a contract change and gates on plan freshness. |
| **Offline introspection** | `dataproduct explain` projects what a run would do without touching a warehouse; `dataproduct run --dry-run` provably writes nothing. |

## CLI

```
dataproduct init | run | serve | audit | docs | check
             quarantine | observability | evolve | generate
             explain | contract draft
```

Add `--format json` to `explain` and `run --dry-run` for machine-readable output.

## Extending it

Targets are resolved through the `dataproduct.adapters` entry-point group, so a new backend is a
separate distribution — no fork and no change to this package. The core depends only on the
`Protocol`s in `dataproduct.ports`.

## Licence and support

Proprietary — copyright (c) 2026 Leandro Kellermann de Oliveira, all rights reserved.
For redistribution, OEM bundling, a source licence, or support:
**lkellermann@leandroasaservice.com**
