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.0a1.tar.gz (16.4 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.0a1-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

Details for the file cdm_lite-0.3.0a1.tar.gz.

File metadata

  • Download URL: cdm_lite-0.3.0a1.tar.gz
  • Upload date:
  • Size: 16.4 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.0a1.tar.gz
Algorithm Hash digest
SHA256 826884ea97832b47116ee8946b833c89b5fc80cf82372aa9092276d33b1ca951
MD5 6d7475eec3fd6afbc54aaa9547b0ccd1
BLAKE2b-256 4d3da579edb6833f82510e88f2c5bf75e615ba1e62f0ab6352f6cfb5cc262bc1

See more details on using hashes here.

File details

Details for the file cdm_lite-0.3.0a1-py3-none-any.whl.

File metadata

  • Download URL: cdm_lite-0.3.0a1-py3-none-any.whl
  • Upload date:
  • Size: 23.0 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.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 5c6d964f00fd2497a80dad1938b47ed60197cc4aeabddd2eb71f6c903d40d55d
MD5 08d35e12a72b48a9283cee2061d37680
BLAKE2b-256 61c76728ef1d9652c17c2a84e4cf3a10462f329a7ceed1ccecc551b7d6c15122

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