Skip to content

Commit a0791df

Browse files
committed
Use -sys.maxsize - 1 as default priority for BatteryPool
When no priorities are specified, we should use the lowest possible priority. Zero was supposed to be this lowest possible value, until it was mentioned that negative priorities should be possible as well. This commit also updates the BatteryPool's `charge` and `discharge` to use the pool's priority rather than the minimum. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 65c028e commit a0791df

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/frequenz/sdk/microgrid/_data_pipeline.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from __future__ import annotations
1212

1313
import logging
14+
import sys
1415
import typing
1516
from collections import abc
1617
from dataclasses import dataclass
@@ -186,7 +187,7 @@ def battery_pool(
186187
self,
187188
battery_ids: abc.Set[int] | None = None,
188189
source_id: str | None = None,
189-
priority: int = 0,
190+
priority: int = -sys.maxsize - 1,
190191
) -> BatteryPoolWrapper:
191192
"""Return the corresponding BatteryPool instance for the given ids.
192193
@@ -424,7 +425,7 @@ def ev_charger_pool(ev_charger_ids: set[int] | None = None) -> EVChargerPool:
424425
def battery_pool(
425426
battery_ids: abc.Set[int] | None = None,
426427
source_id: str | None = None,
427-
priority: int = 0,
428+
priority: int = -sys.maxsize - 1,
428429
) -> BatteryPoolWrapper:
429430
"""Return the corresponding BatteryPool instance for the given ids.
430431

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ async def charge(
139139
preferred_power=power,
140140
bounds=timeseries.Bounds(None, None),
141141
battery_ids=self._battery_pool._batteries,
142-
priority=0,
142+
priority=self._priority,
143143
request_timeout=request_timeout,
144144
include_broken_batteries=include_broken_batteries,
145145
)
@@ -182,7 +182,7 @@ async def discharge(
182182
preferred_power=power,
183183
bounds=timeseries.Bounds(None, None),
184184
battery_ids=self._battery_pool._batteries,
185-
priority=0,
185+
priority=self._priority,
186186
request_timeout=request_timeout,
187187
include_broken_batteries=include_broken_batteries,
188188
)

0 commit comments

Comments
 (0)