FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Aggregate all metric config bounds into a `BoundsSet` by llucax · Pull Request #268 · frequenz-floss/frequenz-client-common-python · GitHub

Repository navigation

Aggregate all metric config bounds into a BoundsSet - #268

Merged
llucax merged 3 commits into
frequenz-floss:v0.x.xfrom
llucax:metric-config-bounds-set
Aug 14, 2026
Merged

llucax merged 3 commits into
frequenz-floss:v0.x.xfrom
llucax:metric-config-bounds-set

Conversation

llucax commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

ElectricalComponent.metric_config_bounds comes from the repeated MetricConfigBounds metric_config_bounds wire field, which is not a protobuf map. The converter nonetheless keyed a dict by metric and did bounds[metric] = ... on each entry, so when a metric appeared more than once the later entry silently overwrote the earlier one. Conflicting operational limits were lost with no diagnostic on the returned mapping or electrical_component_from_proto_with_issues().

Aggregate every entry for a metric instead, reusing bounds_set_from_proto. A metric whose entries are all well-formed maps to a BoundsSet (their union); a metric with any malformed entry maps to an InvalidBoundsSet preserving all the raw bounds in wire order, so the conflict stays inspectable.

As a consequence the field is now typed Mapping[Metric | int, BoundsSet | InvalidBoundsSet], and get_metric_config_bounds() resolves an entry to a valid BoundsSet (defaulting to the unbounded BoundsSet()) or raises InvalidBoundsSetError.

llucax added 3 commits August 14, 2026 14:26
`_bounds_set_from_proto` converts a sequence of protobuf `Bounds` into
a `BoundsSet | InvalidBoundsSet`. That is a bounds converter, so its
natural home is `_bounds.py` next to `bounds_from_proto2` (which it
calls), not `_sample.py`, where it only happened to be first needed.

Relocating it lets other converters reuse it without reaching into the
sample module — in particular the electrical-component metric config
bounds converter, which is about to aggregate duplicate metrics through
the same helper.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
`bounds_set_from_proto` is the multi-bound counterpart of the public
`bounds_from_proto2`: it converts a `repeated Bounds` field into a
single `BoundsSet | InvalidBoundsSet`, surfacing malformed data at the
type level.

It was module-private, but any client reading a repeated bounds field
needs the exact same conversion, so we better expose it in the public
package.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
`ElectricalComponent.metric_config_bounds` comes from the `repeated
MetricConfigBounds metric_config_bounds` wire field, which is *not* a
protobuf map. The converter nonetheless keyed a dict by metric and did
`bounds[metric] = ...` on each entry, so when a metric appeared more
than once the later entry silently overwrote the earlier one.
Conflicting operational limits were lost with no diagnostic on the
returned mapping or `electrical_component_from_proto_with_issues()`.

Aggregate every entry for a metric instead, reusing
`bounds_set_from_proto`. A metric whose entries are all well-formed maps
to a `BoundsSet` (their union); a metric with any malformed entry maps
to an `InvalidBoundsSet` preserving all the raw bounds in wire order,
so the conflict stays inspectable.

As a consequence the field is now typed `Mapping[Metric | int,
BoundsSet | InvalidBoundsSet]`, and `get_metric_config_bounds()`
resolves an entry to a valid `BoundsSet` (defaulting to the unbounded
`BoundsSet()`) or raises `InvalidBoundsSetError`.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
llucax requested a review from a team as a code owner August 14, 2026 12:30
llucax requested review from florian-wagner-frequenz and removed request for a team August 14, 2026 12:30
github-actions Bot added part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:tooling Affects the development tooling (CI, deployment, dependency management, etc.) part:metrics Affects the metrics protobuf definitions part:microgrid Affects the microgrid protobuf definitions labels Aug 14, 2026
llucax self-assigned this Aug 14, 2026
llucax added this to the v0.4.1 milestone Aug 14, 2026
llucax enabled auto-merge August 14, 2026 12:31
llucax added this pull request to the merge queue Aug 14, 2026
Merged via the queue into frequenz-floss:v0.x.x with commit 9d02f48 Aug 14, 2026
9 checks passed
llucax deleted the metric-config-bounds-set branch August 14, 2026 15:11
llucax added a commit to llucax/frequenz-client-common-python that referenced this pull request Sep 16, 2026
* Mention that `metric_config_bounds` keys also store the raw `0` for
  unspecified metrics (frequenz-floss#224).
* Merge the two `Microgrid` bullets, which described the same addition.
* Describe the `ElectricalComponent` boolean accessors (frequenz-floss#237), the
  `CategorySpecificInfo` field (frequenz-floss#257, frequenz-floss#273) and the aggregated
  `metric_config_bounds` (frequenz-floss#268).
* Add a compact list of the smaller supporting types from frequenz-floss#248 and
  frequenz-floss#249 (`Invalid{Latitude,Longitude,CountryCode}`, `InvalidLifetime`
  and their errors).

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
llucax added a commit to llucax/frequenz-client-common-python that referenced this pull request Sep 16, 2026
Fill the gaps found in a pre-release sanity check of `RELEASE_NOTES.md`:

* Replace the template placeholder with a real release summary,
including release stats and the note that this is a huge release despite
the patch version, realizing the new library design while keeping
backwards compatibility, with the breaking cleanup to follow in v0.5.0.
* Document two breaking changes to symbols released in v0.4.0 that were
missing from Upgrading: `Bounds` raising on `NaN` endpoints (frequenz-floss#254) and
`MetricConnection.name` no longer being optional (frequenz-floss#257).
* Complete the `UNSPECIFIED`-as-`0` bullet with `metric_config_bounds`
keys (frequenz-floss#224), merge the duplicated `Microgrid` bullets, and briefly cover
the `ElectricalComponent` accessors, `CategorySpecificInfo` and the
smaller `Invalid*` types from frequenz-floss#237, frequenz-floss#248, frequenz-floss#249, frequenz-floss#257, frequenz-floss#268 and frequenz-floss#273.
* Add the `str()` exception message change (frequenz-floss#258) to Bug Fixes.

The `PaginationInfo` breaking change from frequenz-floss#217 is documented separately
in frequenz-floss#285, which adds `InvalidPaginationInfo` and
`pagination_info_from_proto2`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:docs Affects the documentation part:metrics Affects the metrics protobuf definitions part:microgrid Affects the microgrid protobuf definitions part:tests Affects the unit, integration and performance (benchmarks) tests part:tooling Affects the development tooling (CI, deployment, dependency management, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL