Skip to content

Commit 55ddbe0

Browse files
Upgrade to api v0.5.0
Signed-off-by: Flora <[email protected]>
1 parent 793bdd0 commit 55ddbe0

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

RELEASE_NOTES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
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 frequenz-api-reporting 0.6
1010

1111
## New Features
1212

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ 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.2.0, < 0.6",
3232
"frequenz-client-common >= 0.2.0, < 0.3",
3333
"grpcio >= 1.54.2, < 2",
3434
"grpcio-tools >= 1.54.2, < 2",

src/frequenz/client/reporting/_client.py

Lines changed: 14 additions & 6 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
@@ -123,11 +128,8 @@ def __iter__(self) -> Iterator[MetricSample]:
123128
"warning": state.warnings,
124129
"error": state.errors,
125130
}.items():
126-
# Skip if the category is not present
127131
if not isinstance(category, Iterable):
128132
continue
129-
# Each category can have multiple states
130-
# that are provided as individual samples
131133
for s in category:
132134
yield MetricSample(
133135
timestamp=ts,
@@ -317,11 +319,17 @@ def dt2ts(dt: datetime) -> PBTimestamp:
317319
include_options=include_options,
318320
)
319321

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

322330
request = PBReceiveMicrogridComponentsDataStreamRequest(
323331
microgrid_components=microgrid_components_pb,
324-
metrics=metrics_pb,
332+
metrics=metric_conns_pb,
325333
filter=stream_filter,
326334
)
327335

0 commit comments

Comments
 (0)