Skip to content

Commit 9ea0fc0

Browse files
committed
Make component_category and component_type parameters kw-only
This affects the PowerManager, PowerDistributor and PowerWrapper. The `component_type` paramater now also has a default value of `None`. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 59ff8f4 commit 9ea0fc0

File tree

4 files changed

+28
-24
lines changed

4 files changed

+28
-24
lines changed

src/frequenz/sdk/actor/_power_managing/_power_managing_actor.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,28 @@ class PowerManagingActor(Actor):
3232

3333
def __init__( # pylint: disable=too-many-arguments
3434
self,
35-
component_category: ComponentCategory,
36-
component_type: ComponentType | None,
3735
proposals_receiver: Receiver[Proposal],
3836
bounds_subscription_receiver: Receiver[ReportRequest],
3937
power_distributing_requests_sender: Sender[power_distributing.Request],
4038
power_distributing_results_receiver: Receiver[power_distributing.Result],
4139
channel_registry: ChannelRegistry,
40+
*,
41+
component_category: ComponentCategory,
42+
component_type: ComponentType | None = None,
4243
# arguments to actors need to serializable, so we pass an enum for the algorithm
4344
# instead of an instance of the algorithm.
4445
algorithm: Algorithm = Algorithm.MATRYOSHKA,
4546
):
4647
"""Create a new instance of the power manager.
4748
4849
Args:
50+
proposals_receiver: The receiver for proposals.
51+
bounds_subscription_receiver: The receiver for bounds subscriptions.
52+
power_distributing_requests_sender: The sender for power distribution
53+
requests.
54+
power_distributing_results_receiver: The receiver for power distribution
55+
results.
56+
channel_registry: The channel registry.
4957
component_category: The category of the component this power manager
5058
instance is going to support.
5159
component_type: The type of the component of the given category that this
@@ -55,13 +63,6 @@ def __init__( # pylint: disable=too-many-arguments
5563
the inverter as a solar inverter or a battery inverter. This can be
5664
`None` when the component category is enough to uniquely identify the
5765
component.
58-
proposals_receiver: The receiver for proposals.
59-
bounds_subscription_receiver: The receiver for bounds subscriptions.
60-
power_distributing_requests_sender: The sender for power distribution
61-
requests.
62-
power_distributing_results_receiver: The receiver for power distribution
63-
results.
64-
channel_registry: The channel registry.
6566
algorithm: The power management algorithm to use.
6667
6768
Raises:

src/frequenz/sdk/actor/power_distributing/power_distributing.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,25 @@ class PowerDistributingActor(Actor):
5757

5858
def __init__( # pylint: disable=too-many-arguments
5959
self,
60-
component_category: ComponentCategory,
61-
component_type: ComponentType | None,
6260
requests_receiver: Receiver[Request],
6361
results_sender: Sender[Result],
6462
component_pool_status_sender: Sender[ComponentPoolStatus],
6563
wait_for_data_sec: float,
6664
*,
65+
component_category: ComponentCategory,
66+
component_type: ComponentType | None = None,
6767
name: str | None = None,
6868
) -> None:
6969
"""Create class instance.
7070
7171
Args:
72+
requests_receiver: Receiver for receiving power requests from the power
73+
manager.
74+
results_sender: Sender for sending results to the power manager.
75+
component_pool_status_sender: Channel for sending information about which
76+
components are expected to be working.
77+
wait_for_data_sec: How long actor should wait before processing first
78+
request. It is a time needed to collect first components data.
7279
component_category: The category of the components that this actor is
7380
responsible for.
7481
component_type: The type of the component of the given category that this
@@ -78,13 +85,6 @@ def __init__( # pylint: disable=too-many-arguments
7885
the inverter as a solar inverter or a battery inverter. This can be
7986
`None` when the component category is enough to uniquely identify the
8087
component.
81-
requests_receiver: Receiver for receiving power requests from the power
82-
manager.
83-
results_sender: Sender for sending results to the power manager.
84-
component_pool_status_sender: Channel for sending information about which
85-
components are expected to be working.
86-
wait_for_data_sec: How long actor should wait before processing first
87-
request. It is a time needed to collect first components data.
8888
name: The name of the actor. If `None`, `str(id(self))` will be used. This
8989
is used mostly for debugging purposes.
9090

src/frequenz/sdk/microgrid/_data_pipeline.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,15 @@ def __init__(
9898
self._resampling_actor: _ActorInfo | None = None
9999

100100
self._battery_power_wrapper = PowerWrapper(
101-
ComponentCategory.BATTERY, None, self._channel_registry
101+
self._channel_registry, component_category=ComponentCategory.BATTERY
102102
)
103103
self._ev_power_wrapper = PowerWrapper(
104-
ComponentCategory.EV_CHARGER, None, self._channel_registry
104+
self._channel_registry, component_category=ComponentCategory.EV_CHARGER
105105
)
106106
self._pv_power_wrapper = PowerWrapper(
107-
ComponentCategory.INVERTER, InverterType.SOLAR, self._channel_registry
107+
self._channel_registry,
108+
component_category=ComponentCategory.INVERTER,
109+
component_type=InverterType.SOLAR,
108110
)
109111

110112
self._logical_meter: LogicalMeter | None = None

src/frequenz/sdk/microgrid/_power_wrapper.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@ class PowerWrapper:
3838

3939
def __init__(
4040
self,
41-
component_category: ComponentCategory,
42-
component_type: ComponentType | None,
4341
channel_registry: ChannelRegistry,
42+
*,
43+
component_category: ComponentCategory,
44+
component_type: ComponentType | None = None,
4445
):
4546
"""Initialize the power control.
4647
4748
Args:
49+
channel_registry: A channel registry for use in the actors.
4850
component_category: The category of the components that actors started by
4951
this instance of the PowerWrapper will be responsible for.
5052
component_type: The type of the component of the given category that this
@@ -54,7 +56,6 @@ def __init__(
5456
the inverter as a solar inverter or a battery inverter. This can be
5557
`None` when the component category is enough to uniquely identify the
5658
component.
57-
channel_registry: A channel registry for use in the actors.
5859
"""
5960
self._component_category = component_category
6061
self._component_type = component_type

0 commit comments

Comments
 (0)