Skip to content

Commit e289a7a

Browse files
committed
Make microgrid config fields public
Required for schema-based config loading. Signed-off-by: cwasicki <[email protected]>
1 parent d6d1c6a commit e289a7a

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

src/frequenz/data/microgrid/config.py

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,13 @@ class Metadata:
207207
class MicrogridConfig:
208208
"""Configuration of a microgrid."""
209209

210-
_metadata: Metadata
210+
meta: Metadata
211211
"""Metadata of the microgrid."""
212212

213-
_assets_cfg: AssetsConfig
213+
assets: AssetsConfig
214214
"""Configuration of the assets in the microgrid."""
215215

216-
_component_types_cfg: dict[str, ComponentTypeConfig]
216+
ctype: dict[str, ComponentTypeConfig]
217217
"""Mapping of component category types to ac power component config."""
218218

219219
def __init__(self, config_dict: dict[str, Any]) -> None:
@@ -222,33 +222,23 @@ def __init__(self, config_dict: dict[str, Any]) -> None:
222222
Args:
223223
config_dict: Dictionary with component type as key and config as value.
224224
"""
225-
self._metadata = Metadata(**(config_dict.get("meta") or {}))
225+
self.meta = Metadata(**(config_dict.get("meta") or {}))
226226

227-
self._assets_cfg = AssetsConfig(
227+
self.assets = AssetsConfig(
228228
pv=config_dict.get("pv") or {},
229229
wind=config_dict.get("wind") or {},
230230
battery=config_dict.get("battery") or {},
231231
)
232232

233-
self._component_types_cfg = {
233+
self.ctype = {
234234
ctype: ComponentTypeConfig(component_type=cast(ComponentType, ctype), **cfg)
235235
for ctype, cfg in config_dict.get("ctype", {}).items()
236236
if ComponentTypeConfig.is_valid_type(ctype)
237237
}
238238

239-
@property
240-
def meta(self) -> Metadata:
241-
"""Return the metadata of the microgrid."""
242-
return self._metadata
243-
244-
@property
245-
def assets(self) -> AssetsConfig:
246-
"""Return the assets configuration of the microgrid."""
247-
return self._assets_cfg
248-
249239
def component_types(self) -> list[str]:
250240
"""Get a list of all component types in the configuration."""
251-
return list(self._component_types_cfg.keys())
241+
return list(self.ctype.keys())
252242

253243
def component_type_ids(
254244
self,
@@ -272,7 +262,7 @@ def component_type_ids(
272262
ValueError: If the component type is unknown.
273263
KeyError: If `component_category` is invalid.
274264
"""
275-
cfg = self._component_types_cfg.get(component_type)
265+
cfg = self.ctype.get(component_type)
276266
if not cfg:
277267
raise ValueError(f"{component_type} not found in config.")
278268

@@ -301,7 +291,7 @@ def formula(self, component_type: str, metric: str) -> str:
301291
Raises:
302292
ValueError: If the component type is unknown or formula is missing.
303293
"""
304-
cfg = self._component_types_cfg.get(component_type)
294+
cfg = self.ctype.get(component_type)
305295
if not cfg:
306296
raise ValueError(f"{component_type} not found in config.")
307297
if cfg.formula is None:

0 commit comments

Comments
 (0)