Skip to content

Commit 21c96fb

Browse files
committed
Drop the source from the bucket if a None proposal is received
And if that leads to an empty bucket, drop the bucket too. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 7555366 commit 21c96fb

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,15 @@ def calculate_target_power(
199199
bucket = self._component_buckets.setdefault(component_ids, set())
200200
if proposal in bucket:
201201
bucket.remove(proposal)
202-
bucket.add(proposal)
202+
if (
203+
proposal.preferred_power is not None
204+
or proposal.bounds.lower is not None
205+
or proposal.bounds.upper is not None
206+
):
207+
bucket.add(proposal)
208+
elif not bucket:
209+
del self._component_buckets[component_ids]
210+
_ = self._target_power.pop(component_ids, None)
203211

204212
# If there has not been any proposal for the given components, don't calculate a
205213
# target power and just return `None`.

0 commit comments

Comments
 (0)