frequenz-gridpool 0.6.4__tar.gz → 0.7.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. {frequenz_gridpool-0.6.4/src/frequenz_gridpool.egg-info → frequenz_gridpool-0.7.1}/PKG-INFO +91 -6
  2. frequenz_gridpool-0.7.1/README.md +202 -0
  3. frequenz_gridpool-0.7.1/RELEASE_NOTES.md +42 -0
  4. {frequenz_gridpool-0.6.4 → frequenz_gridpool-0.7.1}/pyproject.toml +1 -0
  5. {frequenz_gridpool-0.6.4 → frequenz_gridpool-0.7.1}/src/frequenz/gridpool/__init__.py +0 -16
  6. {frequenz_gridpool-0.6.4 → frequenz_gridpool-0.7.1}/src/frequenz/gridpool/cli/__main__.py +150 -54
  7. {frequenz_gridpool-0.6.4 → frequenz_gridpool-0.7.1}/src/frequenz/gridpool/cli/_dump_config.py +16 -11
  8. {frequenz_gridpool-0.6.4 → frequenz_gridpool-0.7.1}/src/frequenz/gridpool/cli/_patch_config.py +68 -23
  9. {frequenz_gridpool-0.6.4 → frequenz_gridpool-0.7.1}/src/frequenz/gridpool/config/__init__.py +17 -15
  10. frequenz_gridpool-0.7.1/src/frequenz/gridpool/config/_assets.py +500 -0
  11. frequenz_gridpool-0.7.1/src/frequenz/gridpool/config/_gridpool.py +17 -0
  12. frequenz_gridpool-0.6.4/src/frequenz/gridpool/config/load.py → frequenz_gridpool-0.7.1/src/frequenz/gridpool/config/_load.py +54 -89
  13. frequenz_gridpool-0.6.4/src/frequenz/gridpool/config/microgrid.py → frequenz_gridpool-0.7.1/src/frequenz/gridpool/config/_microgrid.py +8 -161
  14. frequenz_gridpool-0.7.1/src/frequenz/gridpool/config/_migrations.py +139 -0
  15. frequenz_gridpool-0.7.1/src/frequenz/gridpool/config/_topology.py +377 -0
  16. {frequenz_gridpool-0.6.4 → frequenz_gridpool-0.7.1/src/frequenz_gridpool.egg-info}/PKG-INFO +91 -6
  17. {frequenz_gridpool-0.6.4 → frequenz_gridpool-0.7.1}/src/frequenz_gridpool.egg-info/SOURCES.txt +6 -2
  18. {frequenz_gridpool-0.6.4 → frequenz_gridpool-0.7.1}/src/frequenz_gridpool.egg-info/scm_file_list.json +9 -3
  19. frequenz_gridpool-0.7.1/src/frequenz_gridpool.egg-info/scm_version.json +8 -0
  20. frequenz_gridpool-0.6.4/README.md +0 -117
  21. frequenz_gridpool-0.6.4/RELEASE_NOTES.md +0 -28
  22. frequenz_gridpool-0.6.4/src/frequenz_gridpool.egg-info/scm_version.json +0 -8
  23. {frequenz_gridpool-0.6.4 → frequenz_gridpool-0.7.1}/LICENSE +0 -0
  24. {frequenz_gridpool-0.6.4 → frequenz_gridpool-0.7.1}/MANIFEST.in +0 -0
  25. {frequenz_gridpool-0.6.4 → frequenz_gridpool-0.7.1}/setup.cfg +0 -0
  26. {frequenz_gridpool-0.6.4 → frequenz_gridpool-0.7.1}/src/frequenz/gridpool/_graph_generator.py +0 -0
  27. {frequenz_gridpool-0.6.4 → frequenz_gridpool-0.7.1}/src/frequenz/gridpool/cli/__init__.py +0 -0
  28. {frequenz_gridpool-0.6.4 → frequenz_gridpool-0.7.1}/src/frequenz/gridpool/cli/_render_graph.py +0 -0
  29. {frequenz_gridpool-0.6.4 → frequenz_gridpool-0.7.1}/src/frequenz/gridpool/conftest.py +0 -0
  30. {frequenz_gridpool-0.6.4 → frequenz_gridpool-0.7.1}/src/frequenz/gridpool/py.typed +0 -0
  31. {frequenz_gridpool-0.6.4 → frequenz_gridpool-0.7.1}/src/frequenz_gridpool.egg-info/dependency_links.txt +0 -0
  32. {frequenz_gridpool-0.6.4 → frequenz_gridpool-0.7.1}/src/frequenz_gridpool.egg-info/entry_points.txt +0 -0
  33. {frequenz_gridpool-0.6.4 → frequenz_gridpool-0.7.1}/src/frequenz_gridpool.egg-info/requires.txt +0 -0
  34. {frequenz_gridpool-0.6.4 → frequenz_gridpool-0.7.1}/src/frequenz_gridpool.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: frequenz-gridpool
3
- Version: 0.6.4
3
+ Version: 0.7.1
4
4
  Summary: High-level interface to grid pools for the Frequenz platform.
5
5
  Author-email: Frequenz Energy-as-a-Service GmbH <floss@frequenz.com>
6
6
  License-Expression: MIT
@@ -81,9 +81,64 @@ Dynamic: license-file
81
81
 
82
82
  ## Introduction
83
83
 
84
- High-level interface to grid pools for the Frequenz platform.
84
+ High-level interface to gridpools for the Frequenz platform.
85
85
 
86
- TODO(cookiecutter): Improve the README file
86
+ ## Market topology configuration
87
+
88
+ Market topology is stored under the `assets` namespace. A relation names at
89
+ least two of a gridpool, microgrid and market location:
90
+
91
+ ```toml
92
+ assets.microgrids.241.meta.microgrid_id = 241
93
+
94
+ assets.market_locations.10208446344.id = "10208446344"
95
+
96
+ assets.relations.G80M241L10208446344.gridpool_id = 80
97
+ assets.relations.G80M241L10208446344.microgrid_id = 241
98
+ assets.relations.G80M241L10208446344.market_location_id = "10208446344"
99
+ assets.relations.G80M241L10208446344.delivery_area.code = "10YDE-RWENET---I"
100
+ assets.relations.G80M241L10208446344.validity.trading.participation = "ENERGY_TRADING"
101
+ assets.relations.G80M241L10208446344.validity.trading.start = 2026-01-01T00:00:00Z
102
+ ```
103
+
104
+ A relation naming a gridpool requires a delivery area. A gridpool-free relation
105
+ must link a microgrid and market location, and may carry a delivery area for a
106
+ direct market-location-to-area mapping. Omitted market-location types default
107
+ to `MALO_ID`; omitted market areas default to `101` (`EU_DE`).
108
+
109
+ A delivery area is a `code` and a `code_type` that defaults to EIC, so an EIC
110
+ area is just `delivery_area.code = "..."`. EIC codes are checked for format and
111
+ check character, not registration with an EIC issuing office; other code types
112
+ are taken as given. One code is bound to a single code type across a document.
113
+
114
+ Validity periods are half-open: the start is inclusive, the end exclusive, and
115
+ an omitted bound is open. Bounds and query instants must include a UTC offset.
116
+
117
+ Load one or more files and query the merged document with:
118
+
119
+ ```python
120
+ from datetime import datetime, timezone
121
+ from pathlib import Path
122
+
123
+ from frequenz.gridpool.config import AssetsConfig
124
+
125
+ config = AssetsConfig.load_from_files(
126
+ [Path("topology.toml"), Path("topology-overrides.toml")]
127
+ )
128
+ relations = config.find_relations(
129
+ microgrid_id=241,
130
+ at=datetime(2026, 1, 15, tzinfo=timezone.utc),
131
+ )
132
+ ```
133
+
134
+ Later files override individual fields from earlier files. The projections
135
+ `find_delivery_areas`, `find_market_locations` and `find_microgrids` accept
136
+ filters for the other relation sides and an instant. `find_delivery_areas`
137
+ returns each area with its code and code type; a delivery-area filter takes
138
+ either a bare code or a full delivery area matched on its code type.
139
+
140
+ Market locations are keyed by raw ID, so the same raw ID cannot be used in
141
+ several market areas within one document.
87
142
 
