Skip to content

Commit d2a27c7

Browse files
committed
Remove distribution_result field from Report classes
This should reduce the number of `Report`s sent out by the PowerManager. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 5956f6a commit d2a27c7

File tree

8 files changed

+1
-46
lines changed

8 files changed

+1
-46
lines changed

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
if typing.TYPE_CHECKING:
1818
from ...timeseries._base_types import SystemBounds
19-
from .. import power_distributing
2019

2120

2221
@dataclasses.dataclass(frozen=True, kw_only=True)
@@ -52,12 +51,6 @@ class _Report:
5251
target_power: Power | None
5352
"""The currently set power for the components."""
5453

55-
distribution_result: power_distributing.Result | None
56-
"""The result of the last power distribution.
57-
58-
This is `None` if no power distribution has been performed yet.
59-
"""
60-
6154
_inclusion_bounds: timeseries.Bounds[Power] | None
6255
"""The available inclusion bounds for the components, for the actor's priority.
6356
@@ -266,15 +259,13 @@ def get_status(
266259
component_ids: frozenset[int],
267260
priority: int,
268261
system_bounds: SystemBounds,
269-
distribution_result: power_distributing.Result | None,
270262
) -> _Report:
271263
"""Get the bounds for a set of components, for the given priority.
272264
273265
Args:
274266
component_ids: The IDs of the components to get the bounds for.
275267
priority: The priority of the actor for which the bounds are requested.
276268
system_bounds: The system bounds for the components.
277-
distribution_result: The result of the last power distribution.
278269
279270
Returns:
280271
The bounds for the components.

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
if typing.TYPE_CHECKING:
3434
from ...timeseries._base_types import SystemBounds
35-
from .. import power_distributing
3635

3736
_logger = logging.getLogger(__name__)
3837

@@ -225,15 +224,13 @@ def get_status(
225224
component_ids: frozenset[int],
226225
priority: int,
227226
system_bounds: SystemBounds,
228-
distribution_result: power_distributing.Result | None,
229227
) -> _Report:
230228
"""Get the bounds for the algorithm.
231229
232230
Args:
233231
component_ids: The IDs of the components to get the bounds for.
234232
priority: The priority of the actor for which the bounds are requested.
235233
system_bounds: The system bounds for the components.
236-
distribution_result: The result of the last power distribution.
237234
238235
Returns:
239236
The target power and the available bounds for the given components, for
@@ -245,7 +242,6 @@ def get_status(
245242
target_power=target_power,
246243
_inclusion_bounds=None,
247244
_exclusion_bounds=system_bounds.exclusion_bounds,
248-
distribution_result=distribution_result,
249245
)
250246

251247
lower_bound = system_bounds.inclusion_bounds.lower
@@ -284,7 +280,6 @@ def get_status(
284280
lower=lower_bound, upper=upper_bound
285281
),
286282
_exclusion_bounds=system_bounds.exclusion_bounds,
287-
distribution_result=distribution_result,
288283
)
289284

290285
@override

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ def __init__( # pylint: disable=too-many-arguments
9191
self._set_op_power_subscriptions: dict[
9292
frozenset[int], dict[int, Sender[_Report]]
9393
] = {}
94-
self._distribution_results: dict[frozenset[int], power_distributing.Result] = {}
9594

9695
self._set_power_group: BaseAlgorithm = Matryoshka(
9796
max_proposal_age=timedelta(seconds=60.0)
@@ -120,7 +119,6 @@ async def _send_reports(self, component_ids: frozenset[int]) -> None:
120119
component_ids,
121120
priority,
122121
bounds,
123-
self._distribution_results.get(component_ids),
124122
)
125123
await sender.send(status)
126124
for priority, sender in self._set_power_subscriptions.get(
@@ -133,7 +131,6 @@ async def _send_reports(self, component_ids: frozenset[int]) -> None:
133131
bounds,
134132
self._set_op_power_group.get_target_power(component_ids),
135133
),
136-
self._distribution_results.get(component_ids),
137134
)
138135
await sender.send(status)
139136

@@ -403,9 +400,6 @@ async def _run(self) -> None:
403400
)
404401

405402
result = selected.message
406-
self._distribution_results[frozenset(result.request.component_ids)] = (
407-
result
408-
)
409403
if not isinstance(result, power_distributing.Success):
410404
_logger.warning(
411405
"PowerManagingActor: PowerDistributing failed: %s", result

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import abc
77
import typing
88

9-
from ...actor import power_distributing
109
from .._base_types import Bounds
1110
from .._quantities import Power
1211

@@ -20,13 +19,6 @@ class BatteryPoolReport(typing.Protocol):
2019
def target_power(self) -> Power | None:
2120
"""The currently set power for the batteries."""
2221

23-
@property
24-
def distribution_result(self) -> power_distributing.Result | None:
25-
"""The result of the last power distribution.
26-
27-
This is `None` if no power distribution has been performed yet.
28-
"""
29-
3022
@property
3123
def bounds(self) -> Bounds[Power] | None:
3224
"""The usable bounds for the batteries.

src/frequenz/sdk/timeseries/ev_charger_pool/_result_types.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import typing
77

8-
from ...actor import power_distributing
98
from .._base_types import Bounds
109
from .._quantities import Power
1110

@@ -17,13 +16,6 @@ class EVChargerPoolReport(typing.Protocol):
1716
def target_power(self) -> Power | None:
1817
"""The currently set power for the EV chargers."""
1918

20-
@property
21-
def distribution_result(self) -> power_distributing.Result | None:
22-
"""The result of the last power distribution.
23-
24-
This is `None` if no power distribution has been performed yet.
25-
"""
26-
2719
@property
2820
def bounds(self) -> Bounds[Power] | None:
2921
"""The usable bounds for the EV chargers.

src/frequenz/sdk/timeseries/pv_pool/_result_types.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import typing
77

8-
from ...actor import power_distributing
98
from .._base_types import Bounds
109
from .._quantities import Power
1110

@@ -17,13 +16,6 @@ class PVPoolReport(typing.Protocol):
1716
def target_power(self) -> Power | None:
1817
"""The currently set power for the PV inverters."""
1918

20-
@property
21-
def distribution_result(self) -> power_distributing.Result | None:
22-
"""The result of the last power distribution.
23-
24-
This is `None` if no power distribution has been performed yet.
25-
"""
26-
2719
@property
2820
def bounds(self) -> Bounds[Power] | None:
2921
"""The usable bounds for the PV inverters.

tests/actor/_power_managing/test_matryoshka.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def bounds(
7070
) -> None:
7171
"""Test the status report."""
7272
report = self.algorithm.get_status(
73-
self._batteries, priority, self._system_bounds, None
73+
self._batteries, priority, self._system_bounds
7474
)
7575
if expected_power is None:
7676
assert report.target_power is None

tests/actor/_power_managing/test_report.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ def __init__(
3434
if exclusion_bounds is not None
3535
else None
3636
),
37-
distribution_result=None,
3837
)
3938

4039
def case(

0 commit comments

Comments
 (0)