Skip to content

Commit 889206a

Browse files
committed
Rename BatteryPoolWrapper -> BatteryPool
Also improve its public facing documentation. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 155508c commit 889206a

File tree

5 files changed

+34
-29
lines changed

5 files changed

+34
-29
lines changed

src/frequenz/sdk/microgrid/_data_pipeline.py

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
Request,
3939
Result,
4040
)
41-
from ..timeseries.battery_pool import BatteryPoolWrapper
41+
from ..timeseries.battery_pool import BatteryPool
4242
from ..timeseries.battery_pool._battery_pool_reference_store import (
4343
BatteryPoolReferenceStore,
4444
)
@@ -191,13 +191,11 @@ def battery_pool(
191191
battery_ids: abc.Set[int] | None = None,
192192
name: str | None = None,
193193
priority: int = -sys.maxsize - 1,
194-
) -> BatteryPoolWrapper:
195-
"""Return the corresponding BatteryPool instance for the given ids.
194+
) -> BatteryPool:
195+
"""Return a new BatteryPool instance for the given ids.
196196
197-
If a BatteryPool instance for the given ids doesn't exist, a new one is created
198-
and returned.
199-
200-
The BatteryPool is wrapped in a new `BatteryPoolWrapper` instance each time.
197+
If a BatteryPoolReferenceStore instance for the given battery ids doesn't exist,
198+
a new one is created and used for creating the BatteryPool.
201199
202200
Args:
203201
battery_ids: Optional set of IDs of batteries to be managed by the
@@ -207,9 +205,10 @@ def battery_pool(
207205
priority: The priority of the actor making the call.
208206
209207
Returns:
210-
A BatteryPoolWrapper instance.
208+
A BatteryPool instance.
209+
211210
"""
212-
from ..timeseries.battery_pool import BatteryPoolWrapper
211+
from ..timeseries.battery_pool import BatteryPool
213212
from ..timeseries.battery_pool._battery_pool_reference_store import (
214213
BatteryPoolReferenceStore,
215214
)
@@ -239,7 +238,7 @@ def battery_pool(
239238
batteries_id=battery_ids,
240239
)
241240

242-
return BatteryPoolWrapper(self._battery_pools[key], name, priority)
241+
return BatteryPool(self._battery_pools[key], name, priority)
243242

244243
def _start_power_managing_actor(self) -> None:
245244
"""Start the power managing actor if it is not already running."""
@@ -433,11 +432,8 @@ def battery_pool(
433432
battery_ids: abc.Set[int] | None = None,
434433
name: str | None = None,
435434
priority: int = -sys.maxsize - 1,
436-
) -> BatteryPoolWrapper:
437-
"""Return the corresponding BatteryPool instance for the given ids.
438-
439-
If a BatteryPool instance for the given ids doesn't exist, a new one is created and
440-
returned.
435+
) -> BatteryPool:
436+
"""Return a new BatteryPool instance for the given parameters.
441437
442438
The priority value is used to resolve conflicts when multiple actors are trying to
443439
propose different power values for the same set of batteries.
@@ -446,8 +442,6 @@ def battery_pool(
446442
When specifying priority, bigger values indicate higher priority. The default
447443
priority is the lowest possible value.
448444
449-
The BatteryPool is wrapped in a new `BatteryPoolWrapper` instance each time.
450-
451445
Args:
452446
battery_ids: Optional set of IDs of batteries to be managed by the BatteryPool.
453447
If not specified, all batteries available in the component graph are used.

src/frequenz/sdk/timeseries/battery_pool/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
"""Manage a pool of batteries."""
55

6-
from ._battery_pool_wrapper import BatteryPoolWrapper
6+
from ._battery_pool import BatteryPool
77
from ._result_types import PowerMetrics
88

99
__all__ = [
10-
"BatteryPoolWrapper",
10+
"BatteryPool",
1111
"PowerMetrics",
1212
]

src/frequenz/sdk/timeseries/battery_pool/_battery_pool_wrapper.py renamed to src/frequenz/sdk/timeseries/battery_pool/_battery_pool.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,23 @@
3636
# pylint: disable=protected-access
3737

3838

39-
class BatteryPoolWrapper:
40-
"""The BatteryPoolWrapper is the external interface for the BatteryPool.
41-
42-
BatteryPoolReferenceStore instances are unique to a set of batteries. The
43-
BatteryPoolWrapper provides an abstraction over actor priorities when multiple
44-
actors want to use the same set of batteries.
39+
class BatteryPool:
40+
"""An interface for interaction with pools of batteries.
41+
42+
Use the [microgrid.battery_pool][frequenz.sdk.microgrid.battery_pool] method for
43+
creating `BatteryPool` instances.
44+
45+
Provides:
46+
- properties for fetching reporting streams of instantaneous
47+
[power][frequenz.sdk.timeseries.battery_pool.BatteryPool.power],
48+
[soc][frequenz.sdk.timeseries.battery_pool.BatteryPool.soc],
49+
[capacity][frequenz.sdk.timeseries.battery_pool.BatteryPool.capacity] values and
50+
available power bounds and other status through
51+
[power_status][frequenz.sdk.timeseries.battery_pool.BatteryPool.power_status].
52+
- control methods for proposing power values, namely:
53+
[propose_power][frequenz.sdk.timeseries.battery_pool.BatteryPool.propose_power],
54+
[propose_charge][frequenz.sdk.timeseries.battery_pool.BatteryPool.propose_charge] and
55+
[propose_discharge][frequenz.sdk.timeseries.battery_pool.BatteryPool.propose_discharge].
4556
"""
4657

4758
def __init__(
@@ -50,7 +61,7 @@ def __init__(
5061
name: str | None,
5162
priority: int,
5263
):
53-
"""Create a BatteryPoolWrapper instance.
64+
"""Create a BatteryPool instance.
5465
5566
Args:
5667
battery_pool_ref: The battery pool reference store instance.

src/frequenz/sdk/timeseries/battery_pool/_battery_pool_reference_store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class BatteryPoolReferenceStore: # pylint: disable=too-many-instance-attributes
3131
These are independent of the priority of the actors, and can be shared between
3232
multiple users of the same set of batteries.
3333
34-
They are exposed through the BatteryPoolWrapper class.
34+
They are exposed through the BatteryPool class.
3535
"""
3636

3737
def __init__( # pylint: disable=too-many-arguments

tests/timeseries/_battery_pool/test_battery_pool.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
Sample,
3737
Temperature,
3838
)
39-
from frequenz.sdk.timeseries.battery_pool import BatteryPoolWrapper, PowerMetrics
39+
from frequenz.sdk.timeseries.battery_pool import BatteryPool, PowerMetrics
4040
from frequenz.sdk.timeseries.battery_pool._metric_calculator import (
4141
battery_inverter_mapping,
4242
)
@@ -90,7 +90,7 @@ def get_components(
9090
class SetupArgs:
9191
"""Setup arguments needed to run tests."""
9292

93-
battery_pool: BatteryPoolWrapper
93+
battery_pool: BatteryPool
9494
"""Battery pool that should be tested."""
9595

9696
min_update_interval: float

0 commit comments

Comments
 (0)