Skip to main content

clinical-contract

Write healthcare data contracts, validate their structure, and check CSV or Parquet datasets against them.

PyPI Python License: MIT

clinical-contract is a lightweight tool for teams that need to describe, share, and verify clinical data expectations.

It helps you:

  • write a data contract with a guided web editor or YAML;
  • validate that the contract is correctly composed;
  • check that a real .parquet or .csv file conforms to the expected schema;
  • run expressive SQL quality rules with DuckDB using equality, thresholds, or ranges;
  • use the same logic in the browser, the CLI, and Python pipelines.

clinical-contract web editor demo

Live Web App

The project includes a static browser application designed for GitHub Pages:

Open the web editor

The web app lets users create or load a contract, edit it visually, inspect the generated YAML, validate the contract, upload a CSV/Parquet file, preview the dataset, and run schema/quality checks directly in the browser with PyScript, Pyodide, and DuckDB.

Why It Exists

Clinical data exchanges often fail because the expected dataset is documented in one place while the real delivered file follows another reality.

clinical-contract keeps the expectation and the verification close together:

  • the contract explains what the dataset should contain;
  • the checker verifies what the dataset actually contains;
  • the quality rules make important assumptions executable.

This makes data delivery easier to review, easier to automate, and easier to discuss between data producers and data consumers.

What It Checks

clinical-contract currently focuses on three practical layers:

  1. Contract structure Required metadata, description fields, schema definitions, columns, and quality rules are validated before checking data.

  2. Schema compatibility Required columns must exist and detected DuckDB types must match the contract logical or physical types.

  3. Quality rules SQL checks are executed against the loaded CSV/Parquet file and reported as passed or failed.

Python Package

The same engine is available as a Python package on PyPI.

pip install clinical-contract

Validate a contract:

clinical-contract validate site/examples/contract.yaml

Check a data file:

clinical-contract check site/examples/contract.yaml site/examples/template.parquet

Use it from Python to validate a contract structure:

from clinical_contract import DataContract, load_raw

raw_contract = load_raw("contract.yaml")
report = DataContract.validate_structure(raw_contract)

print(report.success)

Or check a data file against a contract:

from clinical_contract import load_contract

contract, _ = load_contract("contract.yaml")
report = contract.check("data.parquet")

print(report.success)

Local Development

Clone the repository:

git clone https://github.com/artheioupfat/clinical-contract.git
cd clinical-contract

Install Python dependencies:

uv sync --extra dev

Run Python tests:

uv run pytest -v

Install web dependencies:

npm ci

Run site tests:

npm run test:site

Build the site CSS:

npm run build:site:css

Serve the static site locally:

python3 -m http.server 8000 --directory site

Then open http://127.0.0.1:8000.

Project Structure

src/clinical_contract/   Python package and validation engine
site/                    Static web app for GitHub Pages
site/examples/           Browser template contract and sample dataset
tests/                   Python test suite
site/tests/              JavaScript site tests

Status

The project is still evolving. The current focus is to keep the Python library, CLI, and browser app aligned around one DuckDB-based validation engine.

License

MIT — see LICENSE for details.

Author

Arthur PRIGENT — GitHub

Metadata

Release files for clinical-contract 0.1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for clinical-contract 0.1.9
File Size Uploaded Provenance Actions
clinical_contract-0.1.9.tar.gz 6.5 MB With provenance Details for clinical_contract-0.1.9.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for clinical-contract 0.1.9
File Interpreter ABI Platform Actions
clinical_contract-0.1.9-py3-none-any.whl Python 3 none any Details for clinical_contract-0.1.9-py3-none-any.whl

Total release size: 6.5 MB

Release files / clinical_contract-0.1.9.tar.gz

Download URL clinical_contract-0.1.9.tar.gz
Size 6.5 MB
Tags Source
SHA-256 checksum
How to use checksums
79fa71c4470a13d6f37591faacb0de7a51f90ea5688d8f0965b6836d370dfee8
BLAKE2b-256 checksum
How to use checksums
403170e5682070fc993c83761c34ed568e4515e43f3e7dcb2d8c81676785e1cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 31, 2026.

Transparency log

Release files / clinical_contract-0.1.9-py3-none-any.whl

Download URL clinical_contract-0.1.9-py3-none-any.whl
Size 18.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5e89ec2fc04e41946fcd180cc4c02b19d67a5b5857a543f107e6451ae42f4276
BLAKE2b-256 checksum
How to use checksums
70bc080f56d35b3a3e5fc5fe972faeabde51e5cf0f0a3dc08699a2f50b7896e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 31, 2026.

Transparency log

Security for clinical-contract 0.1.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for clinical_contract-0.1.9.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 31, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page