| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
`_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>
* 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>
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`.
| Back | FazBrowse Home | New Git URL |
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.