Skip to content

Commit 82f6ac7

Browse files
committed
Remove support for passing request_timeout with each power proposal
Signed-off-by: Sahas Subramanian <[email protected]>
1 parent ff526d9 commit 82f6ac7

File tree

8 files changed

+3
-62
lines changed

8 files changed

+3
-62
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import abc
99
import dataclasses
10-
import datetime
1110
import enum
1211
import typing
1312

@@ -164,9 +163,6 @@ class Proposal:
164163
This is used by the power manager to determine the age of the proposal.
165164
"""
166165

167-
request_timeout: datetime.timedelta = datetime.timedelta(seconds=5.0)
168-
"""The maximum amount of time to wait for the request to be fulfilled."""
169-
170166
set_operating_point: bool
171167
"""Whether this proposal sets the operating point power or the normal power."""
172168

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,15 +330,11 @@ async def _send_updated_target_power(
330330
proposal,
331331
must_send,
332332
)
333-
request_timeout = (
334-
proposal.request_timeout if proposal else timedelta(seconds=5.0)
335-
)
336333
if target_power is not None:
337334
await self._power_distributing_requests_sender.send(
338335
power_distributing.Request(
339336
power=target_power,
340337
component_ids=component_ids,
341-
request_timeout=request_timeout,
342338
adjust_power=True,
343339
)
344340
)

src/frequenz/sdk/actor/power_distributing/request.py

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

66
import dataclasses
77
from collections import abc
8-
from datetime import timedelta
98

109
from ...timeseries._quantities import Power
1110

@@ -20,9 +19,6 @@ class Request:
2019
component_ids: abc.Set[int]
2120
"""The component ids of the components to be used for this request."""
2221

23-
request_timeout: timedelta = timedelta(seconds=5.0)
24-
"""The maximum amount of time to wait for the request to be fulfilled."""
25-
2622
adjust_power: bool = True
2723
"""Whether to adjust the power to match the bounds.
2824

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

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import asyncio
1212
import uuid
1313
from collections import abc
14-
from datetime import timedelta
1514

1615
from ... import timeseries
1716
from ..._internal._channels import ReceiverFetcher
@@ -85,7 +84,6 @@ async def propose_power(
8584
self,
8685
power: Power | None,
8786
*,
88-
request_timeout: timedelta = timedelta(seconds=5.0),
8987
bounds: timeseries.Bounds[Power | None] = timeseries.Bounds(None, None),
9088
) -> None:
9189
"""Send a proposal to the power manager for the pool's set of batteries.
@@ -117,7 +115,6 @@ async def propose_power(
117115
proposal will not have any effect on the target power, unless bounds are
118116
specified. If both are `None`, it is equivalent to not having a
119117
proposal or withdrawing a previous one.
120-
request_timeout: The timeout for the request.
121118
bounds: The power bounds for the proposal. These bounds will apply to
122119
actors with a lower priority, and can be overridden by bounds from
123120
actors with a higher priority. If None, the power bounds will be set
@@ -132,17 +129,11 @@ async def propose_power(
132129
component_ids=self._pool_ref_store._batteries,
133130
priority=self._priority,
134131
creation_time=asyncio.get_running_loop().time(),
135-
request_timeout=request_timeout,
136132
set_operating_point=self._set_operating_point,
137133
)
138134
)
139135

140-
async def propose_charge(
141-
self,
142-
power: Power | None,
143-
*,
144-
request_timeout: timedelta = timedelta(seconds=5.0),
145-
) -> None:
136+
async def propose_charge(self, power: Power | None) -> None:
146137
"""Set the given charge power for the batteries in the pool.
147138
148139
Power values need to be positive values, indicating charge power.
@@ -164,7 +155,6 @@ async def propose_charge(
164155
power: The unsigned charge power to propose for the batteries in the pool.
165156
If None, the proposed power of higher priority actors will take
166157
precedence as the target power.
167-
request_timeout: The timeout for the request.
168158
169159
Raises:
170160
ValueError: If the given power is negative.
@@ -179,17 +169,11 @@ async def propose_charge(
179169
component_ids=self._pool_ref_store._batteries,
180170
priority=self._priority,
181171
creation_time=asyncio.get_running_loop().time(),
182-
request_timeout=request_timeout,
183172
set_operating_point=self._set_operating_point,
184173
)
185174
)
186175

187-
async def propose_discharge(
188-
self,
189-
power: Power | None,
190-
*,
191-
request_timeout: timedelta = timedelta(seconds=5.0),
192-
) -> None:
176+
async def propose_discharge(self, power: Power | None) -> None:
193177
"""Set the given discharge power for the batteries in the pool.
194178
195179
Power values need to be positive values, indicating discharge power.
@@ -211,7 +195,6 @@ async def propose_discharge(
211195
power: The unsigned discharge power to propose for the batteries in the
212196
pool. If None, the proposed power of higher priority actors will take
213197
precedence as the target power.
214-
request_timeout: The timeout for the request.
215198
216199
Raises:
217200
ValueError: If the given power is negative.
@@ -228,7 +211,6 @@ async def propose_discharge(
228211
component_ids=self._pool_ref_store._batteries,
229212
priority=self._priority,
230213
creation_time=asyncio.get_running_loop().time(),
231-
request_timeout=request_timeout,
232214
set_operating_point=self._set_operating_point,
233215
)
234216
)

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import asyncio
88
import uuid
99
from collections import abc
10-
from datetime import timedelta
1110

1211
from ..._internal._channels import ReceiverFetcher
1312
from ...actor import _power_managing
@@ -73,7 +72,6 @@ async def propose_power(
7372
self,
7473
power: Power | None,
7574
*,
76-
request_timeout: timedelta = timedelta(seconds=5.0),
7775
bounds: Bounds[Power | None] = Bounds(None, None),
7876
) -> None:
7977
"""Send a proposal to the power manager for the pool's set of EV chargers.
@@ -110,7 +108,6 @@ async def propose_power(
110108
this proposal will not have any effect on the target power, unless
111109
bounds are specified. If both are `None`, it is equivalent to not
112110
having a proposal or withdrawing a previous one.
113-
request_timeout: The timeout for the request.
114111
bounds: The power bounds for the proposal. These bounds will apply to
115112
actors with a lower priority, and can be overridden by bounds from
116113
actors with a higher priority. If None, the power bounds will be set to
@@ -132,7 +129,6 @@ async def propose_power(
132129
component_ids=self._pool_ref_store.component_ids,
133130
priority=self._priority,
134131
creation_time=asyncio.get_running_loop().time(),
135-
request_timeout=request_timeout,
136132
set_operating_point=self._set_operating_point,
137133
)
138134
)

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import asyncio
77
import uuid
88
from collections import abc
9-
from datetime import timedelta
109

