Electric Barometer · Contracts (eb-contracts)
Data contract and validation layer for the Electric Barometer ecosystem, defining canonical schemas, semantics, and enforcement for forecasts, costs, results, and run context.
Overview
eb-contracts defines versioned schemas and validators for demand panels, forecasts, costs, and run context. It enforces shared structure and semantics; it does not compute metrics or train models.
Installation
eb-contracts is distributed as a standard Python package.
pip install eb-contracts
Core Concepts
-
Canonical data contracts — Core data artifacts (forecasts, cost specifications, results, and context) are represented using explicit, versioned schemas rather than implicit conventions or ad-hoc DataFrame shapes.
-
Semantic consistency — Column names, units, grain, and meaning are standardized and enforced so that downstream systems can rely on shared interpretation rather than contextual knowledge or undocumented assumptions.
-
Validation as a boundary — Contract validation establishes a clear boundary between “valid” and “invalid” data, preventing silent failures and making structural issues visible at ingestion time rather than during downstream computation.
-
Versioned evolution — Contracts are versioned to allow schemas and semantics to evolve over time without breaking existing consumers, enabling forward progress while preserving backward compatibility.
-
Explicit migration — Adaptation from external or legacy data formats into contract-compliant artifacts is performed through explicit migration utilities, avoiding implicit coercion or guesswork.
-
Separation of structure from logic — Data shape and meaning are defined independently of metric computation, optimization, or execution logic, ensuring that structural correctness is not entangled with algorithmic behavior.
Minimal Example
The example below illustrates a typical contract workflow using eb-contracts: adapting an external forecast frame into a canonical contract artifact and validating it at the system boundary.
import pandas as pd
from eb_contracts import set_validation_mode
from eb_contracts.api import PanelPointColumns, to_panel_point_v1
raw = pd.DataFrame(
{
"store": ["A", "A"],
"timestamp": [
pd.Timestamp("2025-01-01 00:00:00"),
pd.Timestamp("2025-01-01 00:30:00"),
],
"actual": [10.0, 12.0],
"forecast": [11.0, 13.0],
}
)
columns = PanelPointColumns(
entity_id="store",
interval_start="timestamp",
y_true="actual",
y_pred="forecast",
)
with set_validation_mode("strict"):
forecast = to_panel_point_v1(raw, columns=columns)
print(type(forecast))
License
BSD 3-Clause License. © 2026 Kyle Corrie.
Metadata
Release files for eb-contracts 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| eb_contracts-0.2.3.tar.gz | 28.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| eb_contracts-0.2.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 64.1 kB
Release files / eb_contracts-0.2.3.tar.gz
| Download URL | eb_contracts-0.2.3.tar.gz |
|---|---|
| Size | 28.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1cad2e9defd5b1a7f9e4b804dd4723cdf89f17f59b339602ec3de7628197a24e
|
|
BLAKE2b-256 checksum How to use checksums |
fbde500fbc9b4efe002cffceb59bb4f51d3865e20e8d4b9fdb5ef600fc8771b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / eb_contracts-0.2.3-py3-none-any.whl
| Download URL | eb_contracts-0.2.3-py3-none-any.whl |
|---|---|
| Size | 35.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
75a1b41f6b0989f429816d9947aec91b918c19c63b40edee22279e1a4facb8f2
|
|
BLAKE2b-256 checksum How to use checksums |
6a54ad94535d2761dc00b8b278b02ab455735d8195ad51decb98a2b012aa2ab2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|