Skip to content

Commit 8fa9081

Browse files
committed
Make functions in private module public
The module itself is private, but the functions are used outside the module, so they should be public. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 5694504 commit 8fa9081

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

src/frequenz/client/microgrid/_client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
from ._component import (
3636
Component,
3737
ComponentCategory,
38-
_component_category_from_protobuf,
39-
_component_metadata_from_protobuf,
40-
_component_type_from_protobuf,
38+
component_category_from_protobuf,
39+
component_metadata_from_protobuf,
40+
component_type_from_protobuf,
4141
)
4242
from ._component_data import (
4343
BatteryData,
@@ -132,9 +132,9 @@ async def components(self) -> Iterable[Component]:
132132
result: Iterable[Component] = map(
133133
lambda c: Component(
134134
c.id,
135-
_component_category_from_protobuf(c.category),
136-
_component_type_from_protobuf(c.category, c.inverter),
137-
_component_metadata_from_protobuf(c.category, c.grid),
135+
component_category_from_protobuf(c.category),
136+
component_type_from_protobuf(c.category, c.inverter),
137+
component_metadata_from_protobuf(c.category, c.grid),
138138
),
139139
components_only,
140140
)

src/frequenz/client/microgrid/_component.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class InverterType(ComponentType):
3535
"""Hybrid inverter."""
3636

3737

38-
def _component_type_from_protobuf(
38+
def component_type_from_protobuf(
3939
component_category: PbComponentCategory.ValueType,
4040
component_metadata: PbInverterMetadata,
4141
) -> ComponentType | None:
@@ -87,7 +87,7 @@ class ComponentCategory(Enum):
8787
"""CHP component."""
8888

8989

90-
def _component_category_from_protobuf(
90+
def component_category_from_protobuf(
9191
component_category: PbComponentCategory.ValueType,
9292
) -> ComponentCategory:
9393
"""Convert a protobuf ComponentCategory message to ComponentCategory enum.
@@ -135,10 +135,21 @@ class GridMetadata(ComponentMetadata):
135135
"""Metadata for a grid connection point."""
136136

137137

138-
def _component_metadata_from_protobuf(
138+
def component_metadata_from_protobuf(
139139
component_category: PbComponentCategory.ValueType,
140140
component_metadata: PbGridMetadata,
141141
) -> GridMetadata | None:
142+
"""Convert a protobuf GridMetadata message to GridMetadata class.
143+
144+
For internal-only use by the `microgrid` package.
145+
146+
Args:
147+
component_category: category the type belongs to.
148+
component_metadata: protobuf metadata to fetch type from.
149+
150+
Returns:
151+
GridMetadata instance corresponding to the protobuf message.
152+
"""
142153
if component_category == PbComponentCategory.COMPONENT_CATEGORY_GRID:
143154
max_current = component_metadata.rated_fuse_current
144155
fuse = Fuse(max_current)

0 commit comments

Comments
 (0)