Skip to main content

CMeta v1: compact metadata format with JSON transforms

Project description

Nuklai Nexus Compact Metadata Standard (CMeta)

CI

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-cmeta if 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:

  • string
  • int, bigint
  • float, double, decimal
  • boolean
  • date, timestamp
  • json, 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:

  1. Bump the version in pyproject.toml.

  2. Commit & push to main.

  3. Tag the release:

    git tag v0.1.0 && git push origin v0.1.0
    
  4. The GitHub Actions workflow will:

    • run tests
    • build wheels/sdist
    • publish to PyPI

📄 License

MIT — free for personal and commercial use.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nuklai_cmeta-0.1.0.tar.gz (19.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nuklai_cmeta-0.1.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

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

Hashes for nuklai_cmeta-0.1.0.tar.gz
Algorithm Hash digest
SHA256 84ee479485eeb0f980c46039a918b2a7c895e2cd0fa6f12c95a16dc508c091a6
MD5 c7456303710db69854f0ec9a40802682
BLAKE2b-256 2f78470bdc9a11f5b9f7c7def731e2d8db628723bdc47c98c12d1801ddbda3dd

See more details on using hashes here.

Provenance

The following attestation bundles were made for nuklai_cmeta-0.1.0.tar.gz:

Publisher: ci.yml on Nuklai/cmeta

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for nuklai_cmeta-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 628c1440ff06ec7a87381c14b3637ffcbb79b3b5d5c45a86725c0827e73cfcdd
MD5 76ac1c2af31c4553a0e3e9414674b9e2
BLAKE2b-256 95d8bdfe3cd1495628a246fb9f8fa9ab18bee153bb64383ba4d098791aa49f82

See more details on using hashes here.

Provenance

The following attestation bundles were made for nuklai_cmeta-0.1.0-py3-none-any.whl:

Publisher: ci.yml on Nuklai/cmeta

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page