Skip to content

Fix succeeded_power calculation in PV power distribution #1217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 15, 2025

Conversation

shsms
Copy link
Contributor

@shsms shsms commented May 15, 2025

This was reported incorrectly earlier using a variable that was never
set. That variable and related (unused) channels have been removed.

This also updates the PV pool tests to ensure that the distribution
results are accurate.

shsms added 2 commits May 15, 2025 16:39
This was reported incorrectly earlier using a variable that was never
set.  That variable and related (unused) channels have been removed.

This also updates the PV pool tests to ensure that the distribution
results are accurate.

Signed-off-by: Sahas Subramanian <[email protected]>
Signed-off-by: Sahas Subramanian <[email protected]>
@Copilot Copilot AI review requested due to automatic review settings May 15, 2025 14:57
@shsms shsms requested a review from a team as a code owner May 15, 2025 14:57
@shsms shsms requested review from Marenz and removed request for a team May 15, 2025 14:57
@github-actions github-actions bot added part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:microgrid Affects the interactions with the microgrid labels May 15, 2025
Copy link

@Copilot 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 fixes an incorrect calculation of succeeded_power during PV power distribution and removes unused variables/channels.

  • Updates the succeeded_power logic in the PV inverter manager to subtract both failed and remaining power.
  • Adjusts test assertions and expected values in the PV pool tests to reflect the new calculation.
  • Revises release notes to document the correction.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
tests/timeseries/_pv_pool/test_pv_pool_control_methods.py Updated test assertions and expected values to match the new succeeded_power calculation.
src/frequenz/sdk/microgrid/_power_distributing/_component_managers/_pv_inverter_manager/_pv_inverter_manager.py Revised succeeded_power calculation by switching from self._target_power to request.power and adjusting for remaining power.
RELEASE_NOTES.md Updated release notes to accurately document the bug fix and expected behavior.
Comments suppressed due to low confidence (1)

tests/timeseries/_pv_pool/test_pv_pool_control_methods.py:303

  • [nitpick] Consider adding additional tests to cover edge cases where the request.power significantly deviates from component defaults, ensuring comprehensive coverage of the new succeeded_power logic.
await pv_pool.propose_power(Power.from_watts(-200000.0))

@@ -241,7 +238,7 @@ async def _set_api_power( # pylint: disable=too-many-locals
failed_components=failed_components,
succeeded_components=succeeded_components,
failed_power=failed_power,
succeeded_power=self._target_power - failed_power,
succeeded_power=request.power - failed_power - remaining_power,
Copy link
Preview

Copilot AI May 15, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider adding a brief comment or updating the docstring here to clarify why the succeeded_power is calculated as request.power minus both the failed_power and remaining_power.

Copilot uses AI. Check for mistakes.

@@ -250,7 +247,7 @@ async def _set_api_power( # pylint: disable=too-many-locals
await self._results_sender.send(
Success(
succeeded_components=succeeded_components,
succeeded_power=self._target_power,
succeeded_power=request.power - remaining_power,
Copy link
Preview

Copilot AI May 15, 2025

Choose a reason for hiding this comment

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

[nitpick] A comment explaining why the succeeded_power calculation in this branch excludes failed_power (compared to the previous branch) would improve maintainability and clarity.

Copilot uses AI. Check for mistakes.

@github-project-automation github-project-automation bot moved this from To do to Review approved in Python SDK Roadmap May 15, 2025
@shsms shsms added this pull request to the merge queue May 15, 2025
Merged via the queue into frequenz-floss:v1.x.x with commit ee4c2f8 May 15, 2025
5 checks passed
@shsms shsms deleted the pv-pool-fix branch May 15, 2025 15:27
@github-project-automation github-project-automation bot moved this from Review approved to Done in Python SDK Roadmap May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
part:docs Affects the documentation part:microgrid Affects the interactions with the microgrid part:tests Affects the unit, integration and performance (benchmarks) tests
Projects
Development

Successfully merging this pull request may close these issues.

2 participants