Skip to content

Conversation

@llucax
Copy link
Contributor

@llucax llucax commented Jul 4, 2025

Part of #55.

@Copilot Copilot AI review requested due to automatic review settings July 4, 2025 14:41
@llucax llucax requested review from a team as code owners July 4, 2025 14:41
@github-actions github-actions bot added part:tests Affects the unit, integration and performance (benchmarks) tests part:client Affects the client code labels Jul 4, 2025
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 implements the list_connections RPC surface in the Microgrid client, including the new ComponentConnection model, its protobuf conversions, and associated tests.

  • Added list_connections method to MicrogridApiClient with filtering support.
  • Introduced ComponentConnection dataclass and converter functions.
  • Added unit and integration-style tests for connection listing and conversion.

Reviewed Changes

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

Show a summary per file
File Description
tests/test_client.py Added async test for list_connections using existing test spec
tests/component/test_connection_proto.py Added tests for component_connection_from_proto with issues
tests/component/test_connection.py Added unit tests for ComponentConnection behavior
tests/client_test_cases/list_connections/success_case.py Success scenario test data for list_connections
tests/client_test_cases/list_connections/mixed_filters_case.py Test data for mixed source/destination filters
tests/client_test_cases/list_connections/error_case.py Error scenario test data for list_connections
tests/client_test_cases/list_connections/empty_case.py Empty-result scenario test data
src/frequenz/client/microgrid/component/_connection_proto.py Implementation of proto-to-ComponentConnection conversion
src/frequenz/client/microgrid/component/_connection.py ComponentConnection dataclass and methods
src/frequenz/client/microgrid/component/init.py Export ComponentConnection in package imports
src/frequenz/client/microgrid/_client.py Added list_connections method to client API
Comments suppressed due to low confidence (4)

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

  • There's a small grammatical error in the docstring: remove the extra 'are' so it reads '...infrastructure can be connected...'.
        are can be connected to each other to form an electrical circuit, which can

src/frequenz/client/microgrid/component/_connection_proto.py:2

  • [nitpick] This new file is dated 2024 but the surrounding tests and code use 2025; consider updating the license year to 2025 for consistency.
# Copyright © 2024 Frequenz Energy-as-a-Service GmbH

src/frequenz/client/microgrid/component/_connection.py:2

  • [nitpick] This new file header is dated 2024 but the tests use 2025; please update the year to 2025.
# Copyright © 2024 Frequenz Energy-as-a-Service GmbH

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

  • [nitpick] There's logic here filtering out None connections—add a test case where the server returns a connection with identical source and destination IDs to verify the client drops it as expected.
            for conn in map(

@llucax llucax self-assigned this Jul 4, 2025
@llucax llucax added this to the v0.17.0 milestone Jul 4, 2025
@llucax llucax requested a review from shsms July 4, 2025 14:44
@llucax llucax added cmd:skip-release-notes It is not necessary to update release notes for this PR type:enhancement New feature or enhancement visitble to users labels Jul 4, 2025
@llucax llucax enabled auto-merge July 4, 2025 14:45
@llucax llucax added cmd:skip-release-notes It is not necessary to update release notes for this PR and removed cmd:skip-release-notes It is not necessary to update release notes for this PR labels Jul 7, 2025
"""A single electrical link between two components within a microgrid.
A component connection represents the physical wiring as viewed from the grid
connection point, if one exists, or from the islanding point, in case of an islanded
Copy link
Contributor

Choose a reason for hiding this comment

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

Is "islanding point" a fixed term we use? "island point" would seem more natural to me

Copy link
Contributor

Choose a reason for hiding this comment

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

the grid connection point, if one exists, or from the islanding point, in case of an islanded microgrids

Also, I wonder if it would be easier to read if we describe this only once, but we repeat this exact phrase at least two more times..

Copy link
Contributor

Choose a reason for hiding this comment

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

Like, the other times we could at least say "grid connection/islanding point" instead of the whole phrase. But maybe there is also a more neutral term

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All this should go to the common API, it is all taken from there. I'm not sure how are we going to cope with keeping these in sync, but I guess this is only an issue until we reach 1.0.0, then changes should be very minimal. Maybe when 1.0.0 is released we need to go through all the docs and check they are consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one I will pass, as it diverges too much from the source, I'd rather fix it in the common API first to agree in what's the best wording first with @tiyash-basu-frequenz.

"""

operational_lifetime: Lifetime = dataclasses.field(default_factory=Lifetime)
"""The operational lifetime of the connection."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Whats an operational Lifetime?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is still a bit uncertain, sort of. For the microgrid API, as long as we don't add a way to get historical data for the component graph, this should probably always be empty. I think it is mostly for historical data to signal what was the timespan this component was actually part of the component graph. Not sure if this relates to the operational mode (like if it was disabled if it counts as operational or not).

This still probably needs quite a bit of though and polishing, I don't think we'll solve it for the time being, but I could add some warning that this field utility is still a bit uncertain. I considered also not parsing this field from the protobuf message and skip it completely here, that would be another option, but we already merged some code that has operational_lifetime in it, so it would mean more work to remove it now.

@tiyash-basu-frequenz any recommendations or anything to add?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For now I'm also leaving this one at it is until there is a clear path on how to move forward.

llucax added 2 commits August 27, 2025 08:45
Signed-off-by: Leandro Lucarella <[email protected]>
Signed-off-by: Leandro Lucarella <[email protected]>
@llucax llucax merged commit 6840ced into frequenz-floss:v0.17.x Aug 27, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cmd:skip-release-notes It is not necessary to update release notes for this PR part:client Affects the client code part:tests Affects the unit, integration and performance (benchmarks) tests type:enhancement New feature or enhancement visitble to users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants