Skip to main content

Frequenz Gridpool Library

Build Status PyPI Package Docs

Introduction

High-level interface to gridpools for the Frequenz platform.

Market topology configuration

Market topology is stored under the assets namespace. A relation names at least two of a gridpool, microgrid and market location:

assets.microgrids.241.meta.microgrid_id = 241

assets.market_locations.10208446344.id = "10208446344"

assets.relations.G80M241L10208446344.gridpool_id = 80
assets.relations.G80M241L10208446344.microgrid_id = 241
assets.relations.G80M241L10208446344.market_location_id = "10208446344"
assets.relations.G80M241L10208446344.delivery_area.code = "10YDE-RWENET---I"
assets.relations.G80M241L10208446344.validity.trading.participation = "ENERGY_TRADING"
assets.relations.G80M241L10208446344.validity.trading.start = 2026-01-01T00:00:00Z

A relation naming a gridpool requires a delivery area. A gridpool-free relation must link a microgrid and market location, and may carry a delivery area for a direct market-location-to-area mapping. Omitted market-location types default to MALO_ID; omitted market areas default to 101 (EU_DE).

A delivery area is a code and a code_type that defaults to EIC, so an EIC area is just delivery_area.code = "...". EIC codes are checked for format and check character, not registration with an EIC issuing office; other code types are taken as given. One code is bound to a single code type across a document.

Validity periods are half-open: the start is inclusive, the end exclusive, and an omitted bound is open. Bounds and query instants must include a UTC offset.

Load one or more files and query the merged document with:

from datetime import datetime, timezone
from pathlib import Path

from frequenz.gridpool.config import AssetsConfig

config = AssetsConfig.load_from_files(
    [Path("topology.toml"), Path("topology-overrides.toml")]
)
relations = config.find_relations(
    microgrid_id=241,
    at=datetime(2026, 1, 15, tzinfo=timezone.utc),
)

Later files override individual fields from earlier files. The projections find_delivery_areas, find_market_locations and find_microgrids accept filters for the other relation sides and an instant. find_delivery_areas returns each area with its code and code type; a delivery-area filter takes either a bare code or a full delivery area matched on its code type.

Market locations are keyed by raw ID, so the same raw ID cannot be used in several market areas within one document.

Supported Platforms

The following platforms are officially supported (tested):

  • Python: 3.11
  • Operating System: Ubuntu Linux 20.04
  • Architectures: amd64, arm64

CLI

This package ships the gridpool-cli command with three subcommands.

Setup

Set the Assets API credentials before running the CLI:

export ASSETS_API_URL="grpc://..."
export ASSETS_API_AUTH_KEY="..."
export ASSETS_API_SIGN_SECRET="..."

Print component formulas

gridpool-cli print-formulas <microgrid_id>

Optional prefix formatting:

gridpool-cli print-formulas <microgrid_id> --prefix "{microgrid_id}.{component}"

The per-category formulas (pv, battery, chp, ev) read the component first and use the meter as the fallback. Use --prefer-meters-in-component-formulas for the opposite order, which is what versions before component graph v0.5.0 produced:

gridpool-cli print-formulas <microgrid_id> --prefer-meters-in-component-formulas

Render component graph

Rendering requires optional dependencies. Install with:

pip install frequenz-gridpool[render-graph]
gridpool-cli render-graph <microgrid_id>

To save without opening a window:

gridpool-cli render-graph <microgrid_id> --no-show --output component_graph.png

Generate microgrid config

Derive metadata, formulas and component IDs for one or more microgrids from the Assets API and print them as dotted-key TOML to stdout:

gridpool-cli generate-config <microgrid_id> [<microgrid_id> ...]

Redirect stdout to save the result:

gridpool-cli generate-config <microgrid_id> > microgrid.toml

This command emits only microgrid entries. Topology relations, including their delivery-area codes, and market-location entries from input files are not included in its stdout output.

You can layer existing microgrid config files with the Assets API by precedence (--default < Assets API < --override). Values from a --default file are overridden by the API, while a --override file keeps its own values and the API only fills the gaps:

gridpool-cli generate-config <microgrid_id> \
    --default defaults.toml \
    --override overrides.toml > microgrid.toml

If no microgrid IDs are given, they are taken from the microgrid entries in the supplied files:

gridpool-cli generate-config --override existing.toml > microgrid.toml

--prefer-meters-in-component-formulas works here too, so a regenerated config can keep the meter-first order of the per-category formulas:

gridpool-cli generate-config <microgrid_id> \
    --prefer-meters-in-component-formulas > microgrid.toml

Contributing

If you want to know how to build this project and contribute to it, please check out the Contributing Guide.

Metadata

Release files for frequenz-gridpool 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for frequenz-gridpool 0.7.0
File Size Uploaded
frequenz_gridpool-0.7.0.tar.gz 36.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for frequenz-gridpool 0.7.0
File Interpreter ABI Platform
frequenz_gridpool-0.7.0-py3-none-any.whl Python 3 none any Details

Total release size: 71.5 kB

Release files / frequenz_gridpool-0.7.0.tar.gz

Download URL frequenz_gridpool-0.7.0.tar.gz
Size 36.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b3a16dea0938a59eda22acee2336d09b79aa1b28be662e1d240969ba752724e0
BLAKE2b-256 checksum
How to use checksums
916324681971c4207426fa69ac729d6eb654440477e82ae767dbde225e4cfecd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.

Transparency log

Release files / frequenz_gridpool-0.7.0-py3-none-any.whl

Download URL frequenz_gridpool-0.7.0-py3-none-any.whl
Size 35.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
06ab88a444c432b08cfb3b06404a86b1ea4e499a69fc109d2589b3e2a5b22447
BLAKE2b-256 checksum
How to use checksums
bd8b8ea837c56bda81a9885b183ac565d3d6b30cf70e871b5aec964e464bfd2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.

Transparency log

Release history Release notifications | RSS feed

0.8.0

2 release files

0.7.1

2 release files

This release

0.7.0 This release

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.5

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page