Skip to main content

cimoxide

Python bindings for cimoxide, a Rust toolkit for ENTSO-E CGMES (Common Grid Model Exchange Standard) power system data. This package wraps the Rust decoder and SHACL/SPARQL validator (via PyO3) to give you fast RDF/XML parsing and CGMES conformance validation from Python, with no Rust toolchain required at install time.

Install

pip install cimoxide

Prebuilt wheels are published for common platforms; if none match your environment, pip will need a Rust toolchain and maturin to build from source.

Quick start

import cimoxide

# Parse one or more CGMES RDF/XML files into a single merged dataset.
ds = cimoxide.decode_files([
    "RealGrid_EQ.xml",
    "RealGrid_SSH.xml",
    "RealGrid_TP.xml",
    "RealGrid_SV.xml",
])

len(ds)                       # total number of elements
ds.by_type()                  # {"ACLineSegment": [mrid, ...], ...} — no deserialization
ds.get_type("ACLineSegment")  # [{"_type": "ACLineSegment", "r": 0.12, ...}, ...]

for mrid in ds:
    obj = ds[mrid]             # dict, e.g. {"_type": "BusbarSection", "name": "...", ...}

Each element is a plain Python dict with a "_type" key (the CIM class name) plus one key per populated attribute, snake_case, matching the JSON serialization of the underlying Rust structs. Reference fields (MRID associations) are plain MRID strings.

Validation

violations = cimoxide.validate_files(
    ["RealGrid_EQ.xml", "RealGrid_SSH.xml"],
    profiles=["EQ", "SSH"],   # optional; auto-detected if omitted
)

for v in violations:
    print(v.severity, v.rule_id, v.message, v.object_id)

validate_files runs two-phase validation: per-profile SHACL/SPARQL checks against each file individually, then cross-profile checks on the merged dataset. See the validate_files docstring for the full parameter list (solved, common, quality, silence).

API surface

Function / method Description
cimoxide.decode_file(path) Parse a single RDF/XML file.
cimoxide.decode_files(paths) Parse and merge multiple RDF/XML files.
cimoxide.decode_str(content) Parse RDF/XML from a string.
cimoxide.validate_files(paths, ...) Two-phase SHACL/SPARQL validation, returns list[Violation].
CimDataset.merge(other) Merge another dataset into this one (other becomes empty).
CimDataset.drop_blocks() Free internal parse buffers after the final merge.
CimDataset[mrid] / .get(mrid) Fetch one element as a dict (KeyError / None if missing).
CimDataset.mrids() / iter(ds) / len(ds) Enumerate or count MRIDs.
CimDataset.by_type() dict[str, list[mrid]] type index, no deserialization.
CimDataset.get_type(name) All element dicts for one CIM class.
CimDataset.entries() All entries as dict[mrid, dict] (deserializes everything).

Full type stubs with per-method docstrings are in python/cimoxide/__init__.pyi and python/cimoxide/types.pyi (generated TypedDict per CIM class, for editor autocomplete on the returned dicts).

Examples

examples/example_counts.py decodes the RealGrid test configuration and prints an element count per CIM type:

python examples/example_counts.py

(Requires the CGMES-Test-Configurations submodule checked out at the repo root — see "Development" below.)

Tests

The test suite decodes and validates the CGMES fixture files checked into the parent repository's testdata/ directory:

pip install pytest
pytest tests/
  • tests/test_decode.py — round-trip decode tests (decode_file/decode_str/decode_files, indexing, iteration).
  • tests/test_api.py — dataset API contract tests (merge, drop_blocks, error handling).
  • tests/test_validate.pyvalidate_files behavior (profile filtering, silence, quality/common flags, Violation fields).

Development

This package is built from the cimoxide monorepo, where cimoxide-py lives alongside the Rust crates it binds (cimdecoder, cimstructs, cimvalidation). To build it from source:

git clone --recurse-submodules https://github.com/m-mirz/cimoxide.git
cd cimoxide
pip install maturin
cd cimoxide-py
maturin develop --release   # editable install into the active virtualenv
pytest tests/

See the repository README for the full project layout, the code generator, and the Rust CLI.

License

Apache-2.0

Download files

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

Source Distribution

cimoxide-0.0.5.tar.gz (852.3 kB view details)

Uploaded Source

Built Distributions

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

cimoxide-0.0.5-cp39-abi3-win_amd64.whl (7.9 MB view details)

Uploaded CPython 3.9+Windows x86-64

cimoxide-0.0.5-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.6 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

cimoxide-0.0.5-cp39-abi3-macosx_11_0_arm64.whl (6.1 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

File details

Details for the file cimoxide-0.0.5.tar.gz.

File metadata

  • Download URL: cimoxide-0.0.5.tar.gz
  • Upload date:
  • Size: 852.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cimoxide-0.0.5.tar.gz
Algorithm Hash digest
SHA256 53a99edd82437e6c052d960ee3603601dfa145b17a2d23666a81064a1850a07e
MD5 1382cfc883974867dd1c04c236a2fe1c
BLAKE2b-256 e236b6f5e5eeec4e4e456fdb6b07f74eb80a201f778116d4152780dff2ce8b61

See more details on using hashes here.

Provenance

The following attestation bundles were made for cimoxide-0.0.5.tar.gz:

Publisher: pypi.yml on m-mirz/cimoxide

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

File details

Details for the file cimoxide-0.0.5-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: cimoxide-0.0.5-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 7.9 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cimoxide-0.0.5-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 4673a390a15784b9433b987efafbf89803d5c3cd3c50a12380275fbf7b415329
MD5 6811529febd7f041e1089d65bc02c0d2
BLAKE2b-256 382a41c5992b2fdff23124eafb5249a902dceb3261cb676a532ef9db51675eed

See more details on using hashes here.

Provenance

The following attestation bundles were made for cimoxide-0.0.5-cp39-abi3-win_amd64.whl:

Publisher: pypi.yml on m-mirz/cimoxide

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

File details

Details for the file cimoxide-0.0.5-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cimoxide-0.0.5-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 075af6eee9c8ec4bf3a572e3ff24d723a41c0dd275b67c5b395ae1f57907793a
MD5 c554520ebb68fc90bbcbb31e075f1ac7
BLAKE2b-256 efe4fe40fd8a5278360a9e26e62e030af140190ebdda21b64d2d49092c73a84e

See more details on using hashes here.

Provenance

The following attestation bundles were made for cimoxide-0.0.5-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: pypi.yml on m-mirz/cimoxide

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

File details

Details for the file cimoxide-0.0.5-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cimoxide-0.0.5-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6de5f4d83ddcfb470b0a748797efd00e445d05476a57a8735a21c0332b7cc5da
MD5 f01e258845f18f349fd8f1094f2e55c3
BLAKE2b-256 f6e1a501e52cb29e29ad87166b9b5cac9bd30f74099c4428660ab4579de0c581

See more details on using hashes here.

Provenance

The following attestation bundles were made for cimoxide-0.0.5-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: pypi.yml on m-mirz/cimoxide

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 Sentry Error logging StatusPage Status page