Skip to content

Commit 7a612ed

Browse files
committed
Rename *pool constructor param to component_ids
This allows for all *pool methods to be more consistent with each other. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 8abd544 commit 7a612ed

File tree

2 files changed

+32
-31
lines changed

2 files changed

+32
-31
lines changed

src/frequenz/sdk/microgrid/_data_pipeline.py

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def producer(self) -> Producer:
185185

186186
def ev_charger_pool(
187187
self,
188-
ev_charger_ids: abc.Set[int] | None = None,
188+
component_ids: abc.Set[int] | None = None,
189189
name: str | None = None,
190190
priority: int = -sys.maxsize - 1,
191191
) -> EVChargerPool:
@@ -195,7 +195,7 @@ def ev_charger_pool(
195195
created and returned.
196196
197197
Args:
198-
ev_charger_ids: Optional set of IDs of EV Chargers to be managed by the
198+
component_ids: Optional set of IDs of EV Chargers to be managed by the
199199
EVChargerPool.
200200
name: An optional name used to identify this instance of the pool or a
201201
corresponding actor in the logs.
@@ -214,8 +214,8 @@ def ev_charger_pool(
214214

215215
# We use frozenset to make a hashable key from the input set.
216216
ref_store_key: frozenset[int] = frozenset()
217-
if ev_charger_ids is not None:
218-
ref_store_key = frozenset(ev_charger_ids)
217+
if component_ids is not None:
218+
ref_store_key = frozenset(component_ids)
219219

220220
pool_key = f"{ref_store_key}-{priority}"
221221
if pool_key in self._known_pool_keys:
@@ -226,7 +226,7 @@ def ev_charger_pool(
226226
"consider reusing the same instance."
227227
"\n Hint: If the instances are created from different actors, "
228228
"consider using different priorities to distinguish them.",
229-
ev_charger_ids,
229+
component_ids,
230230
priority,
231231
)
232232
else:
@@ -246,7 +246,7 @@ def ev_charger_pool(
246246
power_manager_bounds_subs_sender=(
247247
self._ev_power_wrapper.bounds_subscription_channel.new_sender()
248248
),
249-
component_ids=ev_charger_ids,
249+
component_ids=component_ids,
250250
)
251251
)
252252
return EVChargerPool(
@@ -255,7 +255,7 @@ def ev_charger_pool(
255255

256256
def pv_pool(
257257
self,
258-
pv_inverter_ids: abc.Set[int] | None = None,
258+
component_ids: abc.Set[int] | None = None,
259259
name: str | None = None,
260260
priority: int = -sys.maxsize - 1,
261261
) -> PVPool:
@@ -265,7 +265,7 @@ def pv_pool(
265265
exist, a new one is created and used for creating the `PVPool`.
266266
267267
Args:
268-
pv_inverter_ids: Optional set of IDs of PV inverters to be managed by the
268+
component_ids: Optional set of IDs of PV inverters to be managed by the
269269
`PVPool`.
270270
name: An optional name used to identify this instance of the pool or a
271271
corresponding actor in the logs.
@@ -282,8 +282,8 @@ def pv_pool(
282282

283283
# We use frozenset to make a hashable key from the input set.
284284
ref_store_key: frozenset[int] = frozenset()
285-
if pv_inverter_ids is not None:
286-
ref_store_key = frozenset(pv_inverter_ids)
285+
if component_ids is not None:
286+
ref_store_key = frozenset(component_ids)
287287

288288
pool_key = f"{ref_store_key}-{priority}"
289289
if pool_key in self._known_pool_keys:
@@ -294,7 +294,7 @@ def pv_pool(
294294
"consider reusing the same instance."
295295
"\n Hint: If the instances are created from different actors, "
296296
"consider using different priorities to distinguish them.",
297-
pv_inverter_ids,
297+
component_ids,
298298
priority,
299299
)
300300
else:
@@ -313,7 +313,7 @@ def pv_pool(
313313
power_manager_bounds_subs_sender=(
314314
self._pv_power_wrapper.bounds_subscription_channel.new_sender()
315315
),
316-
component_ids=pv_inverter_ids,
316+
component_ids=component_ids,
317317
)
318318

319319
return PVPool(self._pv_pool_reference_stores[ref_store_key], name, priority)
@@ -331,17 +331,17 @@ def grid(self) -> Grid:
331331

332332
def battery_pool(
333333
self,
334-
battery_ids: abc.Set[int] | None = None,
334+
component_ids: abc.Set[int] | None = None,
335335
name: str | None = None,
336336
priority: int = -sys.maxsize - 1,
337337
) -> BatteryPool:
338338
"""Return a new `BatteryPool` instance for the given ids.
339339
340-
If a `BatteryPoolReferenceStore` instance for the given battery ids doesn't exist,
341-
a new one is created and used for creating the `BatteryPool`.
340+
If a `BatteryPoolReferenceStore` instance for the given battery ids doesn't
341+
exist, a new one is created and used for creating the `BatteryPool`.
342342
343343
Args:
344-
battery_ids: Optional set of IDs of batteries to be managed by the
344+
component_ids: Optional set of IDs of batteries to be managed by the
345345
`BatteryPool`.
346346
name: An optional name used to identify this instance of the pool or a
347347
corresponding actor in the logs.
@@ -360,8 +360,8 @@ def battery_pool(
360360

361361
# We use frozenset to make a hashable key from the input set.
362362
ref_store_key: frozenset[int] = frozenset()
363-
if battery_ids is not None:
364-
ref_store_key = frozenset(battery_ids)
363+
if component_ids is not None:
364+
ref_store_key = frozenset(component_ids)
365365

366366
pool_key = f"{ref_store_key}-{priority}"
367367
if pool_key in self._known_pool_keys:
@@ -372,7 +372,7 @@ def battery_pool(
372372
"consider reusing the same instance."
373373
"\n Hint: If the instances are created from different actors, "
374374
"consider using different priorities to distinguish them.",
375-
battery_ids,
375+
component_ids,
376376
priority,
377377
)
378378
else:
@@ -393,7 +393,7 @@ def battery_pool(
393393
self._battery_power_wrapper.bounds_subscription_channel.new_sender()
394394
),
395395
min_update_interval=self._resampler_config.resampling_period,
396-
batteries_id=battery_ids,
396+
batteries_id=component_ids,
397397
)
398398
)
399399

@@ -505,7 +505,7 @@ def producer() -> Producer:
505505

506506

507507
def ev_charger_pool(
508-
ev_charger_ids: abc.Set[int] | None = None,
508+
component_ids: abc.Set[int] | None = None,
509509
name: str | None = None,
510510
priority: int = -sys.maxsize - 1,
511511
) -> EVChargerPool:
@@ -528,7 +528,7 @@ def ev_charger_pool(
528528
power.
529529
530530
Args:
531-
ev_charger_ids: Optional set of IDs of EV Chargers to be managed by the
531+
component_ids: Optional set of IDs of EV Chargers to be managed by the
532532
EVChargerPool. If not specified, all EV Chargers available in the
533533
component graph are used.
534534
name: An optional name used to identify this instance of the pool or a
@@ -538,11 +538,11 @@ def ev_charger_pool(
538538
Returns:
539539
An `EVChargerPool` instance.
540540
"""
541-
return _get().ev_charger_pool(ev_charger_ids, name, priority)
541+
return _get().ev_charger_pool(component_ids, name, priority)
542542

543543

544544
def battery_pool(
545-
battery_ids: abc.Set[int] | None = None,
545+
component_ids: abc.Set[int] | None = None,
546546
name: str | None = None,
547547
priority: int = -sys.maxsize - 1,
548548
) -> BatteryPool:
@@ -565,20 +565,21 @@ def battery_pool(
565565
power.
566566
567567
Args:
568-
battery_ids: Optional set of IDs of batteries to be managed by the `BatteryPool`.
569-
If not specified, all batteries available in the component graph are used.
568+
component_ids: Optional set of IDs of batteries to be managed by the
569+
`BatteryPool`. If not specified, all batteries available in the component
570+
graph are used.
570571
name: An optional name used to identify this instance of the pool or a
571572
corresponding actor in the logs.
572573
priority: The priority of the actor making the call.
573574
574575
Returns:
575576
A `BatteryPool` instance.
576577
"""
577-
return _get().battery_pool(battery_ids, name, priority)
578+
return _get().battery_pool(component_ids, name, priority)
578579

579580

580581
def pv_pool(
581-
pv_inverter_ids: abc.Set[int] | None = None,
582+
component_ids: abc.Set[int] | None = None,
582583
name: str | None = None,
583584
priority: int = -sys.maxsize - 1,
584585
) -> PVPool:
@@ -601,7 +602,7 @@ def pv_pool(
601602
power.
602603
603604
Args:
604-
pv_inverter_ids: Optional set of IDs of PV inverters to be managed by the
605+
component_ids: Optional set of IDs of PV inverters to be managed by the
605606
`PVPool`. If not specified, all PV inverters available in the component
606607
graph are used.
607608
name: An optional name used to identify this instance of the pool or a
@@ -611,7 +612,7 @@ def pv_pool(
611612
Returns:
612613
A `PVPool` instance.
613614
"""
614-
return _get().pv_pool(pv_inverter_ids, name, priority)
615+
return _get().pv_pool(component_ids, name, priority)
615616

616617

617618
def grid() -> Grid:

tests/timeseries/_battery_pool/test_battery_pool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ async def test_battery_pool_power_incomplete_bat_request(mocker: MockerFixture)
588588
with pytest.raises(FormulaGenerationError):
589589
# Request only two of the three batteries behind the inverters
590590
battery_pool = microgrid.battery_pool(
591-
battery_ids=set([bats[1].component_id, bats[0].component_id])
591+
component_ids=set([bats[1].component_id, bats[0].component_id])
592592
)
593593
power_receiver = battery_pool.power.new_receiver()
594594
await mockgrid.mock_resampler.send_bat_inverter_power([2.0])

0 commit comments

Comments
 (0)