Skip to content
Draft
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
2 changes: 1 addition & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## Upgrading

<!-- Here goes notes on how to upgrade from previous versions, including deprecations and what they should be replaced with -->
- The SDK now depends on the `frequenz-client-microgrid` v0.18.x series. The main change is now all component and microgrid IDs need to be passed using the wrapper classes `ComponentId`/`MicrogridId` instead of `int`.

## New Features

Expand Down
11 changes: 5 additions & 6 deletions benchmarks/power_distribution/power_distributor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from frequenz.channels import Broadcast
from frequenz.client.common.microgrid.components import ComponentId
from frequenz.client.microgrid import Component, ComponentCategory
from frequenz.client.microgrid.component import Battery
from frequenz.quantities import Power

from frequenz.sdk import microgrid
Expand Down Expand Up @@ -116,8 +116,7 @@ async def run_test( # pylint: disable=too-many-locals
battery_status_channel = Broadcast[ComponentPoolStatus](name="battery-status")
power_result_channel = Broadcast[Result](name="power-result")
async with PowerDistributingActor(
component_category=ComponentCategory.BATTERY,
component_type=None,
component_type=Battery,
requests_receiver=power_request_channel.new_receiver(),
results_sender=power_result_channel.new_sender(),
component_pool_status_sender=battery_status_channel.new_sender(),
Expand All @@ -143,10 +142,10 @@ async def run() -> None:
ResamplerConfig2(resampling_period=timedelta(seconds=1.0)),
)

all_batteries: set[Component] = connection_manager.get().component_graph.components(
component_categories={ComponentCategory.BATTERY}
all_batteries = connection_manager.get().component_graph.components(
filter_by_types={Battery},
)
batteries_ids = {c.component_id for c in all_batteries}
batteries_ids = {c.id for c in all_batteries}
# Take some time to get data from components
await asyncio.sleep(4)
with open("/dev/stdout", "w", encoding="utf-8") as csvfile:
Expand Down
8 changes: 4 additions & 4 deletions benchmarks/timeseries/benchmark_datasourcing.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from typing import Any

from frequenz.channels import Broadcast, Receiver, ReceiverStoppedError
from frequenz.client.microgrid import ComponentMetricId
from frequenz.client.microgrid.metrics import Metric

from frequenz.sdk import microgrid
from frequenz.sdk._internal._channels import ChannelRegistry
Expand All @@ -37,9 +37,9 @@
sys.exit(1)

COMPONENT_METRIC_IDS = [
ComponentMetricId.CURRENT_PHASE_1,
ComponentMetricId.CURRENT_PHASE_2,
ComponentMetricId.CURRENT_PHASE_3,
Metric.AC_CURRENT_PHASE_1,
Metric.AC_CURRENT_PHASE_2,
Metric.AC_CURRENT_PHASE_3,
]


Expand Down
2 changes: 1 addition & 1 deletion examples/battery_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from frequenz.sdk import microgrid
from frequenz.sdk.timeseries import ResamplerConfig2

MICROGRID_API_URL = "grpc://microgrid.sandbox.api.frequenz.io:62060"
MICROGRID_API_URL = "grpc://microgrid.sandbox.api.frequenz.io:61060"


async def main() -> None:
Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ plugins:
- https://frequenz-floss.github.io/frequenz-channels-python/v1/objects.inv
- https://frequenz-floss.github.io/frequenz-client-common-python/v0.3/objects.inv
- https://frequenz-floss.github.io/frequenz-client-microgrid-python/v0.9/objects.inv
#- https://frequenz-floss.github.io/frequenz-client-microgrid-python/v0.18/objects.inv
- https://frequenz-floss.github.io/frequenz-core-python/v1/objects.inv
- https://frequenz-floss.github.io/frequenz-quantities-python/v1/objects.inv
- https://lovasoa.github.io/marshmallow_dataclass/html/objects.inv
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ dependencies = [
# Make sure to update the mkdocs.yml file when
# changing the version
# (plugins.mkdocstrings.handlers.python.import)
"frequenz-client-microgrid >= 0.9.0, < 0.10.0",
#"frequenz-client-microgrid >= 0.18.0, < 0.19.0",
"frequenz-client-microgrid @ git+https://github.com/frequenz-floss/frequenz-client-microgrid-python@refs/heads/v0.18.x",
"frequenz-client-common >= 0.3.2, < 0.4.0",
"frequenz-channels >= 1.6.1, < 2.0.0",
"frequenz-quantities[marshmallow] >= 1.0.0, < 2.0.0",
Expand Down
9 changes: 4 additions & 5 deletions src/frequenz/sdk/microgrid/_data_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from frequenz.channels import Broadcast, Sender
from frequenz.client.common.microgrid.components import ComponentId
from frequenz.client.microgrid import ComponentCategory, InverterType
from frequenz.client.microgrid.component import Battery, EvCharger, SolarInverter

from frequenz.sdk.microgrid._power_managing._base_classes import Algorithm, DefaultPower

Expand Down Expand Up @@ -105,23 +105,22 @@ def __init__(
self._channel_registry,
api_power_request_timeout=api_power_request_timeout,
power_manager_algorithm=Algorithm.SHIFTING_MATRYOSHKA,
component_category=ComponentCategory.BATTERY,
default_power=DefaultPower.ZERO,
component_class=Battery,
)
self._ev_power_wrapper = PowerWrapper(
self._channel_registry,
api_power_request_timeout=api_power_request_timeout,
power_manager_algorithm=Algorithm.MATRYOSHKA,
component_category=ComponentCategory.EV_CHARGER,
default_power=DefaultPower.MAX,
component_class=EvCharger,
)
self._pv_power_wrapper = PowerWrapper(
self._channel_registry,
api_power_request_timeout=api_power_request_timeout,
power_manager_algorithm=Algorithm.MATRYOSHKA,
component_category=ComponentCategory.INVERTER,
component_type=InverterType.SOLAR,
default_power=DefaultPower.MIN,
component_class=SolarInverter,
)

self._logical_meter: LogicalMeter | None = None
Expand Down
8 changes: 5 additions & 3 deletions src/frequenz/sdk/microgrid/_data_sourcing/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# License: MIT
# Copyright © 2022 Frequenz Energy-as-a-Service GmbH

"""The DataSourcingActor."""
"""Data sourcing actor."""

from ._component_metric_request import ComponentMetricId, ComponentMetricRequest
from frequenz.client.microgrid.metrics import Metric

from ._component_metric_request import ComponentMetricRequest
from .data_sourcing import DataSourcingActor

__all__ = [
"ComponentMetricId",
"Metric",
"ComponentMetricRequest",
"DataSourcingActor",
]
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
from datetime import datetime

from frequenz.client.common.microgrid.components import ComponentId
from frequenz.client.microgrid import ComponentMetricId
from frequenz.client.microgrid.metrics import Metric

__all__ = ["ComponentMetricRequest", "ComponentMetricId"]
from frequenz.sdk.microgrid._old_component_data import TransitionalMetric

__all__ = ["ComponentMetricRequest", "Metric"]


@dataclass
Expand All @@ -25,7 +27,7 @@ class ComponentMetricRequest:
metric. For example, requesters can use different `namespace` values to subscribe to
raw or resampled data streams separately. This ensures that each requester receives
the appropriate type of data without interference. Requests with the same
`namespace`, `component_id`, and `metric_id` will use the same channel, preventing
`namespace`, `component_id`, and `metric` will use the same channel, preventing
unnecessary duplication of data streams.

The requester and provider must use the same channel name so that they can
Expand All @@ -40,7 +42,7 @@ class ComponentMetricRequest:
component_id: ComponentId
"""The ID of the requested component."""

metric_id: ComponentMetricId
metric: Metric | TransitionalMetric
"""The ID of the requested component's metric."""

start_time: datetime | None
Expand All @@ -60,7 +62,7 @@ def get_channel_name(self) -> str:
"component_metric_request<"
f"namespace={self.namespace},"
f"component_id={self.component_id},"
f"metric_id={self.metric_id.name}"
f"metric={self.metric.name}"
f"{start}"
">"
)
Loading
Loading