Frequenz-client-base

Latest version: v0.8.1

Safety actively analyzes 688572 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 2

0.8.1

Frequenz Client Base Library Release Notes

Summary

<!-- Here goes a general summary of what this release is about -->

Upgrading

<!-- Here goes notes on how to upgrade from previous versions, including deprecations and what they should be replaced with -->

New Features

<!-- Here goes the main new features and examples or instructions on how to use them -->

Bug Fixes

<!-- Here goes notable bug fixes that are worth a special mention or explanation -->


What's Changed
* Clear release notes by llucax in https://github.com/frequenz-floss/frequenz-client-base-python/pull/97
* Remove unnecessary --platform flag in Dockerfile by llucax in https://github.com/frequenz-floss/frequenz-client-base-python/pull/98
* Update `parse_grpc_uri` docs with keep-alive params by shsms in https://github.com/frequenz-floss/frequenz-client-base-python/pull/99


**Full Changelog**: https://github.com/frequenz-floss/frequenz-client-base-python/compare/v0.8.0...v0.8.1

0.8.0

Frequenz Client Base Library Release Notes

Upgrading

The `BaseApiClient` class is generic again. There was too many issues with the new approach, so it was rolled back.

- If you are upgrading from v0.7.x, you should be able to roll back your changes with the upgrade and just keep the new `stub` property.

python
Old
from __future__ import annotations
import my_service_pb2_grpc
class MyApiClient(BaseApiClient):
def __init__(self, server_url: str, *, ...) -> None:
super().__init__(server_url, ...)
stub = my_service_pb2_grpc.MyServiceStub(self.channel)
self._stub: my_service_pb2_grpc.MyServiceAsyncStub = stub type: ignore
...

property
def stub(self) -> my_service_pb2_grpc.MyServiceAsyncStub:
if self.channel is None:
raise ClientNotConnected(server_url=self.server_url, operation="stub")
return self._stub

New
from __future__ import annotations
import my_service_pb2_grpc
from my_service_pb2_grpc import MyServiceStub
class MyApiClient(BaseApiClient[MyServiceStub]):
def __init__(self, server_url: str, *, ...) -> None:
super().__init__(server_url, MyServiceStub, ...)
...

