Skip to content

Ensure timestamp conversion errors are surfaced#133

Merged
matthias-wende-frequenz merged 2 commits into
frequenz-floss:v0.x.xfrom
matthias-wende-frequenz:raise_time_value_error
Apr 23, 2025
Merged

Ensure timestamp conversion errors are surfaced#133
matthias-wende-frequenz merged 2 commits into
frequenz-floss:v0.x.xfrom
matthias-wende-frequenz:raise_time_value_error

Conversation

@matthias-wende-frequenz
Copy link
Copy Markdown
Contributor

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.

Copilot AI review requested due to automatic review settings April 23, 2025 15:45
@matthias-wende-frequenz matthias-wende-frequenz requested a review from a team as a code owner April 23, 2025 15:45
@github-actions github-actions Bot added the part:docs Affects the documentation label Apr 23, 2025
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures that errors during timestamp conversion in the electricity trading client are surfaced immediately by adding a try...except...raise block. Key changes include:

  • Introducing a try-except block around dt_to_pb_timestamp_utc calls for start_time and end_time.
  • Updating the client code to use the converted timestamp variables.
  • Reflecting the change in RELEASE_NOTES.md for clarity on how timestamp conversion errors are handled.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/frequenz/client/electricity_trading/_client.py Wraps timestamp conversion with try...except...raise to propagate errors immediately.
RELEASE_NOTES.md Updates release notes to include the new behavior on timestamp conversion errors.

Comment thread src/frequenz/client/electricity_trading/_client.py Outdated
micaebe
micaebe previously approved these changes Apr 23, 2025
Copy link
Copy Markdown

@micaebe micaebe left a comment

Choose a reason for hiding this comment

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

lgtm
But CI is failing bcs. mypy wants to have a tuple of exception classes instead of the | optional notation (so TypeError | ValueError -> (TypeError, ValueError))

Comment thread src/frequenz/client/electricity_trading/_client.py Outdated
Explicitly call `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.

Signed-off-by: Matthias Wende <matthias.wende@frequenz.com>
Signed-off-by: Matthias Wende <matthias.wende@frequenz.com>
@matthias-wende-frequenz
Copy link
Copy Markdown
Contributor Author

matthias-wende-frequenz commented Apr 23, 2025

But CI is failing bcs. mypy wants to have a tuple of exception classes instead of the | optional notation (so TypeError | ValueError -> (TypeError, ValueError))

pylint was also complaining. I removed the whole block and made catching the error less explicit. Calling the dt_to_pb_timestamp_utc function explicitly is enough to propagate the raised error up the call stack.

Now all nox tests are passing 🥳.

@matthias-wende-frequenz matthias-wende-frequenz added this pull request to the merge queue Apr 23, 2025
Merged via the queue into frequenz-floss:v0.x.x with commit 91f7493 Apr 23, 2025
5 checks passed
@matthias-wende-frequenz matthias-wende-frequenz deleted the raise_time_value_error branch April 23, 2025 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:docs Affects the documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants