Skip to content

Commit 7325c98

Browse files
authored
Bump client-base to v0.4.0 (#44)
We need this to be able to use it with `grpclib` instead of `grpcio`.
2 parents 67de281 + 4ec46d2 commit 7325c98

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
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+
- The client is now using [`grpclib`](https://pypi.org/project/grpclib/) to connect to the server instead of [`grpcio`](https://pypi.org/project/grpcio/). You might need to adapt the way you connect to the server in your code, using `grpcio.client.Channel` and catching `grpcio.GRPCError` exceptions.
1010

1111
## New Features
1212

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ requires-python = ">= 3.11, < 4"
3838
dependencies = [
3939
"frequenz-api-microgrid >= 0.15.3, < 0.16.0",
4040
"frequenz-channels >= 1.0.0-rc1, < 2.0.0",
41-
"frequenz-client-base >= 0.3.0, < 0.4.0",
41+
"frequenz-client-base[grpclib] >= 0.4.0, < 0.5",
4242
"grpcio >= 1.54.2, < 2",
4343
"protobuf >= 4.21.6, < 6",
4444
"timezonefinder >= 6.2.0, < 7",

src/frequenz/client/microgrid/_client.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import asyncio
77
import logging
8-
from collections.abc import Awaitable, Callable, Iterable
8+
from collections.abc import AsyncIterator, Awaitable, Callable, Iterable
99
from typing import Any, TypeVar, cast
1010

1111
import grpc.aio
@@ -266,10 +266,11 @@ async def _new_component_data_receiver(
266266
broadcaster = streaming.GrpcStreamBroadcaster(
267267
f"raw-component-data-{component_id}",
268268
# We need to cast here because grpc says StreamComponentData is
269-
# a grpc.CallIterator[PbComponentData], not a
270-
# grpc.aio.UnaryStreamCall[..., PbComponentData].
269+
# a grpc.CallIterator[PbComponentData] which is not an AsyncIterator,
270+
# but it is a grpc.aio.UnaryStreamCall[..., PbComponentData], which it
271+
# is.
271272
lambda: cast(
272-
grpc.aio.UnaryStreamCall[Any, PbComponentData],
273+
AsyncIterator[PbComponentData],
273274
self.api.StreamComponentData(PbComponentIdParam(id=component_id)),
274275
),
275276
transform,

0 commit comments

Comments
 (0)