Skip to content

Commit fe3d8f8

Browse files
committed
Support multiple config files in component data
Signed-off-by: cwasicki <[email protected]>
1 parent a98007c commit fe3d8f8

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
## New Features
1212

1313
- Added EV to component types
14+
- Support multiple config files in MicrogridData.
1415

1516
## Bug Fixes
1617

src/frequenz/data/microgrid/component_data.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,28 @@
1919
class MicrogridData:
2020
"""Fetch power data for component types of a microgrid."""
2121

22-
def __init__(self, server_url: str, key: str, microgrid_config_path: str) -> None:
22+
def __init__(
23+
self, server_url: str, key: str, microgrid_config_path: str | list[str]
24+
) -> None:
2325
"""Initialize microgrid data.
2426
2527
Args:
2628
server_url: URL of the reporting service.
2729
key: Authentication key to the service.
28-
microgrid_config_path: Path to the config file with microgrid components.
30+
microgrid_config_path: Path(s) to the config file with microgrid components.
31+
32+
Raises:
33+
ValueError: If no microgrid config path is provided.
2934
"""
3035
self._client = ReportingApiClient(server_url=server_url, key=key)
31-
32-
self._microgrid_configs = MicrogridConfig.load_configs(microgrid_config_path)
36+
paths = (
37+
[microgrid_config_path]
38+
if isinstance(microgrid_config_path, str)
39+
else microgrid_config_path
40+
)
41+
if len(paths) < 1:
42+
raise ValueError("At least one microgrid config path must be provided")
43+
self._microgrid_configs = MicrogridConfig.load_configs(*paths)
3344

3445
@property
3546
def microgrid_ids(self) -> list[str]:

0 commit comments

Comments
 (0)