property
def stub(self) -> my_service_pb2_grpc.MyServiceAsyncStub:
"""The gRPC stub for the API."""
if self.channel is None or self._stub is None:
raise ClientNotConnected(server_url=self.server_url, operation="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


- If you are upgrading from v0.6.x, you should only need to add the `stub` property to your client class and then use that property instead of `_stub` in your code.

python
property
def stub(self) -> my_service_pb2_grpc.MyServiceAsyncStub:
"""The gRPC stub for the API."""
if self.channel is None or self._stub is None:
raise ClientNotConnected(server_url=self.server_url, operation="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



What's Changed
* Clear release notes by shsms in https://github.com/frequenz-floss/frequenz-client-base-python/pull/94
* Bump the required group with 9 updates by dependabot in https://github.com/frequenz-floss/frequenz-client-base-python/pull/95
* Revert "Remove generic type from `BaseApiClient`" by llucax in https://github.com/frequenz-floss/frequenz-client-base-python/pull/96


**Full Changelog**: https://github.com/frequenz-floss/frequenz-client-base-python/compare/v0.7.0...v0.8.0

0.7.0

Frequenz Client Base Library Release Notes

Summary

This release improves the `BaseApiClient` interface and introduces HTTP2 keep-alive, among other changes.

Upgrading

- `GrpcStreamBroadcaster` now takes a `AsyncIterable` instead of a `AsyncIterator` as the `stream_method`. This is to match the type of streaming methods generated by `grpc`, so no conversion to an `AsyncIterator` is needed.

- `GrpcStreamBroadcaster` no longer tries to reconnect when a server closes a connection. This behaviour can be overridden by passing `retry_on_exhausted_stream=True` when constructing `GrpcStreamBroadcaster` instances.

- gRPC URLs don't have a default port anymore, unless a default is set via `ChannelOptions`. If you want to set a default port for URLs, please pass custom `ChannelOptions` as `defaults` to `parse_grpc_uri` or as `channel_defaults` to `BaseApiClient`.

* The `ExponentialBackoff` and `LinearBackoff` classes now require keyword arguments for their constructor. This change was made to make the classes easier to use and to avoid confusion with the order of the arguments.

- HTTP2 keep-alive is now enabled by default, with an interval of 60 seconds between pings, and a 20 second timeout for responses from the service. These values are configurable and may be updated based on specific requirements.

* The `BaseApiClient` class is not generic anymore, and doesn't take a function to create the stub. Instead, subclasses should create their own stub right after calling the parent constructor. This enables subclasses to cast the stub to the generated `XxxAsyncStub` class, which have proper `async` type hints. To convert you client:

python
Old
from my_service_pb2_grpc import MyServiceStub
class MyApiClient(BaseApiClient[MyServiceStub]):
def __init__(self, server_url: str, *, ...) -> None:
super().__init__(server_url, MyServiceStub, ...)
...

New
from __future__ import annotations
import my_service_pb2_grpc
class MyApiClient(BaseApiClient):
def __init__(self, server_url: str, *, ...) -> None:
super().__init__(server_url, connect=connect)
stub = my_service_pb2_grpc.MyServiceStub(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: my_service_pb2_grpc.MyServiceAsyncStub = stub type: ignore
...

property
def stub(self) -> my_service_pb2_grpc.MyServiceAsyncStub:
if self.channel is None:
raise ClientNotConnected(server_url=self.server_url, operation="stub")
return self._stub


You probably also need to ignore the `no-member` check from `pylint`, as `pylint` doesn't read `*.pyi` files, so it won't find the `async` stub and complain.

toml
[tool.pylint.messages_control]
disable = [
[..]
Checked by mypy
"no-member",
[..]
]


After this, you should be able to remove a lot of `cast`s or `type: ignore` from the code when calling the stub `async` methods.

New Features

- Added support for HTTP2 keep-alive.


What's Changed
* Clear release notes by shsms in https://github.com/frequenz-floss/frequenz-client-base-python/pull/83
* Replace the `stream_method` return to `AsyncIterable` by llucax in https://github.com/frequenz-floss/frequenz-client-base-python/pull/87
* Don't allow a default port in URLs by default by llucax in https://github.com/frequenz-floss/frequenz-client-base-python/pull/85
* Bump the required group with 9 updates by dependabot in https://github.com/frequenz-floss/frequenz-client-base-python/pull/89
* Don't retry by default when the stream is exhausted by shsms in https://github.com/frequenz-floss/frequenz-client-base-python/pull/91
* Support http2 keep-alive by shsms in https://github.com/frequenz-floss/frequenz-client-base-python/pull/90
* Remove generic type from `BaseApiClient` by llucax in https://github.com/frequenz-floss/frequenz-client-base-python/pull/92
* Prepare for v0.7.0 by shsms in https://github.com/frequenz-floss/frequenz-client-base-python/pull/93


**Full Changelog**: https://github.com/frequenz-floss/frequenz-client-base-python/compare/v0.6.1...v0.7.0

0.6.1

Frequenz Client Base Library Release Notes

Bug Fixes

- Fixes a bug in creating grpc channels from ipv6 URIs.


What's Changed
* Clear release notes by llucax in https://github.com/frequenz-floss/frequenz-client-base-python/pull/76
* Bump the required group with 9 updates by dependabot in https://github.com/frequenz-floss/frequenz-client-base-python/pull/78
* Use `netloc` from `urlparse` to specify the host by shsms in https://github.com/frequenz-floss/frequenz-client-base-python/pull/79
* Prepare release notes for v0.6.1 by shsms in https://github.com/frequenz-floss/frequenz-client-base-python/pull/82


**Full Changelog**: https://github.com/frequenz-floss/frequenz-client-base-python/compare/v0.6.0...v0.6.1

0.6.0

Frequenz Client Base Library Release Notes

Summary

This version removes `grpclib` support and adds new SSL options to the connection URI.

Upgrading

- `grpclib` was removed, if you used `grpclib` you should switch to `grpcio` instead.

You should also update your dependency to `frequenz-client-base` (without any `[grpclib]` or `[grpcio]` suffix). Also, now there is no need to pass around the channel type to the `BaseApiClient` or the `parse_grpc_uri` function.

- The `parse_grpc_uri` function (and `BaseApiClient` constructor) now enables SSL by default (`ssl=false` should be passed to disable it).

- The `parse_grpc_uri` and `BaseApiClient` function now accepts a set of defaults to use when the URI does not specify a value for a given option.

New Features

- The connection URI can now have a few new SSL options:

* `ssl_root_certificates_path` to specify the path to the root certificates file.
* `ssl_private_key_path` to specify the path to the private key file.
* `ssl_certificate_chain_path` to specify the path to the certificate chain file.


What's Changed
* Clear release notes by llucax in https://github.com/frequenz-floss/frequenz-client-base-python/pull/64
* Use SSL by default by llucax in https://github.com/frequenz-floss/frequenz-client-base-python/pull/67
* Remove support for grpclib by llucax in https://github.com/frequenz-floss/frequenz-client-base-python/pull/71
* Bump the required group across 1 directory with 13 updates by dependabot in https://github.com/frequenz-floss/frequenz-client-base-python/pull/72
* Allow passing SSL options via server URL by llucax in https://github.com/frequenz-floss/frequenz-client-base-python/pull/73
* Prepare release notes for v0.6.0 by llucax in https://github.com/frequenz-floss/frequenz-client-base-python/pull/75


**Full Changelog**: https://github.com/frequenz-floss/frequenz-client-base-python/compare/v0.5.0...v0.6.0

0.5.0

Frequenz Client Base Library Release Notes

Summary

The main features of this release is the new base class for API clients, gRPC exception wrappers and a new utility function to call stub methods.

Upgrading

- `channel.parse_grpc_uri()` takes an extra argument, the channel type (which can be either `grpclib.client.Channel` or `grpcio.aio.Channel`).

New Features

- Add a `exception` module to provide client exceptions, including gRPC errors with one subclass per gRPC error status code.
- `channel.parse_grpc_uri()` can now be used with `grpcio` too.
- A new `BaseApiClient` class is introduced to provide a base class for API clients. It is strongly recommended to use this class as a base class for all API clients.
- A new `call_stub_method()` function to simplify calling stub methods, converting gRPC errors to `ApiClientError`s, checking if the client is connected and optionally wrapping the response.


What's Changed
* Clear the release notes by llucax in https://github.com/frequenz-floss/frequenz-client-base-python/pull/53
* Add client exceptions by llucax in https://github.com/frequenz-floss/frequenz-client-base-python/pull/55
* Bump the required group with 7 updates by dependabot in https://github.com/frequenz-floss/frequenz-client-base-python/pull/57
* Add `grpcio` support to `parse_grpc_uri()` by llucax in https://github.com/frequenz-floss/frequenz-client-base-python/pull/54
* Add a `BaseApiClient` class by llucax in https://github.com/frequenz-floss/frequenz-client-base-python/pull/56
* Improve type-checking for `_grpchacks` by llucax in https://github.com/frequenz-floss/frequenz-client-base-python/pull/59
* Add a function to call gRPC stubs and wrap errors by llucax in https://github.com/frequenz-floss/frequenz-client-base-python/pull/58
* Bump docker/build-push-action from 5 to 6 by dependabot in https://github.com/frequenz-floss/frequenz-client-base-python/pull/61
* Bump the required group with 9 updates by dependabot in https://github.com/frequenz-floss/frequenz-client-base-python/pull/60
* Bump brettcannon/check-for-changed-files from 1.2.0 to 1.2.1 by dependabot in https://github.com/frequenz-floss/frequenz-client-base-python/pull/62
* Prepare release notes for the 0.5 release by llucax in https://github.com/frequenz-floss/frequenz-client-base-python/pull/63


**Full Changelog**: https://github.com/frequenz-floss/frequenz-client-base-python/compare/v0.4.0...v0.5.0

Page 1 of 2

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.