Skip to content

Conversation

@llucax
Copy link
Contributor

@llucax llucax commented May 15, 2025

This PR resolves an issue where microgrid metadata would incorrectly default to a (0,0) location if the actual location was missing.

If also ensures that broadcasters are properly stopped and cleaned up during client disconnection or exit, preventing potential resource leaks.

Finally, it adds some tests for retrieving microgrid metadata.

llucax added 4 commits May 14, 2025 11:32
We also use a fixture to always clean the client used for test
appropriately.

Signed-off-by: Leandro Lucarella <[email protected]>
Signed-off-by: Leandro Lucarella <[email protected]>
@Copilot Copilot AI review requested due to automatic review settings May 15, 2025 08:08
@llucax llucax requested review from a team as code owners May 15, 2025 08:08
@github-actions github-actions bot added part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:client Affects the client code labels May 15, 2025
@llucax llucax self-assigned this May 15, 2025
@llucax llucax requested a review from shsms May 15, 2025 08:08
@llucax llucax added this to the v0.8.0 milestone May 15, 2025
@llucax llucax enabled auto-merge May 15, 2025 08:09
Copy link

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 how missing microgrid location metadata is handled (avoiding a default 0,0), ensures that background broadcasters are stopped when the client disconnects, and adds/refactors tests around metadata and client cleanup.

  • Use HasField("location") to detect absent location instead of relying on truthiness.
  • Implement __aexit__ override to stop all broadcasters and clean up the gRPC channel.
  • Refactor tests to use a shared client fixture and add tests for successful, missing, empty, and error metadata responses.

Reviewed Changes

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

File Description
tests/test_client.py Added client fixture, imported Empty and MicrogridId, refactored existing tests to use the fixture, and added metadata tests.
src/frequenz/client/microgrid/_client.py Added __aexit__ override to stop broadcasters, updated metadata() to check HasField("location").
RELEASE_NOTES.md Documented bug fixes for metadata location handling and client cleanup behavior.
Comments suppressed due to low confidence (1)

src/frequenz/client/microgrid/_client.py:113

  • The implementation of aexit calls asyncio.gather but asyncio is not imported in this file, causing a NameError at runtime. Please add import asyncio at the top of the file.
async def __aexit__(

@llucax llucax added this pull request to the merge queue May 15, 2025
Merged via the queue into frequenz-floss:v0.x.x with commit d2728c9 May 15, 2025
5 checks passed
@llucax llucax deleted the bugfixes branch May 15, 2025 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:client Affects the client code part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants