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: 4 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

* `Dispatch.end_time` has been added to the `Dispatch` class, which is the time when the dispatch ended as calculated by the server. `dispatch-cli` will also print this time.

## Upgrading

* Renamed `Client` class to `DispatchApiClient` for clarity.

## Bug Fixes

* Fix that `dispatch-cli stream` would try to print an event as dispatch, causing an exception.
Expand Down
4 changes: 2 additions & 2 deletions src/frequenz/client/dispatch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

"""Dispatch API client for Python."""

from ._client import Client
from ._client import DispatchApiClient

__all__ = ["Client"]
__all__ = ["DispatchApiClient"]
4 changes: 2 additions & 2 deletions src/frequenz/client/dispatch/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
JsonDictParamType,
TargetComponentParamType,
)
from ._client import Client
from ._client import DispatchApiClient
from .recurrence import EndCriteria, Frequency, RecurrenceRule, Weekday
from .types import Dispatch, DispatchEvent

Expand Down Expand Up @@ -193,7 +193,7 @@ async def cli(ctx: click.Context, url: str, key: str, raw: bool) -> None:

click.echo(f"Using API URL: {url}", err=True)

ctx.obj["client"] = Client(
ctx.obj["client"] = DispatchApiClient(
server_url=url,
key=key,
connect=True,
Expand Down
6 changes: 3 additions & 3 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[dispatch_pb2_grpc.MicrogridDispatchServiceStub]):
class DispatchApiClient(BaseApiClient[dispatch_pb2_grpc.MicrogridDispatchServiceStub]):
"""Dispatch API client."""

def __init__(
Expand Down Expand Up @@ -125,7 +125,7 @@ async def list(
Example usage:

```python
client = Client(key="key", server_url="grpc://fz-0004.frequenz.io")
client = DispatchApiClient(key="key", server_url="grpc://fz-0004.frequenz.io")
async for page in client.list(microgrid_id=1):
for dispatch in page:
print(dispatch)
Expand Down Expand Up @@ -207,7 +207,7 @@ def stream(self, microgrid_id: int) -> channels.Receiver[DispatchEvent]:
Example usage:

```
client = Client(key="key", server_url="grpc://fz-0004.frequenz.io")
client = DispatchApiClient(key="key", server_url="grpc://fz-0004.frequenz.io")
async for message in client.stream(microgrid_id=1):
print(message.event, message.dispatch)
```
Expand Down
4 changes: 2 additions & 2 deletions src/frequenz/client/dispatch/test/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

from typing import Any

from .. import Client
from .. import DispatchApiClient
from ..types import Dispatch
from ._service import ALL_KEY, NONE_KEY, FakeService

__all__ = ["FakeClient", "to_create_params", "ALL_KEY", "NONE_KEY"]


class FakeClient(Client):
class FakeClient(DispatchApiClient):
"""Fake client for testing.

This client uses a fake service to simulate the dispatch api.
Expand Down
4 changes: 3 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def fake_client() -> FakeClient:
@pytest.fixture(autouse=True)
def mock_client(fake_client: FakeClient) -> Generator[None, None, None]:
"""Fixture to mock get_client with FakeClient."""
with patch("frequenz.client.dispatch.__main__.Client", return_value=fake_client):
with patch(
"frequenz.client.dispatch.__main__.DispatchApiClient", return_value=fake_client
):
yield


Expand Down
Loading