Skip to content

Commit 251a96c

Browse files
committed
Update BatteryPoolReport to not depend on Report
This makes `BatteryPoolReport` a plain protocol class like the other `*PoolReport` classes. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 2faab71 commit 251a96c

File tree

2 files changed

+3
-55
lines changed

2 files changed

+3
-55
lines changed

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

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -46,60 +46,8 @@ def get_channel_name(self) -> str:
4646
return f"power_manager.report.{self.component_ids=}.{self.priority=}"
4747

4848

49-
class Report(typing.Protocol):
50-
"""Current PowerManager report for a set of components.
51-
52-
This protocol can be specialized by different component pools to provide more
53-
specific details and documentation for the reports.
54-
"""
55-
56-
@property
57-
def bounds(self) -> timeseries.Bounds[Power] | None:
58-
"""The bounds for the components.
59-
60-
These bounds are adjusted to any restrictions placed by actors with higher
61-
priorities.
62-
63-
There might be exclusion zones within these bounds. If necessary, the
64-
`adjust_to_bounds` method may be used to check if a desired power value fits the
65-
bounds, or to get the closest possible power values that do fit the bounds.
66-
"""
67-
68-
@abc.abstractmethod
69-
def adjust_to_bounds(self, power: Power) -> tuple[Power | None, Power | None]:
70-
"""Adjust a power value to the bounds.
71-
72-
This method can be used to adjust a desired power value to the power bounds
73-
available to the actor.
74-
75-
If the given power value falls within the usable bounds, it will be returned
76-
unchanged.
77-
78-
If it falls outside the usable bounds, the closest possible value on the
79-
corresponding side will be returned. For example, if the given power is lower
80-
than the lowest usable power, only the lowest usable power will be returned, and
81-
similarly for the highest usable power.
82-
83-
If the given power falls within an exclusion zone that's contained within the
84-
usable bounds, the closest possible power values on both sides will be returned.
85-
86-
!!! note
87-
It is completely optional to use this method to adjust power values before
88-
proposing them, because the PowerManager will do this automatically. This
89-
method is provided for convenience, and for granular control when there are
90-
two possible power values, both of which fall within the available bounds.
91-
92-
Args:
93-
power: The power value to adjust.
94-
95-
Returns:
96-
A tuple of the closest power values to the desired power that fall within
97-
the available bounds for the actor.
98-
"""
99-
100-
10149
@dataclasses.dataclass(frozen=True, kw_only=True)
102-
class _Report(Report):
50+
class _Report:
10351
"""Current PowerManager report for a set of components."""
10452

10553
target_power: Power | None

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
"""Types for exposing battery pool reports."""
55

66
import abc
7+
import typing
78

89
from ...actor import power_distributing
9-
from ...actor._power_managing._base_classes import Report
1010
from .._base_types import Bounds
1111
from .._quantities import Power
1212

1313

1414
# This class is used to expose the generic reports from the PowerManager with specific
1515
# documentation for the battery pool.
16-
class BatteryPoolReport(Report):
16+
class BatteryPoolReport(typing.Protocol):
1717
"""A status report for a battery pool."""
1818

1919
target_power: Power | None

0 commit comments

Comments
 (0)