Skip to content

Commit ab22157

Browse files
committed
Add a get_target_power method to PowerManager algorithms
This would return the most recently calculated target power for a given set of components. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent b6d1159 commit ab22157

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,21 @@ def calculate_target_power(
293293
didn't change.
294294
"""
295295

296+
@abc.abstractmethod
297+
def get_target_power(
298+
self,
299+
component_ids: frozenset[int],
300+
) -> Power | None:
301+
"""Get the target power for the given components.
302+
303+
Args:
304+
component_ids: The component IDs to get the target power for.
305+
306+
Returns:
307+
The target power for the given components, or `None` if there is no target
308+
power.
309+
"""
310+
296311
# The arguments for this method are tightly coupled to the `Matryoshka` algorithm.
297312
# It can be loosened up when more algorithms are added.
298313
@abc.abstractmethod

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,21 @@ def _validate_component_ids(
152152
)
153153
return True
154154

155+
def get_target_power(
156+
self,
157+
component_ids: frozenset[int],
158+
) -> Power | None:
159+
"""Get the target power for the given components.
160+
161+
Args:
162+
component_ids: The component IDs to get the target power for.
163+
164+
Returns:
165+
The target power for the given components, or `None` if there is no target
166+
power.
167+
"""
168+
return self._target_power.get(component_ids)
169+
155170
@override
156171
def calculate_target_power(
157172
self,

0 commit comments

Comments
 (0)