Official Python implementation of ODIN (Open Data Interchange Notation)
Project description
odin-foundation
Official Python SDK for ODIN (Open Data Interchange Notation) — a canonical data model for transporting meaning between systems, standards, and AI.
Install
pip install odin-foundation
Requires Python 3.8+
Quick Start
import odin
doc = odin.parse("""
{policy}
number = "PAP-2024-001"
effective = 2024-06-01
premium = #$747.50
active = ?true
""")
print(doc["policy.number"]) # "PAP-2024-001"
print(doc["policy.premium"]) # 747.50
text = odin.dumps(doc)
Core API
| Function | Description | Example |
|---|---|---|
odin.parse(text) |
Parse ODIN text into a document | doc = odin.parse(src) |
odin.dumps(doc) |
Serialize document to ODIN text | text = odin.dumps(doc) |
odin.loads(text) |
Alias for parse (Python-idiomatic) |
doc = odin.loads(src) |
odin.stringify(doc) |
Alias for dumps |
text = odin.stringify(doc) |
odin.canonicalize(doc) |
Deterministic bytes for hashing/signatures | b = odin.canonicalize(doc) |
odin.validate(doc, schema) |
Validate against an ODIN schema | result = odin.validate(doc, schema) |
odin.parse_schema(text) |
Parse a schema definition | schema = odin.parse_schema(src) |
odin.diff(a, b) |
Structured diff between two documents | changes = odin.diff(doc_a, doc_b) |
odin.patch(doc, diff) |
Apply a diff to a document | updated = odin.patch(doc, changes) |
odin.parse_transform(text) |
Parse a transform specification | tx = odin.parse_transform(src) |
odin.execute_transform(tx, source) |
Run a transform on data | out = odin.execute_transform(tx, doc) |
doc.to_json() |
Export to JSON | json_str = doc.to_json() |
doc.to_xml() |
Export to XML | xml_str = doc.to_xml() |
doc.to_csv() |
Export to CSV | csv_str = doc.to_csv() |
odin.dumps(doc) |
Export to ODIN | odin_str = odin.dumps(doc) |
odin.builder() |
Fluent document builder | odin.builder().section("policy")... |
Schema Validation
import odin
schema = odin.parse_schema("""
{policy}
!number : string
!effective : date
!premium : currency
active : boolean
""")
doc = odin.parse(source)
result = odin.validate(doc, schema)
if not result.valid:
for error in result.errors:
print(error)
Transforms
import odin
transform = odin.parse_transform("""
map policy -> record
policy.number -> record.id
policy.premium -> record.amount
""")
result = odin.execute_transform(transform, doc)
Export
odin_str = odin.dumps(doc) # ODIN string
json_str = doc.to_json() # JSON string
xml_str = doc.to_xml() # XML string
csv_str = doc.to_csv() # CSV string
Builder
doc = (odin.builder()
.section("policy")
.set("number", "PAP-2024-001")
.set("effective", date(2024, 6, 1))
.set("premium", odin.currency(747.50))
.set("active", True)
.build())
Testing
Tests use pytest and the shared golden test suite:
pytest
Links
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 odin_foundation-1.0.4.tar.gz.
File metadata
- Download URL: odin_foundation-1.0.4.tar.gz
- Upload date:
- Size: 259.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32a8ab5b14fd5454cde38bddada72892068306375a2508e4c3e311b7a965a2db
|
|
| MD5 |
8c9e887aaea1309a35a8a34d63ed85b4
|
|
| BLAKE2b-256 |
e578e07020485300508d238c99794f3765f6a060200f4d446566d790ad23bfdd
|
Provenance
The following attestation bundles were made for odin_foundation-1.0.4.tar.gz:
Publisher:
publish.yml on odin-foundation/odin-core-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
odin_foundation-1.0.4.tar.gz -
Subject digest:
32a8ab5b14fd5454cde38bddada72892068306375a2508e4c3e311b7a965a2db - Sigstore transparency entry: 1247472656
- Sigstore integration time:
-
Permalink:
odin-foundation/odin-core-python@326806b6d1abb3f40b383e0fccb79c65cce83aed -
Branch / Tag:
refs/heads/main - Owner: https://github.com/odin-foundation
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@326806b6d1abb3f40b383e0fccb79c65cce83aed -
Trigger Event:
push
-
Statement type:
File details
Details for the file odin_foundation-1.0.4-py3-none-any.whl.
File metadata
- Download URL: odin_foundation-1.0.4-py3-none-any.whl
- Upload date:
- Size: 177.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 |
93b68ae7292eda1428d3e188c27b0861fc2bcf3518ad49757991e77d7d5a89aa
|
|
| MD5 |
b0290c3687c61a6271590a9d3b60f48d
|
|
| BLAKE2b-256 |
cc6fac5dc2ae79ba395766330bbf14f3ca4f7ed08fe82d511a472d7b81e34608
|
Provenance
The following attestation bundles were made for odin_foundation-1.0.4-py3-none-any.whl:
Publisher:
publish.yml on odin-foundation/odin-core-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
odin_foundation-1.0.4-py3-none-any.whl -
Subject digest:
93b68ae7292eda1428d3e188c27b0861fc2bcf3518ad49757991e77d7d5a89aa - Sigstore transparency entry: 1247472672
- Sigstore integration time:
-
Permalink:
odin-foundation/odin-core-python@326806b6d1abb3f40b383e0fccb79c65cce83aed -
Branch / Tag:
refs/heads/main - Owner: https://github.com/odin-foundation
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@326806b6d1abb3f40b383e0fccb79c65cce83aed -
Trigger Event:
push
-
Statement type: