Skip to content

Commit 91f7493

Browse files
Ensure timestamp conversion errors are surfaced (#133)
Added a try...except...raise block around the calls to `dt_to_pb_timestamp_utc` for start_time and end_time. Previously, an error during this conversion might not have been handled explicitly at this point. This change guarantees that if the conversion fails, the exception is propagated immediately, improving robustness and aiding debugging by making the failure point clear.
2 parents 8283f6b + 3341926 commit 91f7493

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

RELEASE_NOTES.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,12 @@
66

77
## Upgrading
88

9-
* Unify Public Trades streaming and listing (to align with the proto changes in v0.5.0)
10-
* Removed `list_public_trades`
11-
* Replaced `public_trades_stream` with `receive_public_trades`
12-
* `receive_public_trades` now supports an optional time range (`start_time`, `end_time`)
13-
* Update the `frequenz-api-electricity-trading` from >= 0.5.0, < 0.6.0 to >= 0.6.1, < 0.7.0
14-
* Update repo-config from v0.11.0 to v0.13.0
9+
<!-- Here goes notes on how to upgrade from previous versions, including deprecations and what they should be replaced with -->
1510

1611
## New Features
1712

18-
* Add the Public Order Book extension to the client
19-
* Add the `PublicOrder` and `PublicOrderFilter` types
20-
* Add the `receive_public_order()` endpoint
13+
<!-- Here goes the main new features and examples or instructions on how to use them -->
2114

2215
## Bug Fixes
2316

24-
<!-- Here goes notable bug fixes that are worth a special mention or explanation -->
17+
- Ensure timestamp conversion errors are surfaced

src/frequenz/client/electricity_trading/_client.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,9 @@ def receive_public_order_book(
10361036
side=side,
10371037
)
10381038

1039+
start_time_utc = dt_to_pb_timestamp_utc(start_time) if start_time else None
1040+
end_time_utc = dt_to_pb_timestamp_utc(end_time) if end_time else None
1041+
10391042
if (
10401043
public_order_filter not in self._public_orders_streams
10411044
or not self._public_orders_streams[public_order_filter].is_running
@@ -1047,16 +1050,8 @@ def receive_public_order_book(
10471050
lambda: self.stub.ReceivePublicOrderBookStream(
10481051
electricity_trading_pb2.ReceivePublicOrderBookStreamRequest(
10491052
filter=public_order_filter.to_pb(),
1050-
start_time=(
1051-
dt_to_pb_timestamp_utc(start_time)
1052-
if start_time
1053-
else None
1054-
),
1055-
end_time=(
1056-
dt_to_pb_timestamp_utc(end_time)
1057-
if end_time
1058-
else None
1059-
),
1053+
start_time=start_time_utc,
1054+
end_time=end_time_utc,
10601055
),
10611056
metadata=self._metadata,
10621057
),

0 commit comments

Comments
 (0)