88
143
  ## Supported Platforms
89
144
 
@@ -95,7 +150,7 @@ The following platforms are officially supported (tested):
95
150
 
96
151
  ## CLI
97
152
 
98
- This package ships the `gridpool-cli` command with three subcommands.
153
+ This package ships the `gridpool-cli` command with five subcommands.
99
154
 
100
155
  ### Setup
101
156
 
@@ -107,6 +162,9 @@ export ASSETS_API_AUTH_KEY="..."
107
162
  export ASSETS_API_SIGN_SECRET="..."
108
163
  ```
109
164
 
165
+ `FREQUENZ_API_KEY` and `FREQUENZ_API_SECRET` are accepted as fallbacks for
166
+ `ASSETS_API_AUTH_KEY` and `ASSETS_API_SIGN_SECRET`.
167
+
110
168
  ### Print component formulas
111
169
 
112
170
  ```bash
@@ -161,7 +219,11 @@ Redirect stdout to save the result:
161
219
  gridpool-cli generate-config <microgrid_id> > microgrid.toml
162
220
  ```
163
221
 
164
- You can layer existing config files with the Assets API by precedence
222
+ This command emits only microgrid entries. Topology relations, including their
223
+ delivery-area codes, and market-location entries from input files are not
224
+ included in its stdout output.
225
+
226
+ You can layer existing microgrid config files with the Assets API by precedence
165
227
  (`--default` < Assets API < `--override`). Values from a `--default` file are
166
228
  overridden by the API, while a `--override` file keeps its own values and the
167
229
  API only fills the gaps:
@@ -172,7 +234,8 @@ gridpool-cli generate-config <microgrid_id> \
172
234
  --override overrides.toml > microgrid.toml
173
235
  ```
174
236
 
175
- If no microgrid IDs are given, they are taken from the supplied files:
237
+ If no microgrid IDs are given, they are taken from the microgrid entries in the
238
+ supplied files:
176
239
 
177
240
  ```bash
178
241
  gridpool-cli generate-config --override existing.toml > microgrid.toml
@@ -186,6 +249,28 @@ gridpool-cli generate-config <microgrid_id> \
186
249
  --prefer-meters-in-component-formulas > microgrid.toml
187
250
  ```
188
251
 
252
+ ### Validate config files
253
+
254
+ Check config files offline, without contacting the Assets API, and exit
255
+ non-zero on the first error, to gate config-repo CI:
256
+
257
+ ```bash
258
+ gridpool-cli validate microgrid.toml [more.toml ...]
259
+ ```
260
+
261
+ Each file is validated on its own first, so every record names its own key and
262
+ required fields; the files are then validated merged, for the cross-record
263
+ checks.
264
+
265
+ ### Look up a gridpool's enterprise
266
+
267
+ Print the enterprise ID that owns a gridpool, read from the config files
268
+ (merged as one stack); exits non-zero if the gridpool is not declared:
269
+
270
+ ```bash
271
+ gridpool-cli find-enterprise <gridpool_id> config.toml [more.toml ...]
272
+ ```
273
+
189
274
  ## Contributing
190
275
 
191
276
  If you want to know how to build this project and contribute to it, please
