Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ There are a few intentional hard breaks too, all listed in the Upgrading section

## Upgrading

* `frequenz.client.common.microgrid.components.ComponentId` is restored as a deprecated compatibility class. It keeps its historical import path and remains a distinct type from `ElectricalComponentId`; importing both classes logs the existing duplicate `CID` prefix warning. This restores only `ComponentId`, not the removed `ComponentCategory`, `ComponentStateCode` or `ComponentErrorCode` symbols. The v0.4.0 release remains incompatible with users of the removed import path. Removal will be coordinated with downstream migration rather than tied automatically to v0.5.0.
* `frequenz.client.common.microgrid.components.ComponentId` is restored as a deprecated compatibility class. It keeps its historical import path and remains a distinct type from `ElectricalComponentId`. This restores only `ComponentId`, not the removed `ComponentCategory`, `ComponentStateCode` or `ComponentErrorCode` symbols. The v0.4.0 release remains incompatible with users of the removed import path. Removal will be coordinated with downstream migration rather than tied automatically to v0.5.0.

* `frequenz.client.common.microgrid.electrical_components.ElectricalComponentId` now renders with the prefix `ECID` instead of `CID` (for example, `ECID42` instead of `CID42`).

This is a display-only change.

Anyone who adopted v0.4.0 and logs or displays an `ElectricalComponentId` will see `ECID42` where they previously saw `CID42`. No code changes are needed, only an update to any log-parsing rules or UI labels that checked for the `CID` prefix.

* The `frequenz.client.common.microgrid.electrical_components.ElectricalComponentCategory` enum is now deprecated and will be removed in a future release.

Expand Down Expand Up @@ -98,7 +104,7 @@ There are a few intentional hard breaks too, all listed in the Upgrading section

* `frequenz.client.common.metrics.MetricConnection.__str__` renders as `{name}:{category}` (with `name` possibly empty); known categories render as their member name, the unspecified category renders as `cat=<invalid:0>`, and unknown non-zero categories render as `cat=<int>`.
* `frequenz.client.common.metrics.MetricSample` gained a compact `__str__` (`metric=value`, plus `@connection` when a connection is set) instead of falling back to the dataclass `repr`.
* `UnrecognizedElectricalComponent`, `MismatchedCategoryElectricalComponent`, `UnrecognizedBattery`, `UnrecognizedEvCharger` and `UnrecognizedInverter` now expose their raw wire `category` / `type` in `__str__` (e.g. `CID1:comp1:Inverter:type=99`), instead of hiding it behind the class name alone. These values are merely unrecognized (forward-compatible), not invariant violations, so they use a plain `:field=value` detail rather than the `<invalid:...>` marker.
* `UnrecognizedElectricalComponent`, `MismatchedCategoryElectricalComponent`, `UnrecognizedBattery`, `UnrecognizedEvCharger` and `UnrecognizedInverter` now expose their raw wire `category` / `type` in `__str__` (e.g. `ECID1:comp1:Inverter:type=99`), instead of hiding it behind the class name alone. These values are merely unrecognized (forward-compatible), not invariant violations, so they use a plain `:field=value` detail rather than the `<invalid:...>` marker.

* `frequenz.client.common.metrics.MetricSample.bounds` is now deprecated; use `bounds_set` instead.

Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/typed-ids.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ Construct an ID from its numeric value. IDs of the same type and value compare
equal, so you can use them as dictionary keys or set members. IDs with the
same number but different types are not equal.

The printed prefix identifies the kind of ID: `MID` for a microgrid, `CID` for
The printed prefix identifies the kind of ID: `MID` for a microgrid, `ECID` for
an electrical component, `SID` for a sensor, and `EID` for an enterprise. All
of these types are based on [`BaseId`][frequenz.core.id.BaseId].
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@


@final
class ElectricalComponentId(BaseId, str_prefix="CID"):
class ElectricalComponentId(BaseId, str_prefix="ECID"):
"""A unique identifier for a microgrid electrical component."""
2 changes: 1 addition & 1 deletion tests/microgrid/electrical_components/test_battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,4 @@ def test_unrecognized_battery_str(
_allow_construction=True,
)

assert str(battery) == "CID42:bat1:Battery:type=999"
assert str(battery) == "ECID42:bat1:Battery:type=999"
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ def test_get_metric_config_bounds_int_key_invalid_raises_error() -> None:
@pytest.mark.parametrize(
"name,expected_str",
[
("", "CID1::_TestElectricalComponent"),
("test-component", "CID1:test-component:_TestElectricalComponent"),
("", "ECID1::_TestElectricalComponent"),
("test-component", "ECID1:test-component:_TestElectricalComponent"),
],
ids=["no-name", "with-name"],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def test_str() -> None:
connection = ElectricalComponentConnection(
source_id=ElectricalComponentId(1), destination_id=ElectricalComponentId(2)
)
assert str(connection) == "CID1->CID2"
assert str(connection) == "ECID1->ECID2"


def test_equality_and_hash() -> None:
Expand Down
2 changes: 1 addition & 1 deletion tests/microgrid/electrical_components/test_ev_charger.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,4 @@ def test_unrecognized_ev_charger_str(
_allow_construction=True,
)

assert str(charger) == "CID42:evc1:EvCharger:type=999"
assert str(charger) == "ECID42:evc1:EvCharger:type=999"
2 changes: 1 addition & 1 deletion tests/microgrid/electrical_components/test_inverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,4 @@ def test_unrecognized_inverter_str(
_allow_construction=True,
)

assert str(inverter) == "CID42:inv1:Inverter:type=999"
assert str(inverter) == "ECID42:inv1:Inverter:type=999"
4 changes: 2 additions & 2 deletions tests/microgrid/electrical_components/test_problematic.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def test_unrecognized_component_str(
_allow_construction=True,
)

assert str(component) == "CID42:comp1:category=999"
assert str(component) == "ECID42:comp1:category=999"


def test_mismatched_category_component_str(
Expand All @@ -164,4 +164,4 @@ def test_mismatched_category_component_str(
_allow_construction=True,
)

assert str(component) == "CID42:comp1:mismatched:category=BATTERY:kind=inverter"
assert str(component) == "ECID42:comp1:mismatched:category=BATTERY:kind=inverter"
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_self_referencing_connection_str() -> None:
source_id=ElectricalComponentId(7),
destination_id=ElectricalComponentId(7),
)
assert str(connection) == "CID7->CID7"
assert str(connection) == "ECID7->ECID7"


def test_self_referencing_connection_equality_and_hash() -> None:
Expand Down
12 changes: 8 additions & 4 deletions tests/microgrid/test_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
[
(EnterpriseId, "EID"),
(MicrogridId, "MID"),
(ElectricalComponentId, "CID"),
(ElectricalComponentId, "ECID"),
(SensorId, "SID"),
],
)
Expand Down Expand Up @@ -101,8 +101,12 @@ def test_component_id_equality_and_validation() -> None:
),
],
)
def test_component_id_import_orders_keep_current_prefix_warning(imports: str) -> None:
"""Test both import orders and acknowledge the current duplicate-prefix warning."""
def test_component_id_import_orders_produce_no_prefix_warning(imports: str) -> None:
"""Test both import orders emit no duplicate-prefix warning.

ElectricalComponentId uses ECID and ComponentId uses CID, so they no
longer share a prefix regardless of import order.
"""
source_root = Path(__file__).resolve().parents[2] / "src"
script = f"""
import logging
Expand All @@ -123,7 +127,7 @@ def test_component_id_import_orders_keep_current_prefix_warning(imports: str) ->
)

assert result.returncode == 0, result.stderr
assert "Prefix 'CID' is already registered" in result.stderr
assert "already registered" not in result.stderr


def test_component_id_does_not_restore_legacy_enums() -> None:
Expand Down