Skip to content

Commit 27e1c33

Browse files
committed
Fix dispatch-cli stream trying to print event as dispatch
Signed-off-by: Mathias L. Baumann <[email protected]>
1 parent 9b6c949 commit 27e1c33

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
## Bug Fixes
44

55
* Fix that duration=0 was sent & received as None.
6+
* Fix that `dispatch-cli stream` would try to print an event as dispatch, causing an exception.

src/frequenz/client/dispatch/__main__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import os
88
from datetime import datetime, timezone
99
from pprint import pformat
10-
from typing import Any, List
10+
from typing import Any, List, cast
1111

1212
import asyncclick as click
1313
import grpc
@@ -26,7 +26,7 @@
2626
)
2727
from ._client import Client
2828
from .recurrence import EndCriteria, Frequency, RecurrenceRule, Weekday
29-
from .types import Dispatch
29+
from .types import Dispatch, DispatchEvent, Event
3030

3131
DEFAULT_DISPATCH_API_URL = "grpc://fz-0004.frequenz.io:50051"
3232

@@ -253,7 +253,9 @@ async def stream(ctx: click.Context, microgrid_id: int) -> None:
253253
if ctx.obj["raw"]:
254254
click.echo(pformat(message, compact=True))
255255
else:
256-
print_dispatch(message)
256+
msg = cast(DispatchEvent, message)
257+
print(f"Dispatch {msg.event.name}")
258+
print_dispatch(message.dispatch)
257259

258260

259261
def parse_recurrence(kwargs: dict[str, Any]) -> RecurrenceRule | None:

0 commit comments

Comments
 (0)