Validate clinical YAML data contracts against Parquet and CSV files
Project description
clinical-contract
Write healthcare data contracts, validate their structure, and check CSV or Parquet datasets against them.
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
.parquetor.csvfile conforms to the expected schema; - run SQL quality rules with DuckDB;
- use the same logic in the browser, the CLI, and Python pipelines.
Live Web App
The project includes a static browser application designed for GitHub Pages:
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:
-
Contract structure Required metadata, description fields, schema definitions, columns, and quality rules are validated before checking data.
-
Schema compatibility Required columns must exist and detected DuckDB types must match the contract logical or physical types.
-
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 examples/example_contract.yaml
Check a data file:
clinical-contract check examples/example_contract.yaml data.parquet
Use it from Python:
from clinical_contract import load_contract
contract, raw = load_contract("examples/example_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
examples/ Example contracts
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
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 clinical_contract-0.1.7.tar.gz.
File metadata
- Download URL: clinical_contract-0.1.7.tar.gz
- Upload date:
- Size: 4.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f6d44635502b69421a30041a41f40e09c0b4438587592232cef0cfe7c6aee30
|
|
| MD5 |
aab58b870b0d2be3583a14d1415e6135
|
|
| BLAKE2b-256 |
8d76283d946ecf2b53450b9a07ab6bdde04573d1541022b27f450dbf1aa8fc60
|
Provenance
The following attestation bundles were made for clinical_contract-0.1.7.tar.gz:
Publisher:
ci.yml on artheioupfat/clinical-contract
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clinical_contract-0.1.7.tar.gz -
Subject digest:
0f6d44635502b69421a30041a41f40e09c0b4438587592232cef0cfe7c6aee30 - Sigstore transparency entry: 2039491064
- Sigstore integration time:
-
Permalink:
artheioupfat/clinical-contract@30a3efdaef75477e7307ee8eb41924ea278072c3 -
Branch / Tag:
refs/tags/v0.1.7 - Owner: https://github.com/artheioupfat
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@30a3efdaef75477e7307ee8eb41924ea278072c3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file clinical_contract-0.1.7-py3-none-any.whl.
File metadata
- Download URL: clinical_contract-0.1.7-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
597f3a7bbee77ce8aa29088bf982421b9c44dc73e03f8766933245b8411dcf91
|
|
| MD5 |
29a8bd20e6b1fd123e3eee94474be177
|
|
| BLAKE2b-256 |
06c3d052defe8ad152bf132e9493f5c6e4e0ca883af9d96f4b4851b8bae24763
|
Provenance
The following attestation bundles were made for clinical_contract-0.1.7-py3-none-any.whl:
Publisher:
ci.yml on artheioupfat/clinical-contract
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clinical_contract-0.1.7-py3-none-any.whl -
Subject digest:
597f3a7bbee77ce8aa29088bf982421b9c44dc73e03f8766933245b8411dcf91 - Sigstore transparency entry: 2039491242
- Sigstore integration time:
-
Permalink:
artheioupfat/clinical-contract@30a3efdaef75477e7307ee8eb41924ea278072c3 -
Branch / Tag:
refs/tags/v0.1.7 - Owner: https://github.com/artheioupfat
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@30a3efdaef75477e7307ee8eb41924ea278072c3 -
Trigger Event:
push
-
Statement type: