Skip to content

Commit f5e08fc

Browse files
Upgrade to api v0.5.0
Signed-off-by: Flora <[email protected]>
1 parent 67b9708 commit f5e08fc

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

RELEASE_NOTES.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
## Upgrading
88

9-
<!-- Here goes notes on how to upgrade from previous versions, including deprecations and what they should be replaced with -->
9+
* Update to use the newest release of api-reporting.
10+
This update has a dependency on the serivce as it introduces MetricConnections.
1011

1112
## New Features
1213

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ requires-python = ">= 3.11, < 4"
2828
dependencies = [
2929
"typing_extensions >= 4.6.1, < 5",
3030
"grpc-stubs == 1.53.0.5",
31-
"frequenz-api-reporting >= 0.2.0, < 0.5",
31+
"frequenz-api-reporting >= 0.5.0, < 0.6",
3232
"frequenz-client-common >= 0.2.0, < 0.3",
33-
"grpcio >= 1.54.2, < 2",
34-
"grpcio-tools >= 1.54.2, < 2",
35-
"protobuf >= 4.25.3, < 6",
33+
"grpcio >=1.66.1, < 2",
34+
"grpcio-tools >=1.66.1, < 2",
35+
"protobuf >=5.28.2, < 6",
3636
"frequenz-client-base >= 0.8.0, < 0.9.0",
3737
]
3838
dynamic = ["version"]

src/frequenz/client/reporting/_client.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
MicrogridComponentIDs as PBMicrogridComponentIDs,
1717
)
1818
from frequenz.api.reporting.v1.reporting_pb2 import IncludeOptions as PBIncludeOptions
19+
from frequenz.api.reporting.v1.reporting_pb2 import (
20+
MetricConnections as PBMetricConnections,
21+
)
1922
from frequenz.api.reporting.v1.reporting_pb2 import (
2023
ReceiveMicrogridComponentsDataStreamRequest as PBReceiveMicrogridComponentsDataStreamRequest,
2124
)
@@ -33,7 +36,8 @@
3336
from google.protobuf.timestamp_pb2 import Timestamp as PBTimestamp
3437

3538
MetricSample = namedtuple(
36-
"MetricSample", ["timestamp", "microgrid_id", "component_id", "metric", "value"]
39+
"MetricSample",
40+
["timestamp", "microgrid_id", "component_id", "metric", "value"],
3741
)
3842
"""Type for a sample of a time series incl. metric type, microgrid and component ID
3943
@@ -65,6 +69,7 @@ def is_empty(self) -> bool:
6569
return True
6670
return False
6771

72+
# pylint: disable=too-many-locals
6873
def __iter__(self) -> Iterator[MetricSample]:
6974
"""Get generator that iterates over all values in the batch.
7075
@@ -126,8 +131,6 @@ def __iter__(self) -> Iterator[MetricSample]:
126131
# Skip if the category is not present
127132
if not isinstance(category, Iterable):
128133
continue
129-
# Each category can have multiple states
130-
# that are provided as individual samples
131134
for s in category:
132135
yield MetricSample(
133136
timestamp=ts,
@@ -317,11 +320,17 @@ def dt2ts(dt: datetime) -> PBTimestamp:
317320
include_options=include_options,
318321
)
319322

320-
metrics_pb = [metric.to_proto() for metric in metrics]
323+
metric_conns_pb = [
324+
PBMetricConnections(
325+
metric=metric.to_proto(),
326+
connections=[],
327+
)
328+
for metric in metrics
329+
]
321330

322331
request = PBReceiveMicrogridComponentsDataStreamRequest(
323332
microgrid_components=microgrid_components_pb,
324-
metrics=metrics_pb,
333+
metrics=metric_conns_pb,
325334
filter=stream_filter,
326335
)
327336

0 commit comments

Comments
 (0)