@@ -0,0 +1,202 @@
1
+ # Frequenz Gridpool Library
2
+
3
+ [![Build Status](https://github.com/frequenz-floss/frequenz-gridpool-python/actions/workflows/ci.yaml/badge.svg)](https://github.com/frequenz-floss/frequenz-gridpool-python/actions/workflows/ci.yaml)
4
+ [![PyPI Package](https://img.shields.io/pypi/v/frequenz-gridpool)](https://pypi.org/project/frequenz-gridpool/)
5
+ [![Docs](https://img.shields.io/badge/docs-latest-informational)](https://frequenz-floss.github.io/frequenz-gridpool-python/)
6
+
7
+ ## Introduction
8
+
9
+ High-level interface to gridpools for the Frequenz platform.
10
+
11
+ ## Market topology configuration
12
+
13
+ Market topology is stored under the `assets` namespace. A relation names at
14
+ least two of a gridpool, microgrid and market location:
15
+
16
+ ```toml
17
+ assets.microgrids.241.meta.microgrid_id = 241
18
+
19
+ assets.market_locations.10208446344.id = "10208446344"
20
+
21
+ assets.relations.G80M241L10208446344.gridpool_id = 80
22
+ assets.relations.G80M241L10208446344.microgrid_id = 241
23
+ assets.relations.G80M241L10208446344.market_location_id = "10208446344"
24
+ assets.relations.G80M241L10208446344.delivery_area.code = "10YDE-RWENET---I"
25
+ assets.relations.G80M241L10208446344.validity.trading.participation = "ENERGY_TRADING"
26
+ assets.relations.G80M241L10208446344.validity.trading.start = 2026-01-01T00:00:00Z
27
+ ```
28
+
29
+ A relation naming a gridpool requires a delivery area. A gridpool-free relation
30
+ must link a microgrid and market location, and may carry a delivery area for a
31
+ direct market-location-to-area mapping. Omitted market-location types default
32
+ to `MALO_ID`; omitted market areas default to `101` (`EU_DE`).
33
+
34
+ A delivery area is a `code` and a `code_type` that defaults to EIC, so an EIC
35
+ area is just `delivery_area.code = "..."`. EIC codes are checked for format and
36
+ check character, not registration with an EIC issuing office; other code types
37
+ are taken as given. One code is bound to a single code type across a document.
38
+
39
+ Validity periods are half-open: the start is inclusive, the end exclusive, and
40
+ an omitted bound is open. Bounds and query instants must include a UTC offset.
41
+
42
+ Load one or more files and query the merged document with:
43
+
44
+ ```python
45
+ from datetime import datetime, timezone
46
+ from pathlib import Path
47
+
48
+ from frequenz.gridpool.config import AssetsConfig
49
+
50
+ config = AssetsConfig.load_from_files(
51
+ [Path("topology.toml"), Path("topology-overrides.toml")]
52
+ )
53
+ relations = config.find_relations(
54
+ microgrid_id=241,
55
+ at=datetime(2026, 1, 15, tzinfo=timezone.utc),
56
+ )
57
+ ```
58
+
59
+ Later files override individual fields from earlier files. The projections
60
+ `find_delivery_areas`, `find_market_locations` and `find_microgrids` accept
61
+ filters for the other relation sides and an instant. `find_delivery_areas`
62
+ returns each area with its code and code type; a delivery-area filter takes
63
+ either a bare code or a full delivery area matched on its code type.
64
+
65
+ Market locations are keyed by raw ID, so the same raw ID cannot be used in
66
+ several market areas within one document.
67
+
68
+ ## Supported Platforms
69
+
70
+ The following platforms are officially supported (tested):
71
+
72
+ - **Python:** 3.11
73
+ - **Operating System:** Ubuntu Linux 20.04
74
+ - **Architectures:** amd64, arm64
75
+
76
+ ## CLI
77
+
78
+ This package ships the `gridpool-cli` command with five subcommands.
79
+
80
+ ### Setup
81
+
82
+ Set the Assets API credentials before running the CLI:
83
+
84
+ ```bash
85
+ export ASSETS_API_URL="grpc://..."
86
+ export ASSETS_API_AUTH_KEY="..."
87
+ export ASSETS_API_SIGN_SECRET="..."
88
+ ```
89
+
90
+ `FREQUENZ_API_KEY` and `FREQUENZ_API_SECRET` are accepted as fallbacks for
91
+ `ASSETS_API_AUTH_KEY` and `ASSETS_API_SIGN_SECRET`.
92
+
93
+ ### Print component formulas
94
+
95
+ ```bash
96
+ gridpool-cli print-formulas <microgrid_id>
97
+ ```
98
+
99
+ Optional prefix formatting:
100
+
101
+ ```bash
102
+ gridpool-cli print-formulas <microgrid_id> --prefix "{microgrid_id}.{component}"
103
+ ```
104
+
105
+ The per-category formulas (`pv`, `battery`, `chp`, `ev`) read the component
106
+ first and use the meter as the fallback. Use
107
+ `--prefer-meters-in-component-formulas` for the opposite order, which is what
108
+ versions before component graph v0.5.0 produced:
109
+
110
+ ```bash
111
+ gridpool-cli print-formulas <microgrid_id> --prefer-meters-in-component-formulas
112
+ ```
113
+
114
+ ### Render component graph
115
+
116
+ Rendering requires optional dependencies. Install with:
117
+
118
+ ```bash
119
+ pip install frequenz-gridpool[render-graph]
120
+ ```
121
+
122
+ ```bash
123
+ gridpool-cli render-graph <microgrid_id>
124
+ ```
125
+
126
+ To save without opening a window:
127
+
128
+ ```bash
129
+ gridpool-cli render-graph <microgrid_id> --no-show --output component_graph.png
130
+ ```
131
+
132
+ ### Generate microgrid config
133
+
134
+ Derive metadata, formulas and component IDs for one or more microgrids from the
135
+ Assets API and print them as dotted-key TOML to stdout:
136
+
137
+ ```bash
138
+ gridpool-cli generate-config <microgrid_id> [<microgrid_id> ...]
139
+ ```
140
+
141
+ Redirect stdout to save the result:
142
+
143
+ ```bash
144
+ gridpool-cli generate-config <microgrid_id> > microgrid.toml
145
+ ```
146
+
147
+ This command emits only microgrid entries. Topology relations, including their
148
+ delivery-area codes, and market-location entries from input files are not
149
+ included in its stdout output.
150
+
151
+ You can layer existing microgrid config files with the Assets API by precedence
152
+ (`--default` < Assets API < `--override`). Values from a `--default` file are
153
+ overridden by the API, while a `--override` file keeps its own values and the
154
+ API only fills the gaps:
155
+
156
+ ```bash
157
+ gridpool-cli generate-config <microgrid_id> \
158
+ --default defaults.toml \
159
+ --override overrides.toml > microgrid.toml
160
+ ```
161
+
162
+ If no microgrid IDs are given, they are taken from the microgrid entries in the
163
+ supplied files:
164
+
165
+ ```bash
166
+ gridpool-cli generate-config --override existing.toml > microgrid.toml
167
+ ```
168
+
169
+ `--prefer-meters-in-component-formulas` works here too, so a regenerated
170
+ config can keep the meter-first order of the per-category formulas:
171
+
172
+ ```bash
173
+ gridpool-cli generate-config <microgrid_id> \
174
+ --prefer-meters-in-component-formulas > microgrid.toml
175
+ ```
176
+
177
+ ### Validate config files
178
+
179
+ Check config files offline, without contacting the Assets API, and exit
180
+ non-zero on the first error, to gate config-repo CI:
181
+
182
+ ```bash
183
+ gridpool-cli validate microgrid.toml [more.toml ...]
184
+ ```
185
+
186
+ Each file is validated on its own first, so every record names its own key and
187
+ required fields; the files are then validated merged, for the cross-record
188
+ checks.
189
+
190
+ ### Look up a gridpool's enterprise
191
+
192
+ Print the enterprise ID that owns a gridpool, read from the config files
193
+ (merged as one stack); exits non-zero if the gridpool is not declared:
194
+
195
+ ```bash
196
+ gridpool-cli find-enterprise <gridpool_id> config.toml [more.toml ...]
197
+ ```
198
+
199
+ ## Contributing
200
+
201
+ If you want to know how to build this project and contribute to it, please
202
+ check out the [Contributing Guide](CONTRIBUTING.md).
@@ -0,0 +1,42 @@
1
+ # Frequenz Gridpool Library Release Notes
2
+
3
+ ## Summary
4
+
5
+ This release rounds out `gridpool-cli` for the `assets` config layout and adds
6
+ gridpool enterprise ownership to the config model. The CLI can now generate,
7
+ validate, patch, and query merged config files.
8
+
9
+ ## Upgrading
10
+
11
+ - `generate-config` now writes the `assets.microgrids` layout and stamps
12
+ `assets.version`, instead of the legacy layout. Regenerate configs to get the
13
+ current format; generated files then load back without a migration.
14
+
15
+ - `generate-config --inplace` refuses legacy-layout files (top-level or
16
+ `meta`-nested), which it would duplicate rather than edit. Rebuild those from
17
+ scratch.
18
+
19
+ ## New Features
20
+
21
+ - `gridpool-cli validate <files>` checks config files offline and exits
22
+ non-zero on the first error, to gate config-repo CI. Each file must be valid
23
+ on its own, so a record names its own key and required fields; the files are
24
+ then checked merged, for the cross-record checks.
25
+
26
+ - `gridpool-cli` accepts `FREQUENZ_API_KEY` and `FREQUENZ_API_SECRET` as a
27
+ fallback pair for `ASSETS_API_AUTH_KEY` and `ASSETS_API_SIGN_SECRET`.
28
+
29
+ - Gridpools are described under `assets.gridpools`, each entry naming the
30
+ enterprise that owns the gridpool. `AssetsConfig.find_enterprise(gridpool_id)`
31
+ returns the configured owner.
32
+ `gridpool-cli find-enterprise <gridpool_id> <files>` prints it from the config.
33
+ `AssetsConfig.check` enforces the one-enterprise-per-gridpool invariant: a
34
+ gridpool's microgrids may not disagree on it, and a declared enterprise must
35
+ match the inferred one.
36
+
37
+ - A config derived from the Assets API now carries each microgrid's
38
+ `enterprise_id`.
39
+
40
+ - `generate-config --inplace` refreshes managed values while preserving
41
+ formatting; `--fill-missing` only adds absent values. Generated patches are
42
+ validated before writing.
@@ -148,6 +148,7 @@ min-similarity-lines = 40
148
148
  disable = [
149
149
  "too-few-public-methods",
150
150
  "too-many-return-statements",
151
+ "too-many-arguments",
151
152
  # disabled because it conflicts with isort
152
153
  "wrong-import-order",
153
154
  "ungrouped-imports",
@@ -6,25 +6,9 @@
6
6
  from frequenz.microgrid_component_graph import ComponentGraphConfig, FormulaOverrides
7
7
 
8
8
  from ._graph_generator import ComponentGraphGenerator
9
- from .config import (
10
- Metadata,
11
- MicrogridConfig,
12
- load_configs,
13
- load_configs_from_api,
14
- load_configs_from_files,
15
- merge_config_maps,
16
- merge_microgrid_configs,
17
- )
18
9
 
19
10
  __all__ = [
20
11
  "ComponentGraphConfig",
21
12
  "ComponentGraphGenerator",
22
13
  "FormulaOverrides",
23
- "Metadata",
24
- "MicrogridConfig",
25
- "load_configs",
26
- "load_configs_from_api",
27
- "load_configs_from_files",
28
- "merge_config_maps",
29
- "merge_microgrid_configs",
30
14
  ]