Skip to content

Conversation

@Marenz
Copy link
Contributor

@Marenz Marenz commented Aug 13, 2025

The frequenz-client-common dependency has been updated, which introduced breaking changes from the new v1alpha8 API. This commit adapts the codebase to these changes, resolving the resulting nox failures across mypy, pytest, and formatters.

Key changes include:

  • Replacing the deprecated ComponentCategory with v1alpha8's ElectricalComponentCategory.
  • Updating enum members to match the new API, such as ElectricalComponentCategory.GRID to GRID_CONNECTION_POINT and InverterType.PV to InverterType.SOLAR.

Copilot AI review requested due to automatic review settings August 13, 2025 13:28
@Marenz Marenz requested review from a team as code owners August 13, 2025 13:28
@Marenz Marenz requested a review from llucax August 13, 2025 13:28
@github-actions github-actions bot added part:tests Affects the unit, integration and performance (benchmarks) tests part:tooling Affects the development tooling (CI, deployment, dependency management, etc.) part:cli Affects the command-line interface part:test-utils Affects the test utilities part:dispatcher labels Aug 13, 2025

This comment was marked as outdated.

@Marenz Marenz force-pushed the update-common-api branch from e46999c to 013527b Compare August 13, 2025 15:48
@github-actions github-actions bot added the part:docs Affects the documentation label Aug 13, 2025
@Marenz Marenz force-pushed the update-common-api branch from 013527b to 7a4fd1f Compare August 13, 2025 15:52
@Marenz Marenz requested review from Copilot and shsms August 13, 2025 15:52

This comment was marked as outdated.

@Marenz Marenz force-pushed the update-common-api branch from 7a4fd1f to ee8504e Compare August 18, 2025 09:32
Copy link
Contributor

@llucax llucax left a comment

Choose a reason for hiding this comment

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

LGTM, but this introduces breaking changes, which we want to avoid as much as possible from now on.

Maybe for this time, since this applies what are hopefully the last (major) breaking changes in the underlying protocol, we could ship the breaking changes, and help users upgrade their code.

Comment on lines -620 to -626
class Event(Enum):
"""Enum representing the type of event that occurred during a dispatch operation."""

UNSPECIFIED = StreamMicrogridDispatchesResponse.Event.EVENT_UNSPECIFIED
CREATED = StreamMicrogridDispatchesResponse.Event.EVENT_CREATED
UPDATED = StreamMicrogridDispatchesResponse.Event.EVENT_UPDATED
DELETED = StreamMicrogridDispatchesResponse.Event.EVENT_DELETED
Copy link
Contributor

Choose a reason for hiding this comment

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

We should also re-export the event in common here for backwards compatibility (or leave this class as deprecated).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just re-exporting is not enough as the member names also changed. I added the new names to this enum for now

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I'm not sure why we added the prefixes in common, that was a mistake.

llucax
llucax previously approved these changes Aug 19, 2025
@Marenz Marenz force-pushed the update-common-api branch 2 times, most recently from 05fd8db to 57ca451 Compare August 19, 2025 16:06
@Marenz
Copy link
Contributor Author

Marenz commented Aug 19, 2025

  • Updated to be backwards compatible and working with 0.3.5 common-api
  • Added a commit to add back the init key parameter for backwards compabilty.

@Marenz Marenz requested review from Copilot and llucax August 19, 2025 16: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 adapts the codebase to breaking changes introduced by the frequenz-client-common v1alpha8 API update. The changes ensure compatibility with the new API while maintaining backward compatibility.

  • Updated imports to use ElectricalComponentCategory from the new API structure
  • Replaced deprecated enum members with their v1alpha8 equivalents
  • Modified Event enum usage to match the new API naming conventions

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_proto.py Updates test cases to use new component categories and function names
tests/test_dispatch.py Updates dispatch test to use ElectricalComponentCategory.BATTERY
tests/test_client.py Updates event enum usage to use EVENT_ prefixed names
tests/test_cli.py Updates CLI tests to use new electrical component categories
src/frequenz/client/dispatch/types.py Major refactoring to support both old and new API categories with backward compatibility
src/frequenz/client/dispatch/test/generator.py Updates test generator to use new electrical component categories
src/frequenz/client/dispatch/test/_service.py Updates service implementation for new API structure
src/frequenz/client/dispatch/_client.py Updates client to support new protobuf structure and deprecation warnings
src/frequenz/client/dispatch/_cli_types.py Updates CLI type handling for new electrical component categories
pyproject.toml Updates dependency versions to match v1alpha8 requirements
RELEASE_NOTES.md Documents the breaking changes and new features
Comments suppressed due to low confidence (1)

src/frequenz/client/dispatch/types.py:50

  • The test is using InverterType.PV but the corresponding change shows InverterType.SOLAR being replaced with InverterType.PV. This suggests the test should use InverterType.SOLAR to test the deprecated name, or the comment should indicate this is testing the new name.
    UNSPECIFIED = StreamEvent.EVENT_UNSPECIFIED

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

"""Solar inverter."""

SOLAR = PBInverterType.INVERTER_TYPE_PV
"""Deprecated, Solar inverter."""
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

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

The deprecation comment should include information about when this will be removed and recommend using PV instead.

Suggested change
"""Deprecated, Solar inverter."""
"""Deprecated: will be removed in v2.0.0. Use `PV` instead."""

Copilot uses AI. Check for mistakes.
RELEASE_NOTES.md Outdated
## New Features

* **`ElectricalComponentCategory`**: The client now uses the more specific `frequenz.client.common.microgrid.electrical_components.ElectricalComponentCategory` for targeting components.
* The new property `TargetCategory.ecategory` will return an `ElectricalComponentCategory`.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would call this category2, as recommended in the v0.x.x version guideline. On the first glance I didn't even notice the leading e. Also using a standard name make it more obvious that this property should be renamed back to just category in the future, in the next breaking release.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I didn't know it was an actual guideline recommendation too

@Marenz Marenz force-pushed the update-common-api branch from 57ca451 to 0d7fdea Compare August 20, 2025 12:32
Marenz added 2 commits August 20, 2025 14:33
This commit adapts the client to the latest changes in the `frequenz-api-dispatch` and `frequenz-client-common` libraries.

Key changes include:
- Updated `frequenz-api-dispatch` dependency to `v1.0.0-rc3`.
- Updated `frequenz-client-common` dependency to `v0.3.6`.
- Introduced `ElectricalComponentCategory` from the new `v1alpha8` API for more specific component targeting. The old `ComponentCategory` is preserved for backward compatibility.
- `InverterType.SOLAR` is now deprecated in favor of `InverterType.PV`.
- Time interval filters now use `start_time` and `end_time` instead of `from_time` and `to_time`.

Signed-off-by: Mathias L. Baumann <[email protected]>
Signed-off-by: Mathias L. Baumann <[email protected]>
@Marenz Marenz force-pushed the update-common-api branch from 0d7fdea to 0f7532c Compare August 20, 2025 12:33
llucax
llucax previously approved these changes Aug 20, 2025
Copy link
Contributor

@llucax llucax left a comment

Choose a reason for hiding this comment

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

Just one last minor optional comment.


# Re-export Event for backwards compatibility
__all__ = [
"Event",
Copy link
Contributor

Choose a reason for hiding this comment

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

To mark the import location as deprecated you could also instead of re-export it here, add a class like:

@deprecated("Use from frequenz.client.common.streaming.Event instead")
class Event(streaming.Event): pass

Copy link
Contributor Author

Choose a reason for hiding this comment

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

src/frequenz/client/dispatch/test/_service.py:202: error: Argument "event" to "DispatchEvent" has incompatible type "frequenz.client.common.streaming.Event"; expected "frequenz.client.dispatch.types.Event" [arg-type]

That doesn't seem to be equivalent at least

@Marenz
Copy link
Contributor Author

Marenz commented Aug 20, 2025

Removed tmp commit and will force merge

@Marenz Marenz merged commit 5b19025 into frequenz-floss:v0.x.x Aug 20, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:cli Affects the command-line interface part:dispatcher part:docs Affects the documentation part:test-utils Affects the test utilities 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