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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ pip install frequenz-client-dispatch
Here's a quick example to get you started:

```python
from frequenz.client.dispatch import Client
from frequenz.client.dispatch import DispatchApiClient
import asyncio

async def print_dispatches():
# Initialize the client
client = Client(key="your_api_key", server_url="grpc://fz-0004.frequenz.io")
client = DispatchApiClient(key="your_api_key", server_url="grpc://dispatch.eu-1.prod.api.frequenz.com:443")

# List all dispatches for a specific microgrid
async for page in client.list(microgrid_id=1):
Expand All @@ -39,7 +39,7 @@ async def print_dispatches():
asyncio.run(print_dispatches())
```

For detailed usage and advanced features, check out the [client documentation](https://frequenz-floss.github.io/frequenz-client-dispatch-python/latest/reference/frequenz/client/dispatch/#frequenz.client.dispatch.Client).
For detailed usage and advanced features, check out the [client documentation](https://frequenz-floss.github.io/frequenz-client-dispatch-python/latest/reference/frequenz/client/dispatch/#frequenz.client.dispatch.ApiDispatchClient).

## 🌐 Supported Platforms

Expand Down
2 changes: 1 addition & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## Bug Fixes

* `end_time` was not correctly handling the `None` value when converted from protobuf to pythons `Dispatch` class.
* Fix that a user might see invalid values for dispatches without `end_time`. It was not correctly handling the `None` value when converted from protobuf to pythons `Dispatch` class.
Copy link

Copilot AI May 14, 2025

Choose a reason for hiding this comment

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

[nitpick] There's a typo in 'pythons'; consider updating to 'Python's' for clarity.

Suggested change
* Fix that a user might see invalid values for dispatches without `end_time`. It was not correctly handling the `None` value when converted from protobuf to pythons `Dispatch` class.
* Fix that a user might see invalid values for dispatches without `end_time`. It was not correctly handling the `None` value when converted from protobuf to Python's `Dispatch` class.

Copilot uses AI. Check for mistakes.

## Upgrading

Expand Down
2 changes: 1 addition & 1 deletion src/frequenz/client/dispatch/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from .recurrence import EndCriteria, Frequency, RecurrenceRule, Weekday
from .types import Dispatch, DispatchEvent

DEFAULT_DISPATCH_API_URL = "grpc://fz-0004.frequenz.io:50051"
DEFAULT_DISPATCH_API_URL = "grpc://dispatch.eu-1.prod.api.frequenz.com:443"


def format_datetime(dt: datetime | None) -> str:
Expand Down
23 changes: 10 additions & 13 deletions src/frequenz/client/dispatch/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
from __future__ import annotations

from datetime import datetime, timedelta
from importlib.resources import files
from pathlib import Path
from typing import Any, AsyncIterator, Awaitable, Iterator, Literal, cast

# pylint: disable=no-name-in-module
Expand Down Expand Up @@ -49,7 +47,7 @@
)

# pylint: enable=no-name-in-module
DEFAULT_DISPATCH_PORT = 50051
DEFAULT_DISPATCH_PORT = 443


class DispatchApiClient(BaseApiClient[dispatch_pb2_grpc.MicrogridDispatchServiceStub]):
Expand All @@ -75,14 +73,7 @@ def __init__(
connect=connect,
channel_defaults=ChannelOptions(
port=DEFAULT_DISPATCH_PORT,
ssl=SslOptions(
enabled=True,
root_certificates=Path(
str(
files("frequenz.client.dispatch").joinpath("certs/root.crt")
),
),
),
ssl=SslOptions(enabled=True),
),
)
self._metadata = (("key", key),)
Expand Down Expand Up @@ -125,7 +116,10 @@ async def list(
Example usage:

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

```
client = DispatchApiClient(key="key", server_url="grpc://fz-0004.frequenz.io")
client = DispatchApiClient(
key="key",
server_url="grpc://dispatch.eu-1.prod.api.frequenz.com:443"
)
async for message in client.stream(microgrid_id=1):
print(message.event, message.dispatch)
```
Expand Down
Loading
Loading