Skip to main content

CIMHub Core Library — shared foundation for all CIMHub converter packages

Project description

cimhub_core

Shared foundation for all CIMHub converter packages. Provides the base classes, data model, and utilities that every spoke in the hub-and-spoke architecture depends on.

What's in here

Module Purpose
base.py ABCs: FormatReader, FormatWriter, FormatImporter, FormatExporter
graph_model.py GraphModel — typed in-memory store for LinkML dataclasses
registry.py ConverterRegistry — decorator-based dispatch for import/export functions
scaffold.py Code generator that scaffolds a new converter package from a template
serialization.py Shared serialization helpers (CSV, YAML round-trips)
connectivity/ Topology helpers (bus lookups, connectivity node resolution)
transformations/ CIM-to-CIM geometry transforms (wire spacings, coordinate systems)
get_utils/ get_or_create helpers for common CIM objects (BaseVoltage, Substation, etc.)
mcp/ MCP server tools for LLM-assisted model introspection

Architecture

Every CIMHub converter follows the same four-layer pipeline:

LinkML YAML schemas   →   Generated dataclasses   →   GraphModel   →   FormatReader / FormatWriter
                                                            ↕
                                                    FormatImporter / FormatExporter
                                                    (native ↔ CIM conversion)

cimhub_core owns the bottom two layers (GraphModel + ABCs). Each spoke package owns its own LinkML schema, generated dataclasses, and converter implementations.

GraphModel

The central data container. A sorted dictionary keyed by class then by identifier.

from cimhub_core import GraphModel

model = GraphModel()
model.add_to_graph(obj)

# Retrieve all objects of a class (sorted by identifier)
buses = model.list_by_class(schema.BusRecord)

# Search by attribute value
gen = model.find_by_attribute(schema.GeneratorRecord, "bus_number", 101)

# Counts and membership
model.count(schema.BusRecord)
schema.BusRecord in model
len(model)

Converter ABCs

from cimhub_core import FormatImporter, FormatExporter

class MyImporter(FormatImporter):
    def to_cim(self, source, **kwargs):
        ...

class MyExporter(FormatExporter):
    def to_format(self, cim_model, **kwargs):
        ...

See cimhub_core/src/cimhub_core/development/CONVERTER_API.md for the full contract.

Development Docs

The development/ directory contains the canonical references for all converter authors:

Doc What it covers
CONVERTER_API.md Public API every converter must expose
READER_WRITER_GUIDE.md FormatReader / FormatWriter implementation guide
LINKML_TEMPLATE.md How to write LinkML schemas for native formats
UNITS.md CIMUnit usage — never manually multiply by 1e3/1e6
STYLE_GUIDE.md Coding rules (KISS → DRY → Readable → Maintainable)
ARCHITECTURE.md Full sub-package architecture diagram
TEST_FIXTURE_ARCHITECTURE.md 4-tier test strategy
CONDUCTOR_GEOMETRY_ANTI_PATTERNS.md Line/cable geometry export rules

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

cimhub_core-2.0.0a1.tar.gz (50.0 kB view details)

Uploaded Source

Built Distribution

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

cimhub_core-2.0.0a1-py3-none-any.whl (60.5 kB view details)

Uploaded Python 3

File details

Details for the file cimhub_core-2.0.0a1.tar.gz.

File metadata

  • Download URL: cimhub_core-2.0.0a1.tar.gz
  • Upload date:
  • Size: 50.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cimhub_core-2.0.0a1.tar.gz
Algorithm Hash digest
SHA256 2ce65b3bc6a85a906526a52a9e19e9099470b031b61b9ad46fe5715c2db3252f
MD5 79e3bf8f185fa5560234ef3adb2ba3f2
BLAKE2b-256 c4dcf737958553ecc4d65981af3d5203ca7da53ee32e22c78746cc09c47bbd24

See more details on using hashes here.

Provenance

The following attestation bundles were made for cimhub_core-2.0.0a1.tar.gz:

Publisher: publish-cimhub-core.yml on PNNL-CIM-Tools/CIMHub

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

File details

Details for the file cimhub_core-2.0.0a1-py3-none-any.whl.

File metadata

  • Download URL: cimhub_core-2.0.0a1-py3-none-any.whl
  • Upload date:
  • Size: 60.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cimhub_core-2.0.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 cec102779a7e01f0f703407c36d77e12543ddf03669027ba74aa154ecdbe0e74
MD5 7746b2eaa7499bd1b0f564b039bb76b4
BLAKE2b-256 f22377bcbd432bbe68473391e8e38d42b82a2fecc3b1c0366247fcd1be226824

See more details on using hashes here.

Provenance

The following attestation bundles were made for cimhub_core-2.0.0a1-py3-none-any.whl:

Publisher: publish-cimhub-core.yml on PNNL-CIM-Tools/CIMHub

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