Skip to content

Add wrappers for microgrid and electrical components #73

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

Open
wants to merge 1 commit into
base: v0.x.x
Choose a base branch
from

Conversation

flora-hofmann-frequenz
Copy link
Contributor

A first attempt to move create wrappers for microgrid and electrical components in common rather than assets-client. Most wrappers are from Luca's microgrid client, but the electrical component & connection still needs to change a bit. Any feedback is appreciated.

@flora-hofmann-frequenz flora-hofmann-frequenz requested a review from a team as a code owner May 29, 2025 08:31
@github-actions github-actions bot added part:tooling Affects the development tooling (CI, deployment, dependency management, etc.) part:microgrid Affects the microgrid protobuf definitions labels May 29, 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 adds common wrappers for microgrid and electrical components by extracting identifier classes and converting protobuf messages into strongly-typed Python objects. Key changes include:

  • Creation of a new module for strongly-typed unique identifiers.
  • Introduction of electrical components classes (including conversion functions from protobuf messages) and a dedicated connection class.
  • Addition of utility functions and microgrid info conversion, along with updated dependency requirements.

Reviewed Changes

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

Show a summary per file
File Description
src/frequenz/client/common/microgrid/id.py Adds a strongly-typed identifier framework for microgrid entities.
src/frequenz/client/common/microgrid/electrical_components/_electrical_component.py Introduces electrical components, enums, and conversion functions from protobuf.
src/frequenz/client/common/microgrid/electrical_components/_connection.py Defines connection metadata between components.
src/frequenz/client/common/microgrid/init.py Removes deprecated electrical component category definitions.
Other files Add utility functions, location/microgrid info conversion, lifetime and delivery area handling.
pyproject.toml Updates dependency versions for timezonefinder and the client base.

@@ -0,0 +1,35 @@
# License: MIT
# Copyright © 2022 Frequenz Energy-as-a-Service GmbH
Copy link
Preview

Copilot AI May 29, 2025

Choose a reason for hiding this comment

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

The copyright year in this header (2022) is inconsistent with the rest of the repository (2025). Please update it to maintain consistency.

Copilot uses AI. Check for mistakes.

Comment on lines +16 to +19
source_component_id: int
"""The component ID that represents the source component of the connection."""

destination_component_id: int
Copy link
Preview

Copilot AI May 29, 2025

Choose a reason for hiding this comment

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

There are different types being used for component identifiers (int for source/destination IDs and ComponentId for start/end). Consider unifying these types for consistency and to avoid potential confusion.

Suggested change
source_component_id: int
"""The component ID that represents the source component of the connection."""
destination_component_id: int
source_component_id: ComponentId
"""The component ID that represents the source component of the connection."""
destination_component_id: ComponentId

Copilot uses AI. Check for mistakes.

@llucax
Copy link
Contributor

llucax commented Jun 2, 2025

This is also being reviewed at:

And upcoming PRs. I guess you need this more or less urgently and can't wait until it is merged first in the microgrid API? I think splitting the discussion/review in 2 different places could get problematic 😟

@flora-hofmann-frequenz
Copy link
Contributor Author

flora-hofmann-frequenz commented Jun 2, 2025

I guess you need this more or less urgently and can't wait until it is merged first in the microgrid API? I think splitting the discussion/review in 2 different places could get problematic 😟

I am happy to wait until this one is through, maybe you can just give me a head up once its done and I'll change it! Just FYI @cwasicki these are the wrappers we want to use when we move all Microgrid etc classes to common. Maybe we can check if we can take in the first "inital" client as it was and then add the proper wrappers a little later.

@llucax Super sorry about deleting your tests comment - somehow I completely messed up my comment, wanted to delete it and then got the wrong one :-D

@frequenz-floss frequenz-floss deleted a comment from llucax Jun 2, 2025
@llucax

This comment was marked as outdated.

@llucax
Copy link
Contributor

llucax commented Jun 2, 2025

@llucax Super sorry about deleting your tests comment - somehow I completely messed up my comment, wanted to delete it and then got the wrong one :-D

Haha, no worries.

@llucax
Copy link
Contributor

llucax commented Jun 2, 2025

I am happy to wait until this one is through, maybe you can just give me a head up once its done and I'll change it! Just FYI @cwasicki these are the wrappers we want to use when we move all Microgrid etc classes to common. Maybe we can check if we can take in the first "inital" client as it was and then add the proper wrappers a little later.

Then I'd say please do review the wrappers in frequenz-floss/frequenz-client-microgrid-python#94 and mention any changes you might need for other clients there, so we can already think about an approach that is good in general. Then I can see if I apply the changes there already or if I keep it as it is, but already knowing which changes are coming.

After the review is done there, we can move the reviewed wrappers here already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
part:microgrid Affects the microgrid protobuf definitions part:tooling Affects the development tooling (CI, deployment, dependency management, etc.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants