Skip to content

Commit 11e4c5e

Browse files
authored
Use IDs from frequenz-client-common (#156)
This PR updates the microgrid client to use IDs from the `frequenz-client-common` package instead of defining them in the microgrid client itself. This change is part of a broader effort to centralize common functionality and types across different clients.
2 parents 5a7e2af + 7d817f0 commit 11e4c5e

18 files changed

+42
-250
lines changed

RELEASE_NOTES.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22

33
## Summary
44

5-
<!-- Here goes a general summary of what this release is about -->
5+
This is a small release to allow for easier interoperability between different APIs.
66

77
## Upgrading
88

9-
<!-- Here goes notes on how to upgrade from previous versions, including deprecations and what they should be replaced with -->
9+
- Some minimum dependency versions are bumped, so you might need to update your dependencies as well.
10+
- The IDs (`MicrogridId`, `ComponentId`, `SensorId`) are now imported from `frequenz-client-common`. Please add it to your dependencies if you haven't already, then you can replace your imports:
1011

11-
## New Features
12-
13-
<!-- Here goes the main new features and examples or instructions on how to use them -->
14-
15-
## Bug Fixes
16-
17-
<!-- Here goes notable bug fixes that are worth a special mention or explanation -->
12+
* `from frequenz.client.microgrid import MicrogridId` -> `from frequenz.client.common.microgrid import MicrogridId`
13+
* `from frequenz.client.microgrid import ComponentId` -> `from frequenz.client.common.microgrid.components import ComponentId`
14+
* `from frequenz.client.microgrid import SensorId` -> `from frequenz.client.common.microgrid.sensors import SensorId`

pyproject.toml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ classifiers = [
3636
]
3737
requires-python = ">= 3.11, < 4"
3838
dependencies = [
39-
"frequenz-api-microgrid >= 0.15.3, < 0.16.0",
39+
"frequenz-api-microgrid >= 0.15.5, < 0.16.0",
4040
"frequenz-channels >= 1.0.0-rc1, < 2.0.0",
4141
"frequenz-client-base >= 0.8.0, < 0.12.0",
42-
"grpcio >= 1.59.0, < 2",
43-
"protobuf >= 4.21.6, < 7",
42+
"frequenz-client-common >= 0.3.2, < 0.4.0",
43+
"grpcio >= 1.63.0, < 2",
44+
"protobuf >= 5.26.1, < 7",
4445
"timezonefinder >= 6.2.0, < 7",
45-
"typing-extensions >= 4.6.0, < 5",
46+
"typing-extensions >= 4.13.0, < 5",
4647
]
4748
dynamic = ["version"]
4849

@@ -161,7 +162,15 @@ disable = [
161162
]
162163

163164
[tool.pytest.ini_options]
164-
addopts = "-W=all -Werror -Wdefault::DeprecationWarning -Wdefault::PendingDeprecationWarning -vv"
165+
addopts = "-vv"
166+
filterwarnings = [
167+
"error",
168+
"once::DeprecationWarning",
169+
"once::PendingDeprecationWarning",
170+
# We use a raw string (single quote) to avoid the need to escape special
171+
# chars as this is a regex
172+
'ignore:Protobuf gencode version .*exactly one major version older.*:UserWarning',
173+
]
165174
testpaths = ["tests", "src"]
166175
asyncio_mode = "auto"
167176
asyncio_default_fixture_loop_scope = "function"

src/frequenz/client/microgrid/_client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
from frequenz.api.microgrid import microgrid_pb2, microgrid_pb2_grpc, sensor_pb2
1818
from frequenz.channels import Receiver
1919
from frequenz.client.base import channel, client, retry, streaming
20+
from frequenz.client.common.microgrid import MicrogridId
21+
from frequenz.client.common.microgrid.components import ComponentId
22+
from frequenz.client.common.microgrid.sensors import SensorId
2023
from google.protobuf.empty_pb2 import Empty
2124
from typing_extensions import override
2225

@@ -39,7 +42,6 @@
3942
from ._exception import ApiClientError, ClientNotConnected
4043
from ._metadata import Location, Metadata
4144
from ._sensor_proto import sensor_data_samples_from_proto, sensor_from_proto
42-
from .id import ComponentId, MicrogridId, SensorId
4345
from .sensor import Sensor, SensorDataSamples, SensorMetric
4446

4547
DEFAULT_GRPC_CALL_TIMEOUT = 60.0

src/frequenz/client/microgrid/_component.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88

99
from frequenz.api.common import components_pb2
1010
from frequenz.api.microgrid import grid_pb2, inverter_pb2
11-
12-
from .id import ComponentId
11+
from frequenz.client.common.microgrid.components import ComponentId
1312

1413

1514
class ComponentType(Enum):

src/frequenz/client/microgrid/_component_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from typing import Self
1010

1111
from frequenz.api.microgrid import microgrid_pb2
12+
from frequenz.client.common.microgrid.components import ComponentId
1213

1314
from ._component_error import BatteryError, InverterError
1415
from ._component_states import (
@@ -18,7 +19,6 @@
1819
EVChargerComponentState,
1920
InverterComponentState,
2021
)
21-
from .id import ComponentId
2222

2323

2424
@dataclass(frozen=True)

src/frequenz/client/microgrid/_connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from dataclasses import dataclass
88

9-
from .id import ComponentId
9+
from frequenz.client.common.microgrid.components import ComponentId
1010

1111

1212
@dataclass(frozen=True)

src/frequenz/client/microgrid/_metadata.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
from dataclasses import dataclass
77
from zoneinfo import ZoneInfo
88

9+
from frequenz.client.common.microgrid import MicrogridId
910
from timezonefinder import TimezoneFinder
1011

11-
from .id import MicrogridId
12-
1312
_timezone_finder = TimezoneFinder()
1413

1514

src/frequenz/client/microgrid/_sensor_proto.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
from frequenz.api.common import components_pb2
1111
from frequenz.api.microgrid import common_pb2, microgrid_pb2, sensor_pb2
1212
from frequenz.client.base import conversion
13+
from frequenz.client.common.microgrid.sensors import SensorId
1314

1415
from ._lifetime import Lifetime
1516
from ._util import enum_from_proto
16-
from .id import SensorId
1717
from .sensor import (
1818
Sensor,
1919
SensorDataSamples,

src/frequenz/client/microgrid/id.py

Lines changed: 0 additions & 218 deletions
This file was deleted.

src/frequenz/client/microgrid/sensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
from typing import assert_never
3737

3838
from frequenz.api.microgrid import sensor_pb2
39+
from frequenz.client.common.microgrid.sensors import SensorId
3940

4041
from ._lifetime import Lifetime
41-
from .id import SensorId
4242
from .metrics import AggregatedMetricValue, AggregationMethod
4343

4444

0 commit comments

Comments
 (0)