Skip to content

Commit 79225f5

Browse files
committed
Rename *_pool_ref *Pool ctor parameters to pool_ref_store
This allows all `*Pool` classes to have the same signature. This commit also renames the corresponding private variable in all the `*Pool` classes to `self._pool_ref_store`. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 50c73fd commit 79225f5

File tree

4 files changed

+73
-73
lines changed

4 files changed

+73
-73
lines changed

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

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class BatteryPool:
5555

5656
def __init__(
5757
self,
58-
battery_pool_ref: BatteryPoolReferenceStore,
58+
pool_ref_store: BatteryPoolReferenceStore,
5959
name: str | None,
6060
priority: int,
6161
):
@@ -67,12 +67,12 @@ def __init__(
6767
for creating `BatteryPool` instances.
6868
6969
Args:
70-
battery_pool_ref: The battery pool reference store instance.
70+
pool_ref_store: The battery pool reference store instance.
7171
name: An optional name used to identify this instance of the pool or a
7272
corresponding actor in the logs.
7373
priority: The priority of the actor using this wrapper.
7474
"""
75-
self._battery_pool = battery_pool_ref
75+
self._pool_ref_store = pool_ref_store
7676
unique_id = str(uuid.uuid4())
7777
self._source_id = unique_id if name is None else f"{name}-{unique_id}"
7878
self._priority = priority
@@ -120,12 +120,12 @@ async def propose_power(
120120
to the maximum power of the batteries in the pool. This is currently
121121
and experimental feature.
122122
"""
123-
await self._battery_pool._power_manager_requests_sender.send(
123+
await self._pool_ref_store._power_manager_requests_sender.send(
124124
_power_managing.Proposal(
125125
source_id=self._source_id,
126126
preferred_power=power,
127127
bounds=bounds,
128-
component_ids=self._battery_pool._batteries,
128+
component_ids=self._pool_ref_store._batteries,
129129
priority=self._priority,
130130
creation_time=asyncio.get_running_loop().time(),
131131
request_timeout=request_timeout,
@@ -166,12 +166,12 @@ async def propose_charge(
166166
"""
167167
if power and power < Power.zero():
168168
raise ValueError("Charge power must be positive.")
169-
await self._battery_pool._power_manager_requests_sender.send(
169+
await self._pool_ref_store._power_manager_requests_sender.send(
170170
_power_managing.Proposal(
171171
source_id=self._source_id,
172172
preferred_power=power,
173173
bounds=timeseries.Bounds(None, None),
174-
component_ids=self._battery_pool._batteries,
174+
component_ids=self._pool_ref_store._batteries,
175175
priority=self._priority,
176176
creation_time=asyncio.get_running_loop().time(),
177177
request_timeout=request_timeout,
@@ -214,12 +214,12 @@ async def propose_discharge(
214214
if power < Power.zero():
215215
raise ValueError("Discharge power must be positive.")
216216
power = -power
217-
await self._battery_pool._power_manager_requests_sender.send(
217+
await self._pool_ref_store._power_manager_requests_sender.send(
218218
_power_managing.Proposal(
219219
source_id=self._source_id,
220220
preferred_power=power,
221221
bounds=timeseries.Bounds(None, None),
222-
component_ids=self._battery_pool._batteries,
222+
component_ids=self._pool_ref_store._batteries,
223223
priority=self._priority,
224224
creation_time=asyncio.get_running_loop().time(),
225225
request_timeout=request_timeout,
@@ -233,7 +233,7 @@ def component_ids(self) -> abc.Set[int]:
233233
Returns:
234234
Ids of the batteries in the pool
235235
"""
236-
return self._battery_pool._batteries
236+
return self._pool_ref_store._batteries
237237

238238
@property
239239
def power(self) -> FormulaEngine[Power]:
@@ -251,11 +251,11 @@ def power(self) -> FormulaEngine[Power]:
251251
A FormulaEngine that will calculate and stream the total power of all
252252
batteries in the pool.
253253
"""
254-
engine = self._battery_pool._formula_pool.from_power_formula_generator(
254+
engine = self._pool_ref_store._formula_pool.from_power_formula_generator(
255255
"battery_pool_power",
256256
BatteryPowerFormula,
257257
FormulaGeneratorConfig(
258-
component_ids=self._battery_pool._batteries,
258+
component_ids=self._pool_ref_store._batteries,
259259
),
260260
)
261261
assert isinstance(engine, FormulaEngine)
@@ -298,15 +298,15 @@ def soc(self) -> ReceiverFetcher[Sample[Percentage]]:
298298
"""
299299
method_name = SendOnUpdate.name() + "_" + SoCCalculator.name()
300300

301-
if method_name not in self._battery_pool._active_methods:
302-
calculator = SoCCalculator(self._battery_pool._batteries)
303-
self._battery_pool._active_methods[method_name] = SendOnUpdate(
301+
if method_name not in self._pool_ref_store._active_methods:
302+
calculator = SoCCalculator(self._pool_ref_store._batteries)
303+
self._pool_ref_store._active_methods[method_name] = SendOnUpdate(
304304
metric_calculator=calculator,
305-
working_batteries=self._battery_pool._working_batteries,
306-
min_update_interval=self._battery_pool._min_update_interval,
305+
working_batteries=self._pool_ref_store._working_batteries,
306+
min_update_interval=self._pool_ref_store._min_update_interval,
307307
)
308308

309-
return self._battery_pool._active_methods[method_name]
309+
return self._pool_ref_store._active_methods[method_name]
310310

311311
@property
312312
def temperature(self) -> ReceiverFetcher[Sample[Temperature]]:
@@ -317,14 +317,14 @@ def temperature(self) -> ReceiverFetcher[Sample[Temperature]]:
317317
of all batteries in the pool.
318318
"""
319319
method_name = SendOnUpdate.name() + "_" + TemperatureCalculator.name()
320-
if method_name not in self._battery_pool._active_methods:
321-
calculator = TemperatureCalculator(self._battery_pool._batteries)
322-
self._battery_pool._active_methods[method_name] = SendOnUpdate(
320+
if method_name not in self._pool_ref_store._active_methods:
321+
calculator = TemperatureCalculator(self._pool_ref_store._batteries)
322+
self._pool_ref_store._active_methods[method_name] = SendOnUpdate(
323323
metric_calculator=calculator,
324-
working_batteries=self._battery_pool._working_batteries,
325-
min_update_interval=self._battery_pool._min_update_interval,
324+
working_batteries=self._pool_ref_store._working_batteries,
325+
min_update_interval=self._pool_ref_store._min_update_interval,
326326
)
327-
return self._battery_pool._active_methods[method_name]
327+
return self._pool_ref_store._active_methods[method_name]
328328

329329
@property
330330
def capacity(self) -> ReceiverFetcher[Sample[Energy]]:
@@ -355,15 +355,15 @@ def capacity(self) -> ReceiverFetcher[Sample[Energy]]:
355355
"""
356356
method_name = SendOnUpdate.name() + "_" + CapacityCalculator.name()
357357

358-
if method_name not in self._battery_pool._active_methods:
359-
calculator = CapacityCalculator(self._battery_pool._batteries)
360-
self._battery_pool._active_methods[method_name] = SendOnUpdate(
358+
if method_name not in self._pool_ref_store._active_methods:
359+
calculator = CapacityCalculator(self._pool_ref_store._batteries)
360+
self._pool_ref_store._active_methods[method_name] = SendOnUpdate(
361361
metric_calculator=calculator,
362-
working_batteries=self._battery_pool._working_batteries,
363-
min_update_interval=self._battery_pool._min_update_interval,
362+
working_batteries=self._pool_ref_store._working_batteries,
363+
min_update_interval=self._pool_ref_store._min_update_interval,
364364
)
365365

366-
return self._battery_pool._active_methods[method_name]
366+
return self._pool_ref_store._active_methods[method_name]
367367

368368
@property
369369
def power_status(self) -> ReceiverFetcher[BatteryPoolReport]:
@@ -380,14 +380,14 @@ def power_status(self) -> ReceiverFetcher[BatteryPoolReport]:
380380
sub = _power_managing.ReportRequest(
381381
source_id=self._source_id,
382382
priority=self._priority,
383-
component_ids=self._battery_pool._batteries,
383+
component_ids=self._pool_ref_store._batteries,
384384
)
385-
self._battery_pool._power_bounds_subs[sub.get_channel_name()] = (
385+
self._pool_ref_store._power_bounds_subs[sub.get_channel_name()] = (
386386
asyncio.create_task(
387-
self._battery_pool._power_manager_bounds_subscription_sender.send(sub)
387+
self._pool_ref_store._power_manager_bounds_subscription_sender.send(sub)
388388
)
389389
)
390-
channel = self._battery_pool._channel_registry.get_or_create(
390+
channel = self._pool_ref_store._channel_registry.get_or_create(
391391
_power_managing._Report, sub.get_channel_name()
392392
)
393393
channel.resend_latest = True
@@ -415,16 +415,16 @@ def _system_power_bounds(self) -> ReceiverFetcher[SystemBounds]:
415415
"""
416416
method_name = SendOnUpdate.name() + "_" + PowerBoundsCalculator.name()
417417

418-
if method_name not in self._battery_pool._active_methods:
419-
calculator = PowerBoundsCalculator(self._battery_pool._batteries)
420-
self._battery_pool._active_methods[method_name] = SendOnUpdate(
418+
if method_name not in self._pool_ref_store._active_methods:
419+
calculator = PowerBoundsCalculator(self._pool_ref_store._batteries)
420+
self._pool_ref_store._active_methods[method_name] = SendOnUpdate(
421421
metric_calculator=calculator,
422-
working_batteries=self._battery_pool._working_batteries,
423-
min_update_interval=self._battery_pool._min_update_interval,
422+
working_batteries=self._pool_ref_store._working_batteries,
423+
min_update_interval=self._pool_ref_store._min_update_interval,
424424
)
425425

426-
return self._battery_pool._active_methods[method_name]
426+
return self._pool_ref_store._active_methods[method_name]
427427

428428
async def stop(self) -> None:
429429
"""Stop all tasks and channels owned by the BatteryPool."""
430-
await self._battery_pool.stop()
430+
await self._pool_ref_store.stop()

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class EVChargerPool:
4141

4242
def __init__( # pylint: disable=too-many-arguments
4343
self,
44-
ev_charger_pool_ref: EVChargerPoolReferenceStore,
44+
pool_ref_store: EVChargerPoolReferenceStore,
4545
name: str | None,
4646
priority: int,
4747
) -> None:
@@ -53,12 +53,12 @@ def __init__( # pylint: disable=too-many-arguments
5353
method for creating `EVChargerPool` instances.
5454
5555
Args:
56-
ev_charger_pool_ref: The EV charger pool reference store instance.
56+
pool_ref_store: The EV charger pool reference store instance.
5757
name: An optional name used to identify this instance of the pool or a
5858
corresponding actor in the logs.
5959
priority: The priority of the actor using this wrapper.
6060
"""
61-
self._ev_charger_pool = ev_charger_pool_ref
61+
self._pool_ref_store = pool_ref_store
6262
unique_id = str(uuid.uuid4())
6363
self._source_id = unique_id if name is None else f"{name}-{unique_id}"
6464
self._priority = priority
@@ -118,12 +118,12 @@ async def propose_power(
118118
raise EVChargerPoolError(
119119
"Discharging from EV chargers is currently not supported."
120120
)
121-
await self._ev_charger_pool.power_manager_requests_sender.send(
121+
await self._pool_ref_store.power_manager_requests_sender.send(
122122
_power_managing.Proposal(
123123
source_id=self._source_id,
124124
preferred_power=power,
125125
bounds=bounds,
126-
component_ids=self._ev_charger_pool.component_ids,
126+
component_ids=self._pool_ref_store.component_ids,
127127
priority=self._priority,
128128
creation_time=asyncio.get_running_loop().time(),
129129
request_timeout=request_timeout,
@@ -137,7 +137,7 @@ def component_ids(self) -> abc.Set[int]:
137137
Returns:
138138
Set of managed component IDs.
139139
"""
140-
return self._ev_charger_pool.component_ids
140+
return self._pool_ref_store.component_ids
141141

142142
@property
143143
def current(self) -> FormulaEngine3Phase[Current]:
@@ -156,11 +156,11 @@ def current(self) -> FormulaEngine3Phase[Current]:
156156
Chargers.
157157
"""
158158
engine = (
159-
self._ev_charger_pool.formula_pool.from_3_phase_current_formula_generator(
159+
self._pool_ref_store.formula_pool.from_3_phase_current_formula_generator(
160160
"ev_charger_total_current",
161161
EVChargerCurrentFormula,
162162
FormulaGeneratorConfig(
163-
component_ids=self._ev_charger_pool.component_ids
163+
component_ids=self._pool_ref_store.component_ids
164164
),
165165
)
166166
)
@@ -183,11 +183,11 @@ def power(self) -> FormulaEngine[Power]:
183183
A FormulaEngine that will calculate and stream the total power of all EV
184184
Chargers.
185185
"""
186-
engine = self._ev_charger_pool.formula_pool.from_power_formula_generator(
186+
engine = self._pool_ref_store.formula_pool.from_power_formula_generator(
187187
"ev_charger_power",
188188
EVChargerPowerFormula,
189189
FormulaGeneratorConfig(
190-
component_ids=self._ev_charger_pool.component_ids,
190+
component_ids=self._pool_ref_store.component_ids,
191191
),
192192
)
193193
assert isinstance(engine, FormulaEngine)
@@ -208,14 +208,14 @@ def power_status(self) -> ReceiverFetcher[EVChargerPoolReport]:
208208
sub = _power_managing.ReportRequest(
209209
source_id=self._source_id,
210210
priority=self._priority,
211-
component_ids=self._ev_charger_pool.component_ids,
211+
component_ids=self._pool_ref_store.component_ids,
212212
)
213-
self._ev_charger_pool.power_bounds_subs[sub.get_channel_name()] = (
213+
self._pool_ref_store.power_bounds_subs[sub.get_channel_name()] = (
214214
asyncio.create_task(
215-
self._ev_charger_pool.power_manager_bounds_subs_sender.send(sub)
215+
self._pool_ref_store.power_manager_bounds_subs_sender.send(sub)
216216
)
217217
)
218-
channel = self._ev_charger_pool.channel_registry.get_or_create(
218+
channel = self._pool_ref_store.channel_registry.get_or_create(
219219
_power_managing._Report, # pylint: disable=protected-access
220220
sub.get_channel_name(),
221221
)
@@ -227,9 +227,9 @@ def power_status(self) -> ReceiverFetcher[EVChargerPoolReport]:
227227

228228
async def stop(self) -> None:
229229
"""Stop all tasks and channels owned by the EVChargerPool."""
230-
await self._ev_charger_pool.stop()
230+
await self._pool_ref_store.stop()
231231

232232
@property
233233
def _system_power_bounds(self) -> ReceiverFetcher[SystemBounds]:
234234
"""Return a receiver fetcher for the system power bounds."""
235-
return self._ev_charger_pool.bounds_channel
235+
return self._pool_ref_store.bounds_channel

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class PVPool:
3434

3535
def __init__( # pylint: disable=too-many-arguments
3636
self,
37-
pv_pool_ref: PVPoolReferenceStore,
37+
pool_ref_store: PVPoolReferenceStore,
3838
name: str | None,
3939
priority: int,
4040
) -> None:
@@ -46,11 +46,11 @@ def __init__( # pylint: disable=too-many-arguments
4646
`PVPool` instances.
4747
4848
Args:
49-
pv_pool_ref: The reference store for the PV pool.
49+
pool_ref_store: The reference store for the PV pool.
5050
name: The name of the PV pool.
5151
priority: The priority of the PV pool.
5252
"""
53-
self._pv_pool_ref = pv_pool_ref
53+
self._pool_ref_store = pool_ref_store
5454
unique_id = uuid.uuid4()
5555
self._source_id = str(unique_id) if name is None else f"{name}-{unique_id}"
5656
self._priority = priority
@@ -107,12 +107,12 @@ async def propose_power(
107107
"""
108108
if power is not None and power > Power.zero():
109109
raise PVPoolError("Charge powers for PV inverters is not supported.")
110-
await self._pv_pool_ref.power_manager_requests_sender.send(
110+
await self._pool_ref_store.power_manager_requests_sender.send(
111111
_power_managing.Proposal(
112112
source_id=self._source_id,
113113
preferred_power=power,
114114
bounds=bounds,
115-
component_ids=self._pv_pool_ref.component_ids,
115+
component_ids=self._pool_ref_store.component_ids,
116116
priority=self._priority,
117117
creation_time=asyncio.get_running_loop().time(),
118118
request_timeout=request_timeout,
@@ -126,7 +126,7 @@ def component_ids(self) -> abc.Set[int]:
126126
Returns:
127127
Set of managed component IDs.
128128
"""
129-
return self._pv_pool_ref.component_ids
129+
return self._pool_ref_store.component_ids
130130

131131
@property
132132
def power(self) -> FormulaEngine[Power]:
@@ -144,11 +144,11 @@ def power(self) -> FormulaEngine[Power]:
144144
A FormulaEngine that will calculate and stream the total power of all PV
145145
Inverters.
146146
"""
147-
engine = self._pv_pool_ref.formula_pool.from_power_formula_generator(
147+
engine = self._pool_ref_store.formula_pool.from_power_formula_generator(
148148
"pv_power",
149149
PVPowerFormula,
150150
FormulaGeneratorConfig(
151-
component_ids=self._pv_pool_ref.component_ids,
151+
component_ids=self._pool_ref_store.component_ids,
152152
),
153153
)
154154
assert isinstance(engine, FormulaEngine)
@@ -169,14 +169,14 @@ def power_status(self) -> ReceiverFetcher[PVPoolReport]:
169169
sub = _power_managing.ReportRequest(
170170
source_id=self._source_id,
171171
priority=self._priority,
172-
component_ids=self._pv_pool_ref.component_ids,
172+
component_ids=self._pool_ref_store.component_ids,
173173
)
174-
self._pv_pool_ref.power_bounds_subs[sub.get_channel_name()] = (
174+
self._pool_ref_store.power_bounds_subs[sub.get_channel_name()] = (
175175
asyncio.create_task(
176-
self._pv_pool_ref.power_manager_bounds_subs_sender.send(sub)
176+
self._pool_ref_store.power_manager_bounds_subs_sender.send(sub)
177177
)
178178
)
179-
channel = self._pv_pool_ref.channel_registry.get_or_create(
179+
channel = self._pool_ref_store.channel_registry.get_or_create(
180180
_power_managing._Report, # pylint: disable=protected-access
181181
sub.get_channel_name(),
182182
)
@@ -188,9 +188,9 @@ def power_status(self) -> ReceiverFetcher[PVPoolReport]:
188188

189189
async def stop(self) -> None:
190190
"""Stop all tasks and channels owned by the PVPool."""
191-
await self._pv_pool_ref.stop()
191+
await self._pool_ref_store.stop()
192192

193193
@property
194194
def _system_power_bounds(self) -> ReceiverFetcher[SystemBounds]:
195195
"""Return a receiver fetcher for the system power bounds."""
196-
return self._pv_pool_ref.bounds_channel
196+
return self._pool_ref_store.bounds_channel

0 commit comments

Comments
 (0)