frequenz-client-common 0.3.2__tar.gz → 0.3.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {frequenz_client_common-0.3.2/src/frequenz_client_common.egg-info → frequenz_client_common-0.3.3}/PKG-INFO +3 -3
- frequenz_client_common-0.3.3/RELEASE_NOTES.md +22 -0
- {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.3}/pyproject.toml +2 -2
- frequenz_client_common-0.3.3/src/frequenz/client/common/enum_proto.py +76 -0
- {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.3}/src/frequenz/client/common/metric/__init__.py +5 -2
- {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.3}/src/frequenz/client/common/microgrid/components/__init__.py +57 -4
- {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.3/src/frequenz_client_common.egg-info}/PKG-INFO +3 -3
- {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.3}/src/frequenz_client_common.egg-info/SOURCES.txt +1 -0
- {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.3}/src/frequenz_client_common.egg-info/requires.txt +2 -2
- frequenz_client_common-0.3.2/RELEASE_NOTES.md +0 -19
- {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.3}/LICENSE +0 -0
- {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.3}/MANIFEST.in +0 -0
- {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.3}/README.md +0 -0
- {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.3}/setup.cfg +0 -0
- {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.3}/src/frequenz/client/common/__init__.py +0 -0
- {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.3}/src/frequenz/client/common/conftest.py +0 -0
- {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.3}/src/frequenz/client/common/microgrid/__init__.py +0 -0
- {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.3}/src/frequenz/client/common/microgrid/sensors.py +0 -0
- {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.3}/src/frequenz/client/common/pagination/__init__.py +0 -0
- {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.3}/src/frequenz/client/common/py.typed +0 -0
- {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.3}/src/frequenz_client_common.egg-info/dependency_links.txt +0 -0
- {frequenz_client_common-0.3.2 → frequenz_client_common-0.3.3}/src/frequenz_client_common.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: frequenz-client-common
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Summary: Common code and utilities for Frequenz API clients
|
|
5
5
|
Author-email: Frequenz Energy-as-a-Service GmbH <floss@frequenz.com>
|
|
6
6
|
License: MIT
|
|
@@ -21,8 +21,8 @@ Requires-Python: <4,>=3.11
|
|
|
21
21
|
Description-Content-Type: text/markdown
|
|
22
22
|
License-File: LICENSE
|
|
23
23
|
Requires-Dist: typing-extensions<5,>=4.13.0
|
|
24
|
-
Requires-Dist: frequenz-api-common<7,>=0.6.
|
|
25
|
-
Requires-Dist: frequenz-core<2,>=1.0.
|
|
24
|
+
Requires-Dist: frequenz-api-common<7,>=0.6.1
|
|
25
|
+
Requires-Dist: frequenz-core<2,>=1.0.2
|
|
26
26
|
Provides-Extra: dev-flake8
|
|
27
27
|
Requires-Dist: flake8==7.2.0; extra == "dev-flake8"
|
|
28
28
|
Requires-Dist: flake8-docstrings==1.7.0; extra == "dev-flake8"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Frequenz Client Common Library Release Notes
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
<!-- Here goes a general summary of what this release is about -->
|
|
6
|
+
|
|
7
|
+
## Upgrading
|
|
8
|
+
|
|
9
|
+
- The metrics and components enums `.from_proto()` are deprecated, please use the new `enum_from_proto()` instead.
|
|
10
|
+
- Some minimum dependencies have been bumped, you might need to update your minimum dependencies too:
|
|
11
|
+
|
|
12
|
+
* `frequenz-api-common` to 0.6.1
|
|
13
|
+
* `frequenz-core` to 1.0.2
|
|
14
|
+
|
|
15
|
+
## New Features
|
|
16
|
+
|
|
17
|
+
- 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.
|
|
18
|
+
- The `frequenz.client.common.microgrid.ComponentCategory` was extended to include the missing categories.
|
|
19
|
+
|
|
20
|
+
## Bug Fixes
|
|
21
|
+
|
|
22
|
+
<!-- Here goes notable bug fixes that are worth a special mention or explanation -->
|
|
@@ -27,8 +27,8 @@ classifiers = [
|
|
|
27
27
|
requires-python = ">= 3.11, < 4"
|
|
28
28
|
dependencies = [
|
|
29
29
|
"typing-extensions >= 4.13.0, < 5",
|
|
30
|
-
"frequenz-api-common >= 0.6.
|
|
31
|
-
"frequenz-core >= 1.0.
|
|
30
|
+
"frequenz-api-common >= 0.6.1, < 7",
|
|
31
|
+
"frequenz-core >= 1.0.2, < 2",
|
|
32
32
|
]
|
|
33
33
|
dynamic = ["version"]
|
|
34
34
|
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# License: MIT
|
|
2
|
+
# Copyright © 2025 Frequenz Energy-as-a-Service GmbH
|
|
3
|
+
|
|
4
|
+
"""Conversion of protobuf int enums to Python enums."""
|
|
5
|
+
|
|
6
|
+
import enum
|
|
7
|
+
from typing import Literal, TypeVar, overload
|
|
8
|
+
|
|
9
|
+
EnumT = TypeVar("EnumT", bound=enum.Enum)
|
|
10
|
+
"""A type variable that is bound to an enum."""
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@overload
|
|
14
|
+
def enum_from_proto(
|
|
15
|
+
value: int, enum_type: type[EnumT], *, allow_invalid: Literal[False]
|
|
16
|
+
) -> EnumT: ...
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@overload
|
|
20
|
+
def enum_from_proto(
|
|
21
|
+
value: int, enum_type: type[EnumT], *, allow_invalid: Literal[True] = True
|
|
22
|
+
) -> EnumT | int: ...
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def enum_from_proto(
|
|
26
|
+
value: int, enum_type: type[EnumT], *, allow_invalid: bool = True
|
|
27
|
+
) -> EnumT | int:
|
|
28
|
+
"""Convert a protobuf int enum value to a python enum.
|
|
29
|
+
|
|
30
|
+
Example:
|
|
31
|
+
```python
|
|
32
|
+
import enum
|
|
33
|
+
|
|
34
|
+
from proto import proto_pb2 # Just an example. pylint: disable=import-error
|
|
35
|
+
|
|
36
|
+
@enum.unique
|
|
37
|
+
class SomeEnum(enum.Enum):
|
|
38
|
+
# These values should match the protobuf enum values.
|
|
39
|
+
UNSPECIFIED = 0
|
|
40
|
+
SOME_VALUE = 1
|
|
41
|
+
|
|
42
|
+
enum_value = enum_from_proto(proto_pb2.SomeEnum.SOME_ENUM_SOME_VALUE, SomeEnum)
|
|
43
|
+
# -> SomeEnum.SOME_VALUE
|
|
44
|
+
|
|
45
|
+
enum_value = enum_from_proto(42, SomeEnum)
|
|
46
|
+
# -> 42
|
|
47
|
+
|
|
48
|
+
enum_value = enum_from_proto(
|
|
49
|
+
proto_pb2.SomeEnum.SOME_ENUM_UNKNOWN_VALUE, SomeEnum, allow_invalid=False
|
|
50
|
+
)
|
|
51
|
+
# -> ValueError
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
value: The protobuf int enum value.
|
|
56
|
+
enum_type: The python enum type to convert to.
|
|
57
|
+
allow_invalid: If `True`, return the value as an `int` if the value is not
|
|
58
|
+
a valid member of the enum (this allows for forward-compatibility with new
|
|
59
|
+
enum values defined in the protocol but not added to the Python enum yet).
|
|
60
|
+
If `False`, raise a `ValueError` if the value is not a valid member of the
|
|
61
|
+
enum.
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
The resulting python enum value if the protobuf value is known, otherwise
|
|
65
|
+
the input value converted to a plain `int`.
|
|
66
|
+
|
|
67
|
+
Raises:
|
|
68
|
+
ValueError: If `allow_invalid` is `False` and the value is not a valid member
|
|
69
|
+
of the enum.
|
|
70
|
+
"""
|
|
71
|
+
try:
|
|
72
|
+
return enum_type(value)
|
|
73
|
+
except ValueError:
|
|
74
|
+
if allow_invalid:
|
|
75
|
+
return value
|
|
76
|
+
raise
|
|
@@ -3,16 +3,18 @@
|
|
|
3
3
|
|
|
4
4
|
"""Module to define the metrics used with the common client."""
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
import enum
|
|
7
7
|
from typing import Self
|
|
8
8
|
|
|
9
9
|
# pylint: disable=no-name-in-module
|
|
10
10
|
from frequenz.api.common.v1.metrics.metric_sample_pb2 import Metric as PBMetric
|
|
11
|
+
from typing_extensions import deprecated
|
|
11
12
|
|
|
12
13
|
# pylint: enable=no-name-in-module
|
|
13
14
|
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
@enum.unique
|
|
17
|
+
class Metric(enum.Enum):
|
|
16
18
|
"""List of supported metrics.
|
|
17
19
|
|
|
18
20
|
AC energy metrics information:
|
|
@@ -140,6 +142,7 @@ class Metric(Enum):
|
|
|
140
142
|
SENSOR_IRRADIANCE = PBMetric.METRIC_SENSOR_IRRADIANCE
|
|
141
143
|
|
|
142
144
|
@classmethod
|
|
145
|
+
@deprecated("Use `frequenz.client.common.enum_proto.enum_from_proto` instead.")
|
|
143
146
|
def from_proto(cls, metric: PBMetric.ValueType) -> Self:
|
|
144
147
|
"""Convert a protobuf Metric value to Metric enum.
|
|
145
148
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
from __future__ import annotations
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
import enum
|
|
9
9
|
from typing import final
|
|
10
10
|
|
|
11
11
|
# pylint: disable=no-name-in-module
|
|
@@ -19,6 +19,7 @@ from frequenz.api.common.v1.microgrid.components.components_pb2 import (
|
|
|
19
19
|
ComponentStateCode as PBComponentStateCode,
|
|
20
20
|
)
|
|
21
21
|
from frequenz.core.id import BaseId
|
|
22
|
+
from typing_extensions import deprecated
|
|
22
23
|
|
|
23
24
|
# pylint: enable=no-name-in-module
|
|
24
25
|
|
|
@@ -28,7 +29,8 @@ class ComponentId(BaseId, str_prefix="CID"):
|
|
|
28
29
|
"""A unique identifier for a microgrid component."""
|
|
29
30
|
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
@enum.unique
|
|
33
|
+
class ComponentCategory(enum.Enum):
|
|
32
34
|
"""Possible types of microgrid component."""
|
|
33
35
|
|
|
34
36
|
UNSPECIFIED = PBComponentCategory.COMPONENT_CATEGORY_UNSPECIFIED
|
|
@@ -47,16 +49,63 @@ class ComponentCategory(Enum):
|
|
|
47
49
|
INVERTER = PBComponentCategory.COMPONENT_CATEGORY_INVERTER
|
|
48
50
|
"""An electricity generator, with batteries or solar energy."""
|
|
49
51
|
|
|
52
|
+
CONVERTER = PBComponentCategory.COMPONENT_CATEGORY_CONVERTER
|
|
53
|
+
"""A DC-DC converter."""
|
|
54
|
+
|
|
50
55
|
BATTERY = PBComponentCategory.COMPONENT_CATEGORY_BATTERY
|
|
51
56
|
"""A storage system for electrical energy, used by inverters."""
|
|
52
57
|
|
|
53
58
|
EV_CHARGER = PBComponentCategory.COMPONENT_CATEGORY_EV_CHARGER
|
|
54
59
|
"""A station for charging electrical vehicles."""
|
|
55
60
|
|
|
61
|
+
CRYPTO_MINER = PBComponentCategory.COMPONENT_CATEGORY_CRYPTO_MINER
|
|
62
|
+
"""A crypto miner."""
|
|
63
|
+
|
|
64
|
+
ELECTROLYZER = PBComponentCategory.COMPONENT_CATEGORY_ELECTROLYZER
|
|
65
|
+
"""An electrolyzer for converting water into hydrogen and oxygen."""
|
|
66
|
+
|
|
56
67
|
CHP = PBComponentCategory.COMPONENT_CATEGORY_CHP
|
|
57
68
|
"""A heat and power combustion plant (CHP stands for combined heat and power)."""
|
|
58
69
|
|
|
70
|
+
RELAY = PBComponentCategory.COMPONENT_CATEGORY_RELAY
|
|
71
|
+
"""A relay.
|
|
72
|
+
|
|
73
|
+
Relays generally have two states: open (connected) and closed (disconnected).
|
|
74
|
+
They are generally placed in front of a component, e.g., an inverter, to
|
|
75
|
+
control whether the component is connected to the grid or not.
|
|
76
|
+
"""
|
|
77
|
+
|
|
78
|
+
PRECHARGER = PBComponentCategory.COMPONENT_CATEGORY_PRECHARGER
|
|
79
|
+
"""A precharge module.
|
|
80
|
+
|
|
81
|
+
Precharging involves gradually ramping up the DC voltage to prevent any
|
|
82
|
+
potential damage to sensitive electrical components like capacitors.
|
|
83
|
+
|
|
84
|
+
While many inverters and batteries come equipped with in-built precharging
|
|
85
|
+
mechanisms, some may lack this feature. In such cases, we need to use
|
|
86
|
+
external precharging modules.
|
|
87
|
+
"""
|
|
88
|
+
|
|
89
|
+
FUSE = PBComponentCategory.COMPONENT_CATEGORY_FUSE
|
|
90
|
+
"""A fuse."""
|
|
91
|
+
|
|
92
|
+
VOLTAGE_TRANSFORMER = PBComponentCategory.COMPONENT_CATEGORY_VOLTAGE_TRANSFORMER
|
|
93
|
+
"""A voltage transformer.
|
|
94
|
+
|
|
95
|
+
Voltage transformers are used to step up or step down the voltage, keeping
|
|
96
|
+
the power somewhat constant by increasing or decreasing the current. If voltage is
|
|
97
|
+
stepped up, current is stepped down, and vice versa.
|
|
98
|
+
|
|
99
|
+
Note:
|
|
100
|
+
Voltage transformers have efficiency losses, so the output power is
|
|
101
|
+
always less than the input power.
|
|
102
|
+
"""
|
|
103
|
+
|
|
104
|
+
HVAC = PBComponentCategory.COMPONENT_CATEGORY_HVAC
|
|
105
|
+
"""A Heating, Ventilation, and Air Conditioning (HVAC) system."""
|
|
106
|
+
|
|
59
107
|
@classmethod
|
|
108
|
+
@deprecated("Use `frequenz.client.common.enum_proto.enum_from_proto` instead.")
|
|
60
109
|
def from_proto(
|
|
61
110
|
cls, component_category: PBComponentCategory.ValueType
|
|
62
111
|
) -> ComponentCategory:
|
|
@@ -81,7 +130,8 @@ class ComponentCategory(Enum):
|
|
|
81
130
|
return self.value
|
|
82
131
|
|
|
83
132
|
|
|
84
|
-
|
|
133
|
+
@enum.unique
|
|
134
|
+
class ComponentStateCode(enum.Enum):
|
|
85
135
|
"""All possible states of a microgrid component."""
|
|
86
136
|
|
|
87
137
|
UNSPECIFIED = PBComponentStateCode.COMPONENT_STATE_CODE_UNSPECIFIED
|
|
@@ -161,6 +211,7 @@ class ComponentStateCode(Enum):
|
|
|
161
211
|
"""The precharger circuit is closed, allowing full current to flow to the main circuit."""
|
|
162
212
|
|
|
163
213
|
@classmethod
|
|
214
|
+
@deprecated("Use `frequenz.client.common.enum_proto.enum_from_proto` instead.")
|
|
164
215
|
def from_proto(
|
|
165
216
|
cls, component_state: PBComponentStateCode.ValueType
|
|
166
217
|
) -> ComponentStateCode:
|
|
@@ -185,7 +236,8 @@ class ComponentStateCode(Enum):
|
|
|
185
236
|
return self.value
|
|
186
237
|
|
|
187
238
|
|
|
188
|
-
|
|
239
|
+
@enum.unique
|
|
240
|
+
class ComponentErrorCode(enum.Enum):
|
|
189
241
|
"""All possible errors that can occur across all microgrid component categories."""
|
|
190
242
|
|
|
191
243
|
UNSPECIFIED = PBComponentErrorCode.COMPONENT_ERROR_CODE_UNSPECIFIED
|
|
@@ -338,6 +390,7 @@ class ComponentErrorCode(Enum):
|
|
|
338
390
|
times."""
|
|
339
391
|
|
|
340
392
|
@classmethod
|
|
393
|
+
@deprecated("Use `frequenz.client.common.enum_proto.enum_from_proto` instead.")
|
|
341
394
|
def from_proto(
|
|
342
395
|
cls, component_error_code: PBComponentErrorCode.ValueType
|
|
343
396
|
) -> ComponentErrorCode:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: frequenz-client-common
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Summary: Common code and utilities for Frequenz API clients
|
|
5
5
|
Author-email: Frequenz Energy-as-a-Service GmbH <floss@frequenz.com>
|
|
6
6
|
License: MIT
|
|
@@ -21,8 +21,8 @@ Requires-Python: <4,>=3.11
|
|
|
21
21
|
Description-Content-Type: text/markdown
|
|
22
22
|
License-File: LICENSE
|
|
23
23
|
Requires-Dist: typing-extensions<5,>=4.13.0
|
|
24
|
-
Requires-Dist: frequenz-api-common<7,>=0.6.
|
|
25
|
-
Requires-Dist: frequenz-core<2,>=1.0.
|
|
24
|
+
Requires-Dist: frequenz-api-common<7,>=0.6.1
|
|
25
|
+
Requires-Dist: frequenz-core<2,>=1.0.2
|
|
26
26
|
Provides-Extra: dev-flake8
|
|
27
27
|
Requires-Dist: flake8==7.2.0; extra == "dev-flake8"
|
|
28
28
|
Requires-Dist: flake8-docstrings==1.7.0; extra == "dev-flake8"
|
|
@@ -5,6 +5,7 @@ RELEASE_NOTES.md
|
|
|
5
5
|
pyproject.toml
|
|
6
6
|
src/frequenz/client/common/__init__.py
|
|
7
7
|
src/frequenz/client/common/conftest.py
|
|
8
|
+
src/frequenz/client/common/enum_proto.py
|
|
8
9
|
src/frequenz/client/common/py.typed
|
|
9
10
|
src/frequenz/client/common/metric/__init__.py
|
|
10
11
|
src/frequenz/client/common/microgrid/__init__.py
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# Frequenz Client Common Library Release Notes
|
|
2
|
-
|
|
3
|
-
## Summary
|
|
4
|
-
|
|
5
|
-
This release replaces the failed v0.3.1 release.
|
|
6
|
-
|
|
7
|
-
## Upgrading
|
|
8
|
-
|
|
9
|
-
- The `typing-extensions` dependency minimum version was bumped to 4.13 to support Python 3.12.
|
|
10
|
-
|
|
11
|
-
## New Features
|
|
12
|
-
|
|
13
|
-
- New `BaseId` class to create unique IDs for entities in the system.
|
|
14
|
-
- New ID classes for microgrid-related entities:
|
|
15
|
-
|
|
16
|
-
* `EnterpriseId`
|
|
17
|
-
* `MicrogridId`
|
|
18
|
-
* `ComponentId`
|
|
19
|
-
* `SensorId`
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{frequenz_client_common-0.3.2 → frequenz_client_common-0.3.3}/src/frequenz/client/common/__init__.py
RENAMED
|
File without changes
|
{frequenz_client_common-0.3.2 → frequenz_client_common-0.3.3}/src/frequenz/client/common/conftest.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{frequenz_client_common-0.3.2 → frequenz_client_common-0.3.3}/src/frequenz/client/common/py.typed
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|