Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Frequenz Dispatch Client Library Release Notes

## Bug Fixes
## Summary

* The client was broken due to wrong usage of the new BaseClient API.
* The base client dependency was updated to v0.8.0.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ requires-python = ">= 3.11, < 4"
dependencies = [
"typing-extensions >= 4.6.1, < 5",
"frequenz-api-dispatch == 1.0.0-rc1",
"frequenz-client-base >= 0.7.0, < 0.8.0",
"frequenz-client-base >= 0.8.0, < 0.9.0",
"frequenz-client-common >= 0.1.0, < 0.3.0",
Comment on lines -41 to 42

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you update RELEASE_NOTES?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I usually update them if it's something the user can see, but nothing changed from their perspective in this case, just an indirect dependency

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the only issue with bumping dependencies with breaking changes is users are forced to upgrade the dependency too (the thing that is triggering all these release trains), which will force them to update the code because the changes are breaking. This is why we usually document disruptive dependency bumps, because it has a high potential of actually affecting the user at the end. But in development mode (v0.x.x) I think is not that bad if it is missing in the release notes, people are supposed to expect breakage anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair

"grpcio >= 1.66.1, < 2",
]
Expand Down
19 changes: 8 additions & 11 deletions src/frequenz/client/dispatch/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
DEFAULT_DISPATCH_PORT = 50051


class Client(BaseApiClient):
class Client(BaseApiClient[dispatch_pb2_grpc.MicrogridDispatchServiceStub]):
"""Dispatch API client."""

streams: dict[
Expand All @@ -76,6 +76,7 @@ def __init__(
"""
super().__init__(
server_url,
dispatch_pb2_grpc.MicrogridDispatchServiceStub,
connect=connect,
channel_defaults=ChannelOptions(
port=DEFAULT_DISPATCH_PORT,
Expand All @@ -90,21 +91,17 @@ def __init__(
),
)
self._metadata = (("key", key),)
self._setup_stub()

def _setup_stub(self) -> None:
stub = dispatch_pb2_grpc.MicrogridDispatchServiceStub(self.channel)
# We need the type: ignore here because the generated async stub only lives in
# the .pyi file (the interpreter doesn't know anything about it) so we can't use
# a proper `cast()`, we can only use the async stub as a type hint.
self._stub: dispatch_pb2_grpc.MicrogridDispatchServiceAsyncStub = stub # type: ignore

@property
def stub(self) -> dispatch_pb2_grpc.MicrogridDispatchServiceAsyncStub:
"""The stub for the service."""
if self._channel is None:
if self._channel is None or self._stub is None:
raise ClientNotConnected(server_url=self.server_url, operation="stub")
return self._stub
# This type: ignore is needed because we need to cast the sync stub to
# the async stub, but we can't use cast because the async stub doesn't
# actually exists to the eyes of the interpreter, it only exists for the
# type-checker, so it can only be used for type hints.
return self._stub # type: ignore

# pylint: disable=too-many-arguments, too-many-locals
async def list(
Expand Down
3 changes: 0 additions & 3 deletions src/frequenz/client/dispatch/test/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ def stub(self) -> FakeService: # type: ignore
"""
return self._stuba

def _setup_stub(self) -> None:
"""Empty body because no setup needed."""

def dispatches(self, microgrid_id: int) -> list[Dispatch]:
"""List of dispatches.

Expand Down
Loading