1110
from ..._internal._channels import ReceiverFetcher
1211
from ...actor import _power_managing
@@ -63,7 +62,6 @@ async def propose_power(
6362
self,
6463
power: Power | None,
6564
*,
66-
request_timeout: timedelta = timedelta(seconds=5.0),
6765
bounds: Bounds[Power | None] = Bounds(None, None),
6866
) -> None:
6967
"""Send a proposal to the power manager for the pool's set of PV inverters.
@@ -99,7 +97,6 @@ async def propose_power(
9997
this proposal will not have any effect on the target power, unless
10098
bounds are specified. If both are `None`, it is equivalent to not
10199
having a proposal or withdrawing a previous one.
102-
request_timeout: The timeout for the request.
103100
bounds: The power bounds for the proposal. These bounds will apply to
104101
actors with a lower priority, and can be overridden by bounds from
105102
actors with a higher priority. If None, the power bounds will be set to
@@ -119,7 +116,6 @@ async def propose_power(
119116
component_ids=self._pool_ref_store.component_ids,
120117
priority=self._priority,
121118
creation_time=asyncio.get_running_loop().time(),
122-
request_timeout=request_timeout,
123119
set_operating_point=self._set_operating_point,
124120
)
125121
)

tests/actor/power_distributing/test_power_distributing.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ async def test_power_distributor_one_user(self, mocker: MockerFixture) -> None:
197197
request = Request(
198198
power=Power.from_kilowatts(1.2),
199199
component_ids={9, 19},
200-
request_timeout=SAFETY_TIMEOUT,
201200
)
202201

203202
await self._patch_battery_pool_status(mocks, mocker, request.component_ids)
@@ -281,7 +280,6 @@ async def test_power_distributor_exclusion_bounds(
281280
request = Request(
282281
power=Power.zero(),
283282
component_ids={9, 19},
284-
request_timeout=SAFETY_TIMEOUT,
285283
)
286284

287285
await requests_channel.new_sender().send(request)
@@ -306,7 +304,6 @@ async def test_power_distributor_exclusion_bounds(
306304
request = Request(
307305
power=Power.from_watts(300.0),
308306
component_ids={9, 19},
309-
request_timeout=SAFETY_TIMEOUT,
310307
)
311308

312309
await requests_channel.new_sender().send(request)
@@ -363,7 +360,6 @@ async def test_two_batteries_one_inverters(self, mocker: MockerFixture) -> None:
363360
bat_component1.component_id,
364361
bat_component2.component_id,
365362
},
366-
request_timeout=SAFETY_TIMEOUT,
367363
)
368364

369365
await self._patch_battery_pool_status(mocks, mocker, request.component_ids)
@@ -446,7 +442,6 @@ async def test_two_batteries_one_broken_one_inverters(
446442
request = Request(
447443
power=Power.from_watts(1200.0),
448444
component_ids=set(battery.component_id for battery in bat_components),
449-
request_timeout=SAFETY_TIMEOUT,
450445
)
451446

452447
await self._patch_battery_pool_status(mocks, mocker, request.component_ids)
@@ -502,7 +497,6 @@ async def test_battery_two_inverters(self, mocker: MockerFixture) -> None:
502497
request = Request(
503498
power=Power.from_watts(1200.0),
504499
component_ids={bat_component.component_id},
505-
request_timeout=SAFETY_TIMEOUT,
506500
)
507501

508502
await self._patch_battery_pool_status(mocks, mocker, request.component_ids)
@@ -556,7 +550,6 @@ async def test_two_batteries_three_inverters(self, mocker: MockerFixture) -> Non
556550
request = Request(
557551
power=Power.from_watts(1700.0),
558552
component_ids={batteries[0].component_id, batteries[1].component_id},
559-
request_timeout=SAFETY_TIMEOUT,
560553
)
561554

562555
await self._patch_battery_pool_status(mocks, mocker, request.component_ids)
@@ -644,7 +637,6 @@ async def test_two_batteries_one_inverter_different_exclusion_bounds_2(
644637
request = Request(
645638
power=Power.from_watts(300.0),
646639
component_ids={batteries[0].component_id, batteries[1].component_id},
647-
request_timeout=SAFETY_TIMEOUT,
648640
)
649641

650642
await self._patch_battery_pool_status(mocks, mocker, request.component_ids)
@@ -733,7 +725,6 @@ async def test_two_batteries_one_inverter_different_exclusion_bounds(
733725
request = Request(
734726
power=Power.from_watts(300.0),
735727
component_ids={batteries[0].component_id, batteries[1].component_id},
736-
request_timeout=SAFETY_TIMEOUT,
737728
)
738729

739730
await self._patch_battery_pool_status(mocks, mocker, request.component_ids)
@@ -801,7 +792,6 @@ async def test_connected_but_not_requested_batteries(
801792
request = Request(
802793
power=Power.from_watts(600.0),
803794
component_ids={batteries[0].component_id},
804-
request_timeout=SAFETY_TIMEOUT,
805795
)
806796

807797
await self._patch_battery_pool_status(mocks, mocker, request.component_ids)
@@ -860,7 +850,6 @@ async def test_battery_soc_nan(self, mocker: MockerFixture) -> None:
860850
request = Request(
861851
power=Power.from_kilowatts(1.2),
862852
component_ids={9, 19},
863-
request_timeout=SAFETY_TIMEOUT,
864853
)
865854

866855
await self._patch_battery_pool_status(mocks, mocker, request.component_ids)
@@ -916,7 +905,6 @@ async def test_battery_capacity_nan(self, mocker: MockerFixture) -> None:
916905
request = Request(
917906
power=Power.from_kilowatts(1.2),
918907
component_ids={9, 19},
919-
request_timeout=SAFETY_TIMEOUT,
920908
)
921909

922910
await self._patch_battery_pool_status(mocks, mocker, request.component_ids)
@@ -992,7 +980,6 @@ async def test_battery_power_bounds_nan(self, mocker: MockerFixture) -> None:
992980
request = Request(
993981
power=Power.from_kilowatts(1.2),
994982
component_ids={9, 19},
995-
request_timeout=SAFETY_TIMEOUT,
996983
)
997984

998985
await self._patch_battery_pool_status(mocks, mocker, request.component_ids)
@@ -1040,7 +1027,6 @@ async def test_power_distributor_invalid_battery_id(
10401027
request = Request(
10411028
power=Power.from_kilowatts(1.2),
10421029
component_ids={9, 100},
1043-
request_timeout=SAFETY_TIMEOUT,
10441030
)
10451031

10461032
await self._patch_battery_pool_status(mocks, mocker, request.component_ids)
@@ -1084,7 +1070,6 @@ async def test_power_distributor_one_user_adjust_power_consume(
10841070
request = Request(
10851071
power=Power.from_kilowatts(1.2),
10861072
component_ids={9, 19},
1087-
request_timeout=SAFETY_TIMEOUT,
10881073
adjust_power=False,
10891074
)
10901075

@@ -1133,7 +1118,6 @@ async def test_power_distributor_one_user_adjust_power_supply(
11331118
request = Request(
11341119
power=-Power.from_kilowatts(1.2),
11351120
component_ids={9, 19},
1136-
request_timeout=SAFETY_TIMEOUT,
11371121
adjust_power=False,
11381122
)
11391123

@@ -1182,7 +1166,6 @@ async def test_power_distributor_one_user_adjust_power_success(
11821166
request = Request(
11831167
power=Power.from_kilowatts(1.0),
11841168
component_ids={9, 19},
1185-
request_timeout=SAFETY_TIMEOUT,
11861169
adjust_power=False,
11871170
)
11881171

@@ -1246,7 +1229,6 @@ async def test_not_all_batteries_are_working(self, mocker: MockerFixture) -> Non
12461229
request = Request(
12471230
power=Power.from_kilowatts(1.2),
12481231
component_ids=batteries,
1249-
request_timeout=SAFETY_TIMEOUT,
12501232
)
12511233

12521234
await requests_channel.new_sender().send(request)
@@ -1302,7 +1284,6 @@ async def test_partial_failure_result(self, mocker: MockerFixture) -> None:
13021284
request = Request(
13031285
power=Power.from_kilowatts(1.70),
13041286
component_ids=batteries,
1305-
request_timeout=SAFETY_TIMEOUT,
13061287
)
13071288

13081289
await requests_channel.new_sender().send(request)

tests/timeseries/_battery_pool/test_battery_pool_control_methods.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,7 @@ async def side_effect(inv_id: int, _: float) -> None:
230230
await asyncio.sleep(1000.0)
231231

232232
set_power.side_effect = side_effect
233-
await battery_pool.propose_power(
234-
Power.from_watts(100.0), request_timeout=timedelta(seconds=0.1)
235-
)
233+
await battery_pool.propose_power(Power.from_watts(100.0))
236234
self._assert_report(
237235
await bounds_rx.receive(),
238236
power=100.0,

0 commit comments

Comments
 (0)