Skip to main content

Python CDM Models

Project description

cdm-lite

Python Pydantic models for the FINOS Common Domain Model (CDM).

cdm-lite provides a lightweight CLI to download, clean, and compile official FINOS CDM JSON schemas into Pydantic v2 models. This enables strict validation, autocompletion, and robust deserialization of CDM JSON payloads in Python codebases without heavy Java dependencies.

Status

Current Phase: Alpha

cdm-lite is currently in an alpha development stage. While the core functionality is operational, we are actively refining the cleaning and generation logic.

Feedback Welcome: We strongly encourage users to provide comments, recommendations, or report any issues found during usage. Your input is vital to reaching a stable 1.0 release.

Scope & Limitations

⚠️ Disclaimer: cdm-lite is intended primarily as a lightweight deserializer. The generated Python models are derived directly from the published JSON Schemas. While they provide close structural validation, we cannot guarantee that the generated models perfectly match the behavioral constraints of the full Common Domain Model.

Pydantic classes inherently cannot capture the full extent of the CDM's functionality, such as complex cross-field cardinality checks, conditions, or rosetta-injected logic. For robust serialization and comprehensive domain validation, we strongly recommend using the official, full CDM project implementations (e.g., the Java distribution).

Installation

uv tool install cdm-lite

Workflow

Download and compile the CDM models for your required schema version:

# List available FINOS CDM versions from Maven Central
cdm-lite versions

# Download schemas and compile Pydantic models locally
cdm-lite install 6.19.0

# Activate the version (updates a local symlink)
cdm-lite use 6.19.0

Note: Models are compiled into a user-level cache directory (e.g., ~/.cache/cdm-lite/). Run cdm-lite status to view your specific path.

Project Integration

To use the compiled models in your application, point your environment to the active models directory.

Using uv (pyproject.toml):

[tool.uv.sources]
# Use the exact absolute path returned by `cdm-lite use`
cdm-models = { path = "/home/user/.cache/cdm-lite/current" }

[project]
dependencies = ["cdm-models"]

Using PYTHONPATH:

# Use the exact absolute path returned by `cdm-lite use`
export PYTHONPATH="/home/user/.cache/cdm-lite/current:$PYTHONPATH"

Deserializing JSON

Once the models are available in your path, use standard Pydantic APIs to parse, validate, and interact with incoming JSON objects:

from cdm-models.models.cdm_event_common_TradeState_schema import TradeState  # Exact import paths depend on the CDM schema

payload = '{"trade": {"tradeDate": {"value": "2023-10-25"}}}'

# Deserialize and strictly validate the JSON string
trade_state = TradeState.model_validate_json(payload)

# Access typed and autocompleted attributes
print(trade_state.trade.trade_date.value)

Reference Commands

  • cdm-lite versions: View available versions on Maven Central.
  • cdm-lite install -v <version>: Fetch schemas and compile models.
  • cdm-lite use -v <version>: Set the active version for the current symlink.
  • cdm-lite list: Show locally compiled versions.
  • cdm-lite status: Print active version and system cache location.
  • cdm-lite clear: Remove all local schemas and generated models.

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

cdm_lite-0.3.1a2.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

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

cdm_lite-0.3.1a2-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

Details for the file cdm_lite-0.3.1a2.tar.gz.

File metadata

  • Download URL: cdm_lite-0.3.1a2.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cdm_lite-0.3.1a2.tar.gz
Algorithm Hash digest
SHA256 5f896d81dcf09c8f5a6cfcca1951f05f1cb347ca98f3a7934b124553028389c9
MD5 e730580950f39687386effc561a2a351
BLAKE2b-256 02107d85ce29cbfa18bd99794c65bb74b96fd77780426f168b9b804b55a74ccd

See more details on using hashes here.

File details

Details for the file cdm_lite-0.3.1a2-py3-none-any.whl.

File metadata

  • Download URL: cdm_lite-0.3.1a2-py3-none-any.whl
  • Upload date:
  • Size: 23.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cdm_lite-0.3.1a2-py3-none-any.whl
Algorithm Hash digest
SHA256 040d253d5bc384120724220a95f3f381c7a8ee86541636c8407ec6d34ddc4e5f
MD5 b599a41f6d5d69a80bd4ae9d20a645b9
BLAKE2b-256 82987e3f4b4e920496d5994942e5d441bbf272df9beec73327c55e93aa5fcc80

See more details on using hashes here.

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