Skip to content

Share reference stores between pools for all and explicit components - #1476

Merged
Marenz merged 2 commits into
frequenz-floss:v1.x.xfrom
shsms:pool-reference-store-keys
Oct 30, 2026
Merged

Marenz merged 2 commits into
frequenz-floss:v1.x.xfrom
shsms:pool-reference-store-keys

Conversation

@shsms

@shsms shsms commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

A pool created without component IDs was keyed by an empty set, so it didn't share its reference store with the pool the power manager creates for the explicit IDs of the same components. This branch keys the stores by the resolved component IDs, and fixes the duplicate-pool warning, which had the same keying problem.

Changes

  • ComponentPoolReferenceStore.resolve_component_ids() turns None or an empty set into all the IDs of the pool's type. _DataPipeline.new_*_pool() uses the result as the store key and passes it to the store, so the key and store.component_ids are the same set.
  • The duplicate-pool warning is keyed by (store class, IDs, priority) instead of the text of the IDs. Equal sets can print in different orders, so the old key sometimes missed duplicates, and pools of different types without components warned about each other. The warning now prints the resolved IDs and the right new_*_pool() name.
  • The tests run for all four pool types. Worth a look: the 6-component setup in test_pool_for_all_components_warns_like_explicit_ids. Its comment explains why a key made from the text of the IDs fails there.
  • Side effect: report channel names come from the text of the store's ID set (ReportRequest.get_channel_name()). Before, two pools for the same batteries at the same priority could get names that didn't match, so the second pool's power_status channel never got a sender. Sharing one store fixes that.

shsms added 2 commits October 29, 2026 18:11
A pool created without component IDs, or with an empty set, was keyed by
an empty set, so it didn't share its reference store with the power
manager's pool for the same components, and each tracked the power
bounds of the same components on its own.

Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
The data pipeline warns when the same pool is created twice at the same
priority, but it compared a string of the component IDs. Two equal sets
of component IDs can print in different orders, so the warning was
sometimes missed. The key now also holds the pool's reference store
class, so pools of different types that have no components don't warn
about each other.

The warning now names the components the pool resolved to, not the
`component_ids` argument, which is `None` or an empty set when no IDs
are given. It also names the right `new_*_pool()` function.

Signed-off-by: Sahas Subramanian <sahas.subramanian@proton.me>
@shsms
shsms requested a review from a team as a code owner October 29, 2026 17:16
@shsms
shsms requested review from Marenz and removed request for a team October 29, 2026 17:16
@github-actions github-actions Bot added part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:data-pipeline Affects the data pipeline part:microgrid Affects the interactions with the microgrid labels Oct 29, 2026

@Marenz Marenz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I checked that the new tests fail on v1.x.x and pass here, and that sharing the store is safe: everything in it depends only on the component set.

A few small things:

  1. The warnings still name the old parameters (ev_charger_ids=%s, pv_inverter_ids=%s, battery_ids=%s, steam_boiler_ids=%s in _data_pipeline.py); the keyword is component_ids now. Since this PR already edits those strings, maybe fix them too.
  2. The release note describes the mechanism, but the visible bug was worse: with 11 or more batteries, two pools for the same components at the same priority got differently spelled channel names, and one of them never got power_status updates (I reproduced this on v1.x.x). Maybe say that in the note.
  3. Nit: assert all_pool.power_status is explicit_pool.power_status in test_pools_for_all_components_share_reference_stores would pin that symptom directly.
  4. Nit: the 6-component test relies on the graph-built set printing in a different order than frozenset(ids), which only holds because all_component_ids() now uses a generator. An assert on that premise (or a more general comment) would keep it from silently losing its point.
  5. Nit, maybe a follow-up: ReportRequest.get_channel_name() still builds the name from the text of the set; sorting the IDs there would remove the order dependency for good.

@github-project-automation github-project-automation Bot moved this from To do to Review approved in Python SDK Roadmap Oct 30, 2026

@llucax llucax left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 rAIview (AI review here!)

I found no additional issues to raise. Resolving the component IDs before choosing the reference-store key consistently shares state between equivalent pools, while including the store class in the duplicate-warning key keeps different pool types separate. I found no breaking API changes or new security concerns.

@Marenz
Marenz added this pull request to the merge queue Oct 30, 2026
Merged via the queue into frequenz-floss:v1.x.x with commit ee0601b Oct 30, 2026
9 checks passed
@github-project-automation github-project-automation Bot moved this from Review approved to Done in Python SDK Roadmap Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:data-pipeline Affects the data pipeline part:docs Affects the documentation part:microgrid Affects the interactions with the microgrid part:tests Affects the unit, integration and performance (benchmarks) tests

Projects

Development

Successfully merging this pull request may close these issues.

3 participants