From 4c9997e515feeb0a012fa94f53d41c5b5ba0960d Mon Sep 17 00:00:00 2001 From: cwasicki <126617870+cwasicki@users.noreply.github.com> Date: Wed, 17 Dec 2025 18:52:23 +0100 Subject: [PATCH 1/3] Reset release notes Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com> --- RELEASE_NOTES.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 5632cace..f80f12ed 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -2,13 +2,11 @@ ## Summary -> **Warning:** This client is compatible *only* with Reporting API `v1alpha10` or later. -> Using with services that use an older API version **will cause failures**. + ## Upgrading -* Breaking change to reporting API v1alpha10. -* Switch to new `metrics` package from client-common. + ## New Features From 6a8336fec607c2314ee9b5b91320ec7c67615e07 Mon Sep 17 00:00:00 2001 From: cwasicki <126617870+cwasicki@users.noreply.github.com> Date: Wed, 17 Dec 2025 18:46:44 +0100 Subject: [PATCH 2/3] Fix aggregated values for None samples If the samples in the protobuf of the aggregated response has the value not set (e.g. when the service sends None values), the generated python code falls back to zeroes when the field is accessed. This case needs to be handled explicitly by the client, which now sets these values to NaN. Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com> --- src/frequenz/client/reporting/_types.py | 28 +++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/frequenz/client/reporting/_types.py b/src/frequenz/client/reporting/_types.py index 81473ccf..d8632ffa 100644 --- a/src/frequenz/client/reporting/_types.py +++ b/src/frequenz/client/reporting/_types.py @@ -3,6 +3,7 @@ """Types for the Reporting API client.""" +import math from collections.abc import Iterable, Iterator from dataclasses import dataclass from datetime import datetime @@ -180,10 +181,25 @@ class AggregatedMetric: def sample(self) -> MetricSample: """Return the aggregated metric sample.""" - return MetricSample( - timestamp=datetime_from_proto(self._data_pb.sample.sample_time), - microgrid_id=self._data_pb.aggregation_config.microgrid_id, - component_id=self._data_pb.aggregation_config.aggregation_formula, - metric=Metric(self._data_pb.aggregation_config.metric).name, - value=self._data_pb.sample.sample.value, + config = self._data_pb.aggregation_config + sample = self._data_pb.sample + + timestamp = datetime_from_proto(sample.sample_time) + microgrid_id = config.microgrid_id + component_id = config.aggregation_formula + metric = Metric(config.metric).name + # Ignoring this verification results in + # values of zero if the field is not set. + if sample.HasField("sample") and sample.sample.HasField("value"): + value = sample.sample.value + else: + value = math.nan + + ret = MetricSample( + timestamp=timestamp, + microgrid_id=microgrid_id, + component_id=component_id, + metric=metric, + value=value, ) + return ret From 4d9fde6dde57d91358583c052d05b4012f4a807c Mon Sep 17 00:00:00 2001 From: cwasicki <126617870+cwasicki@users.noreply.github.com> Date: Wed, 17 Dec 2025 18:53:48 +0100 Subject: [PATCH 3/3] Update release notes Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com> --- RELEASE_NOTES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index f80f12ed..17f924e8 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -14,4 +14,4 @@ ## Bug Fixes - +* Fix default value of formula-aggregated metrics when no data was sent.