CMeta v1: compact metadata format with JSON transforms
Project description
Nuklai Nexus Compact Metadata Standard (CMeta)
CMeta is a compact metadata format for describing data lakes, tables, and columns in a way that is:
- 🪶 Token-efficient: compresses schema/metadata for LLMs with narrow context windows
- 🧑💻 Human-readable: easy to read and edit manually
- 🔄 Reversible: can be converted to and from JSON (compact or verbose)
This package provides Python utilities to:
- Parse CMeta text ⇄ JSON
- Convert to/from a compact JSON structure
- Convert to/from a flat, extended JSON structure (very verbose for some specific Nexus use cases)
✨ Installation
uv add nuklai-cmeta
Uses uv. You can also install with
pip install nuklai-cmetaif you prefer.
📐 CMeta v1 Format
-
Hierarchy:
- Lake → Tables → Columns
:denotes containers*denotes columns
-
Descriptions: in
[ ... ] -
Types: in
< ... >using full SQL types (string,int,boolean,date,timestamp, etc.) -
Nested fields: use dot notation (
car.engine.horsepower) -
Escape rules:
]→\]<→\<>→\>
Example:
Webshop[Contains all webshop data]:
users[Contains all registered users]:
* user_id<int>[Unique ID of a user]
* name<string>[Full name of a user]
* email<string>[Email address]
orders[Customer orders]:
* id<int>[Order id]
* total<double>[Total amount]
* created_at<timestamp>[When created]
🔧 Usage
Parse CMeta text → Model
from cmeta import parse_cmeta
text = """
Webshop[Contains all webshop data]:
users[Contains all registered users]:
* user_id<int>[Unique ID]
* name<string>[Full name]
"""
model = parse_cmeta(text)
print(model.lakes[0].tables[0].columns[0].name)
# "user_id"
Model → CMeta text
from cmeta import to_cmeta
cmeta_str = to_cmeta(model)
print(cmeta_str)
Compact JSON
from cmeta import model_to_compact_json, compact_json_to_model
cj = model_to_compact_json(model)
print(cj[0]["tables"][0]["columns"][0])
# {'name': 'user_id', 'type': 'int', 'description': 'Unique ID'}
m2 = compact_json_to_model(cj)
assert to_cmeta(m2) == to_cmeta(model)
Compact JSON format:
[
{
"name": "Webshop",
"description": "Contains all webshop data",
"tables": [
{
"name": "users",
"description": "Contains all registered users",
"columns": [
{"name": "user_id", "type": "int", "description": "Unique ID"}
]
}
]
}
]
Extended JSON (flat, very verbose)
from cmeta import model_to_extended_json, extended_json_to_model
ej = model_to_extended_json(model)
print(ej[0])
# {
# 'columnName': 'user_id',
# 'columnDescription': 'Unique ID',
# 'dataType': 'int',
# 'sourceDescription': 'Contains all webshop data',
# 'sourceName': 'Webshop',
# 'tableDescription': 'Contains all registered users',
# 'tableName': 'users'
# }
m3 = extended_json_to_model(ej)
Extended JSON format:
[
{
"columnName": "user_id",
"columnDescription": "Unique ID",
"dataType": "int",
"sourceDescription": "Contains all webshop data",
"sourceName": "Webshop",
"tableDescription": "Contains all registered users",
"tableName": "users"
}
]
✅ Supported Data Types
CMeta supports common datatypes:
stringint,bigintfloat,double,decimalbooleandate,timestampjson,array,map
🧪 Development
Clone and set up:
uv venv && source .venv/bin/activate
make install
Run checks:
make ci # lint + typecheck + test
make lint # ruff
make format # autoformat
make test # pytest
🚀 Publishing
Dev workflow for trusted contributors:
-
Bump the version in
pyproject.toml. -
Commit & push to
main. -
Tag the release:
git tag v0.1.0 && git push origin v0.1.0
-
The GitHub Actions workflow will:
- run tests
- build wheels/sdist
- publish to PyPI
📄 License
MIT — free for personal and commercial use.
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 nuklai_cmeta-0.1.0.tar.gz.
File metadata
- Download URL: nuklai_cmeta-0.1.0.tar.gz
- Upload date:
- Size: 19.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84ee479485eeb0f980c46039a918b2a7c895e2cd0fa6f12c95a16dc508c091a6
|
|
| MD5 |
c7456303710db69854f0ec9a40802682
|
|
| BLAKE2b-256 |
2f78470bdc9a11f5b9f7c7def731e2d8db628723bdc47c98c12d1801ddbda3dd
|
Provenance
The following attestation bundles were made for nuklai_cmeta-0.1.0.tar.gz:
Publisher:
ci.yml on Nuklai/cmeta
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nuklai_cmeta-0.1.0.tar.gz -
Subject digest:
84ee479485eeb0f980c46039a918b2a7c895e2cd0fa6f12c95a16dc508c091a6 - Sigstore transparency entry: 404478260
- Sigstore integration time:
-
Permalink:
Nuklai/cmeta@4e51eb7205465014ba4ebd43d2ece955444e446c -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Nuklai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@4e51eb7205465014ba4ebd43d2ece955444e446c -
Trigger Event:
push
-
Statement type:
File details
Details for the file nuklai_cmeta-0.1.0-py3-none-any.whl.
File metadata
- Download URL: nuklai_cmeta-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
628c1440ff06ec7a87381c14b3637ffcbb79b3b5d5c45a86725c0827e73cfcdd
|
|
| MD5 |
76ac1c2af31c4553a0e3e9414674b9e2
|
|
| BLAKE2b-256 |
95d8bdfe3cd1495628a246fb9f8fa9ab18bee153bb64383ba4d098791aa49f82
|
Provenance
The following attestation bundles were made for nuklai_cmeta-0.1.0-py3-none-any.whl:
Publisher:
ci.yml on Nuklai/cmeta
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nuklai_cmeta-0.1.0-py3-none-any.whl -
Subject digest:
628c1440ff06ec7a87381c14b3637ffcbb79b3b5d5c45a86725c0827e73cfcdd - Sigstore transparency entry: 404478266
- Sigstore integration time:
-
Permalink:
Nuklai/cmeta@4e51eb7205465014ba4ebd43d2ece955444e446c -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Nuklai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@4e51eb7205465014ba4ebd43d2ece955444e446c -
Trigger Event:
push
-
Statement type: