Add market topology to the config model - #126
Open
cwasicki wants to merge 2 commits into
Open
Conversation
The public surface is the config package, re-exported through its `__init__`; the implementation modules take a leading underscore to match `_graph_generator`, starting with `microgrid` and `load`. Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com>
Describe market topology under `assets.relations`, mirroring the Assets API `MarketTopologyRelation`: each record links at least two of a gridpool, a microgrid and a market location, filed under a `g<>m<>l<>` key derived from its own sides. A gridpool relation carries its `delivery_area`, and its validity lives in `validity`, each entry a half-open `datetime` period, with a market use case telling a gridpool's participations apart. Market locations and delivery areas are self-describing entries under `assets.market_locations` and `assets.delivery_areas`, each carrying its own identifier and how to read it, checked against the key it is filed under. `AssetsConfig` answers the common lookups with `find_relations` and the projections `find_delivery_areas`, `find_market_locations` and `find_microgrids`. `load_assets_from_files` layers several files into one document, merging the raw tables so an override keeps fields it leaves unset. Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com>
cwasicki
requested review from
cyiallou and
llucax
and removed request for
a team
August 21, 2026 17:53
cwasicki
requested review from
Mohammad-Tayyab-Frequenz and
phillip-wenig-frequenz
August 21, 2026 17:53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a data model for market topology under the
assetsconfig namespace, based on the Assets APIMarketTopologyRelation, plus query helpers. The config extends the API model with plain relation-validity periods and delivery-area mappings on gridpool-free relations. It also makes the config package's implementation modules private.Model
assets.relations: each record links at least two of a gridpool, microgrid and market location, filed under aG<>M<>L<>key derived from its own fields. Nothing is read from the key;check()verifies that the key and fields agree.delivery_area. A gridpool-to-microgrid relation therefore carries one even without a market location. Gridpool-free microgrid-to-market-location relations may also carry one for direct mappings.validity: each entry is a half-open[start, end)datetimeperiod. A period may name a market use case (participation) for a gridpool relation, while a plain period describes relation validity without distinguishing a use case.assets.market_locations: self-describing entries carrying their identifier, identifier scheme (MALO_IDby default), and Assets API market area (101,EU_DE, by default). Raw market-location IDs remain document-wide keys, so the same ID cannot occur in several market areas.Time-varying enterprise ownership is outside this change;
Metadata.enterprise_idremains a scalar field.Read API
AssetsConfiganswers the common lookups:find_relations(...)returns relations matching all supplied sides, use case and instant.find_delivery_areas(...),find_market_locations(...)andfind_microgrids(...)return deduplicated projections filtered by the other dimensions.load_assets_from_fileslayers several files into one document, merging raw TOML tables before loading so an override keeps fields it leaves unset.Refactor
The config package's implementation modules are made private with leading underscores, matching
_graph_generator; the public surface remains the package__init__. This is split into its own commit.Breaking changes
Metadata.delivery_areais removed; delivery areas are read from topology relations.Metadata.gid, if set, must be their sole gridpool ID. Omit it when the microgrid participates in several gridpools.load_configs_from_filesnow layers files field by field. Values omitted by a later file remain and cannot be removed by omission.frequenz.gridpool.config.microgrid,.loadand.assetsbreak; import public names fromfrequenz.gridpool.config.See
RELEASE_NOTES.mdfor the full upgrading notes.Follow-ups
int:AssetsConfig.microgridsand theload_configs*return types remainstr-keyed while relations use integer IDs. Normalising these is a separate follow-up PR.assets.market_locationsentries not referenced by any relation through a dedicated query remains open.