Skip to content

Conversation

@Marenz
Copy link
Contributor

@Marenz Marenz commented Aug 11, 2025

This merges all v0.3.x changes into the v0.x.x branch.

I assume we had an extra v0.3.x branch due to the rename changes of Components -> ElectricalComponents.
Since then we decided to handle those API updates using extra paths like .v1alpha8, so we can add back the changes of v0.3.x and stay API compatible with our dependees.

  • A new module frequenz.client.common.enum_proto has been added, which provides a generic enum_from_proto() function to convert protobuf enums to Python enums.
  • Documentation for some frequenz.client.common.microgrid.electrical_components.ElectricalComponentCategory values was improved.
  • The metrics and components enums .from_proto() are deprecated, please use the new enum_from_proto() instead.
  • Classes to represent microgrid-related ID were added (MicrogridId, EnterpriseId, ComponentId, and SensorId).

llucax and others added 21 commits June 6, 2025 12:42
Adds: EnterpriseId, MicrogridId, ComponentId and SensorId.

Signed-off-by: Leandro Lucarella <[email protected]>
Signed-off-by: Leandro Lucarella <[email protected]>
Signed-off-by: Leandro Lucarella <[email protected]>
We need to bump typing-extensions to 4.13.0 because that's the minimum
supported version declaraed by `frequenz-core`.

Signed-off-by: Leandro Lucarella <[email protected]>
Signed-off-by: Leandro Lucarella <[email protected]>
Signed-off-by: Leandro Lucarella <[email protected]>
Signed-off-by: Leandro Lucarella <[email protected]>
This needs a bump of the minimum `frequenz-api-common` to v0.6.1 as this
category was added in that version.

Signed-off-by: Leandro Lucarella <[email protected]>
This function can convert any `int` to any `Enum`, with optional
validation or forward-compatibility.

Signed-off-by: Leandro Lucarella <[email protected]>
Recommend using the new `enum_from_proto()` instead.

Signed-off-by: Leandro Lucarella <[email protected]>
This is to avoid errors in tests about duplicated `BaseId` prefixes.

Signed-off-by: Leandro Lucarella <[email protected]>
Signed-off-by: Leandro Lucarella <[email protected]>
Signed-off-by: Leandro Lucarella <[email protected]>
Copilot AI review requested due to automatic review settings August 11, 2025 16:44
@Marenz Marenz requested a review from a team as a code owner August 11, 2025 16:44
@github-actions github-actions bot added part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:tooling Affects the development tooling (CI, deployment, dependency management, etc.) part:microgrid Affects the microgrid protobuf definitions labels Aug 11, 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 merges v0.3.x branch changes into v0.x.x, introducing several new utilities and components for microgrid client functionality. The changes focus on adding ID classes, enum conversion utilities, and expanding component categories.

  • Adds new ID classes for enterprises, microgrids, components, and sensors with standardized string prefixes
  • Introduces a new enum_from_proto utility function for converting protobuf enum values to Python enums with better error handling
  • Expands microgrid component categories with new types like converters, crypto miners, electrolyzers, and HVAC systems

Reviewed Changes

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

Show a summary per file
File Description
src/frequenz/client/common/enum_proto.py New utility module for protobuf enum conversion with type safety and error handling
src/frequenz/client/common/microgrid/__init__.py Adds EnterpriseId and MicrogridId classes with "EID" and "MID" prefixes
src/frequenz/client/common/microgrid/sensors.py New SensorId class with "SID" prefix for sensor identification
src/frequenz/client/common/microgrid/components/__init__.py Adds ComponentId class and new component categories, deprecates old enum methods
src/frequenz/client/common/metric/__init__.py Updates enum imports and deprecates old from_proto method
tests/test_enum_proto.py Comprehensive tests for the new enum_from_proto utility
tests/microgrid/test_ids.py Tests for string representation of new ID classes
pyproject.toml Updates dependencies and test configuration
RELEASE_NOTES.md Removes outdated upgrade notes

UNSPECIFIED = 0
SOME_VALUE = 1
enum_value = enum_from_proto(proto_pb2.SomeEnum.SOME_ENUM_SOME_VALUE, SomeEnum)
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

The example imports proto_pb2 with a pylint disable comment, but this import will fail in practice. Consider using a more realistic example or clarifying that this is pseudocode.

Copilot uses AI. Check for mistakes.
@Marenz
Copy link
Contributor Author

Marenz commented Aug 12, 2025

I just discovered that this is a dup of #85. As it resolved the conflicts and is effectively the same and #85 is already approved, I will just go ahead and merge this if noone is gonna approve soon :)

@Marenz Marenz merged commit 829aa1a into frequenz-floss:v0.x.x Aug 12, 2025
5 checks passed
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 microgrid protobuf definitions part:tests Affects the unit, integration and performance (benchmarks) tests 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