Skip to content

Commit 66b8903

Browse files
authored
Restore backwards compatibility (#194)
The v0.x.x branch was targeting the v0.4.0 release, so it included breaking changes. Before doing the v0.4.0 release, we want to do a new v0.3.8 release that is backwards compatible but gives a clear migration path to v0.4.0. We created the v0.3.x branch based on the current v0.x.x branch, and this PR is aimed at recovering the backwards compatibility for the v0.3.8 release. Before the final v0.3.8 release we'll need to deprecate some other old symbols.
2 parents 74933ff + aed12f8 commit 66b8903

14 files changed

Lines changed: 449 additions & 209 deletions

File tree

RELEASE_NOTES.md

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,7 @@
22

33
## Summary
44

5-
This release adds a new `grid` package for delivery area definitions, introduces explicit v1alpha8 protobuf conversion helpers across public modules (`metrics`, `streaming`, `electrical_components`, `pagination`, `grid`), and reorganises a number of subpackages to mirror the established `proto/v1alpha8/` layout. Several legacy conversion entry points have been deprecated in favour of the new free functions.
6-
7-
## Upgrading
8-
9-
- v1alpha8-backed enums (`Metric`, `MetricConnectionCategory`, `Event`, electrical component enums, `EnergyMarketCodeType`) are now plain `int`s. Converting them from/to protobuf directly is no longer supported; use the explicit conversion functions in:
10-
- `frequenz.client.common.metrics.proto.v1alpha8`
11-
- `frequenz.client.common.streaming.proto.v1alpha8`
12-
- `frequenz.client.common.microgrid.electrical_components.proto.v1alpha8`
13-
- `frequenz.client.common.grid.proto.v1alpha8`
14-
15-
- The metrics proto helpers have moved from `frequenz.client.common.metrics.proto` to `frequenz.client.common.metrics.proto.v1alpha8`. The old import path is kept as a deprecated shim (importing from it now emits a deprecation warning) and will be removed in a future release. Update your imports as follows:
16-
- `from frequenz.client.common.metrics.proto import bounds_from_proto``from frequenz.client.common.metrics.proto.v1alpha8 import bounds_from_proto`
17-
- `from frequenz.client.common.metrics.proto import bounds_from_proto_with_issues``from frequenz.client.common.metrics.proto.v1alpha8 import bounds_from_proto_with_issues`
18-
- `from frequenz.client.common.metrics.proto import aggregated_metric_sample_from_proto``from frequenz.client.common.metrics.proto.v1alpha8 import aggregated_metric_sample_from_proto`
19-
- `from frequenz.client.common.metrics.proto import metric_connection_from_proto_with_issues``from frequenz.client.common.metrics.proto.v1alpha8 import metric_connection_from_proto_with_issues`
20-
- `from frequenz.client.common.metrics.proto import metric_sample_from_proto_with_issues``from frequenz.client.common.metrics.proto.v1alpha8 import metric_sample_from_proto_with_issues`
21-
22-
- The `PaginationInfo` conversion methods are deprecated in favour of new free functions in `frequenz.client.common.pagination.proto.v1alpha8` (calling the methods now emits a deprecation warning). Migrate as follows:
23-
- `PaginationInfo.from_proto(msg)``pagination_info_from_proto(msg)` (from `frequenz.client.common.pagination.proto.v1alpha8`)
24-
- `PaginationInfo.to_proto()``pagination_info_to_proto(info)` (from `frequenz.client.common.pagination.proto.v1alpha8`)
25-
- `PaginationInfo.to_proto_v1alpha8()``pagination_info_to_proto(info)` (from `frequenz.client.common.pagination.proto.v1alpha8`)
5+
This release adds a new `grid` package for delivery area definitions, introduces explicit v1alpha8 protobuf conversion helpers across public modules (`metrics`, `streaming`, `electrical_components`, `pagination`, `grid`), and reorganises a number of subpackages to mirror the established `proto/v1alpha8/` layout. Several legacy conversion entry points have been deprecated in favour of new free functions.
266

277
## New Features
288

@@ -35,11 +15,24 @@ This release adds a new `grid` package for delivery area definitions, introduces
3515

3616
## Deprecations
3717

18+
> [!IMPORTANT]
19+
> Passing enum values directly to build protobuf messages is now deprecated, but it **does NOT emit a deprecation warning**, so migration needs to be done manually. Use the new conversion functions to convert enum values to their protobuf equivalents before passing them to message builders.
20+
>
21+
> **Implicit conversions will fail type checking in v0.4.0.**
22+
3823
- `frequenz.client.common.metrics.proto` is deprecated; use `frequenz.client.common.metrics.proto.v1alpha8` instead.
3924
- `frequenz.client.common.pagination.PaginationInfo.from_proto` is deprecated; use `frequenz.client.common.pagination.proto.v1alpha8.pagination_info_from_proto` instead.
4025
- `frequenz.client.common.pagination.PaginationInfo.to_proto` is deprecated; use `frequenz.client.common.pagination.proto.v1alpha8.pagination_info_to_proto` instead.
4126
- `frequenz.client.common.pagination.PaginationInfo.to_proto_v1alpha8` is deprecated; use `frequenz.client.common.pagination.proto.v1alpha8.pagination_info_to_proto` instead.
42-
43-
## Bug Fixes
44-
45-
<!-- Here goes notable bug fixes that are worth a special mention or explanation -->
27+
- `frequenz.client.common.microgrid.electrical_components.ElectricalComponentCategory.from_proto()` is deprecated; use `frequenz.client.common.microgrid.electrical_components.proto.v1alpha8.electrical_component_category_from_proto` instead.
28+
- `frequenz.client.common.microgrid.electrical_components.ElectricalComponentCategory.to_proto()` is deprecated; use `frequenz.client.common.microgrid.electrical_components.proto.v1alpha8.electrical_component_category_to_proto` instead.
29+
- `frequenz.client.common.microgrid.electrical_components.ElectricalComponentStateCode.from_proto()` is deprecated; use `frequenz.client.common.microgrid.electrical_components.proto.v1alpha8.electrical_component_state_code_from_proto` instead.
30+
- `frequenz.client.common.microgrid.electrical_components.ElectricalComponentStateCode.to_proto()` is deprecated; use `frequenz.client.common.microgrid.electrical_components.proto.v1alpha8.electrical_component_state_code_to_proto` instead.
31+
- `frequenz.client.common.microgrid.electrical_components.ElectricalComponentDiagnosticCode.from_proto()` is deprecated; use `frequenz.client.common.microgrid.electrical_components.proto.v1alpha8.electrical_component_diagnostic_code_from_proto` instead.
32+
- `frequenz.client.common.microgrid.electrical_components.ElectricalComponentDiagnosticCode.to_proto()` is deprecated; use `frequenz.client.common.microgrid.electrical_components.proto.v1alpha8.electrical_component_diagnostic_code_to_proto` instead.
33+
- `frequenz.client.common.enum_proto.enum_from_proto` is deprecated; use `frequenz.client.common.proto.enum_from_proto` instead.
34+
- `frequenz.client.common.metric.Metric` (based on the deprecated `frequenz.api.common.v1` namespace) is deprecated; use `frequenz.client.common.metrics.Metric` instead.
35+
- `frequenz.client.common.microgrid.components.ComponentCategory` (based on the deprecated `frequenz.api.common.v1` namespace) is deprecated; use `frequenz.client.common.microgrid.electrical_components.ElectricalComponentCategory` instead.
36+
- `frequenz.client.common.microgrid.components.ComponentStateCode` (based on the deprecated `frequenz.api.common.v1` namespace) is deprecated; use `frequenz.client.common.microgrid.electrical_components.ElectricalComponentStateCode` instead.
37+
- `frequenz.client.common.microgrid.components.ComponentErrorCode` (based on the deprecated `frequenz.api.common.v1` namespace) is deprecated; use `frequenz.client.common.microgrid.electrical_components.ElectricalComponentDiagnosticCode` instead.
38+
- `frequenz.client.common.microgrid.components.ComponentId` is deprecated; use `frequenz.client.common.microgrid.electrical_components.ElectricalComponentId` instead.

src/frequenz/client/common/grid/_delivery_area.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import enum
77
from dataclasses import dataclass
88

9+
from frequenz.api.common.v1alpha8.grid import delivery_area_pb2
10+
911

1012
@enum.unique
1113
class EnergyMarketCodeType(enum.Enum):
@@ -35,13 +37,13 @@ class EnergyMarketCodeType(enum.Enum):
3537
processing errors.
3638
"""
3739

38-
UNSPECIFIED = 0
40+
UNSPECIFIED = delivery_area_pb2.ENERGY_MARKET_CODE_TYPE_UNSPECIFIED
3941
"""Unspecified type. This value is a placeholder and should not be used."""
4042

41-
EUROPE_EIC = 1
43+
EUROPE_EIC = delivery_area_pb2.ENERGY_MARKET_CODE_TYPE_EUROPE_EIC
4244
"""European Energy Identification Code Standard."""
4345

44-
US_NERC = 2
46+
US_NERC = delivery_area_pb2.ENERGY_MARKET_CODE_TYPE_US_NERC
4547
"""North American Electric Reliability Corporation identifiers."""
4648

4749

src/frequenz/client/common/metric/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
# pylint: enable=no-name-in-module
1414

1515

16+
@deprecated(
17+
"frequenz.client.common.metric.Metric is deprecated. "
18+
"Use frequenz.client.common.metrics.Metric instead."
19+
)
1620
@enum.unique
1721
class Metric(enum.Enum):
1822
"""List of supported metrics.

0 commit comments

Comments
 (0)