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.0a0.tar.gz (49.7 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.0a0-py3-none-any.whl (60.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cimhub_core-2.0.0a0.tar.gz
  • Upload date:
  • Size: 49.7 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.0a0.tar.gz
Algorithm Hash digest
SHA256 4eb7edeff747614172cb879af0b3026bb1dfad5a3793984f4bd0316edfc340cb
MD5 6b1cdf7ac95bcc7a7e33661350a420a2
BLAKE2b-256 cddadba7b513988b82fca48097b5f4389b76748877dd8c0ad866f14485e317d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for cimhub_core-2.0.0a0.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.0a0-py3-none-any.whl.

File metadata

  • Download URL: cimhub_core-2.0.0a0-py3-none-any.whl
  • Upload date:
  • Size: 60.1 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.0a0-py3-none-any.whl
Algorithm Hash digest
SHA256 d99e097f67e2b6649fa7f2c460672c881f9d16b44a3502599f16c4c325b4346a
MD5 154d5e94911f2b8f65efbabe07d9ec1e
BLAKE2b-256 70e33f75276a9cb089b6db7a454c50a4e627e52f88520384bcd2021683f148eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for cimhub_core-2.0.0a0-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