Skip to content

Commit 53792f2

Browse files
authored
Update microgrid client to latest version (#1109)
2 parents 6cb8bee + 40f7e64 commit 53792f2

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

RELEASE_NOTES.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
## New Features
1212

13-
<!-- Here goes the main new features and examples or instructions on how to use them -->
13+
* The `MicrogridApiClient` was updated to the latest version.
1414

1515
## Bug Fixes
1616

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ dependencies = [
2929
# Make sure to update the mkdocs.yml file when
3030
# changing the version
3131
# (plugins.mkdocstrings.handlers.python.import)
32-
"frequenz-client-microgrid >= 0.5.1, < 0.6.0",
32+
"frequenz-client-microgrid >= 0.6.0, < 0.7.0",
3333
"frequenz-channels >= 1.2.0, < 2.0.0",
3434
"frequenz-quantities == 1.0.0rc3",
3535
"networkx >= 2.8, < 4",

src/frequenz/sdk/microgrid/_power_distributing/_component_managers/_ev_charger_manager/_ev_charger_manager.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
selected_from,
1818
)
1919
from frequenz.client.microgrid import (
20-
ApiClient,
2120
ApiClientError,
2221
ComponentCategory,
2322
EVChargerData,
23+
MicrogridApiClient,
2424
)
2525
from frequenz.quantities import Power, Voltage
2626
from typing_extensions import override
@@ -292,7 +292,7 @@ async def _run(self) -> None: # pylint: disable=too-many-locals
292292

293293
async def _set_api_power(
294294
self,
295-
api: ApiClient,
295+
api: MicrogridApiClient,
296296
target_power_changes: dict[int, Power],
297297
api_request_timeout: timedelta,
298298
) -> Result:

src/frequenz/sdk/microgrid/component_graph.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828

2929
import networkx as nx
3030
from frequenz.client.microgrid import (
31-
ApiClient,
3231
Component,
3332
ComponentCategory,
3433
Connection,
3534
InverterType,
35+
MicrogridApiClient,
3636
)
3737

3838
_logger = logging.getLogger(__name__)
@@ -559,7 +559,7 @@ def refresh_from(
559559

560560
async def refresh_from_api(
561561
self,
562-
api: ApiClient,
562+
api: MicrogridApiClient,
563563
correct_errors: Callable[["_MicrogridComponentGraph"], None] | None = None,
564564
) -> None:
565565
"""Refresh the contents of a component graph from the remote API.

src/frequenz/sdk/microgrid/connection_manager.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import logging
1212
from abc import ABC, abstractmethod
1313

14-
from frequenz.client.microgrid import ApiClient, Location, Metadata
14+
from frequenz.client.microgrid import Location, Metadata, MicrogridApiClient
1515

1616
from .component_graph import ComponentGraph, _MicrogridComponentGraph
1717

@@ -41,8 +41,8 @@ def server_url(self) -> str:
4141

4242
@property
4343
@abstractmethod
44-
def api_client(self) -> ApiClient:
45-
"""Get ApiClient.
44+
def api_client(self) -> MicrogridApiClient:
45+
"""Get the MicrogridApiClient.
4646
4747
Returns:
4848
api client
@@ -97,7 +97,7 @@ def __init__(self, server_url: str) -> None:
9797
`grpc://localhost:1090?ssl=true`.
9898
"""
9999
super().__init__(server_url)
100-
self._api = ApiClient(server_url)
100+
self._api = MicrogridApiClient(server_url)
101101
# To create graph from the api we need await.
102102
# So create empty graph here, and update it in `run` method.
103103
self._graph = _MicrogridComponentGraph()
@@ -106,8 +106,8 @@ def __init__(self, server_url: str) -> None:
106106
"""The metadata of the microgrid."""
107107

108108
@property
109-
def api_client(self) -> ApiClient:
110-
"""Get ApiClient.
109+
def api_client(self) -> MicrogridApiClient:
110+
"""Get the MicrogridApiClient.
111111
112112
Returns:
113113
api client
@@ -154,7 +154,7 @@ async def _update_api(self, server_url: str) -> None:
154154
"""
155155
await super()._update_api(server_url) # pylint: disable=protected-access
156156

157-
self._api = ApiClient(server_url)
157+
self._api = MicrogridApiClient(server_url)
158158
await self._initialize()
159159

160160
async def _initialize(self) -> None:

tests/microgrid/test_graph.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111

1212
import pytest
1313
from frequenz.client.microgrid import (
14-
ApiClient,
1514
Component,
1615
ComponentCategory,
1716
ComponentMetadata,
1817
Connection,
1918
Fuse,
2019
InverterType,
20+
MicrogridApiClient,
2121
)
2222

2323
import frequenz.sdk.microgrid.component_graph as gr
@@ -899,7 +899,7 @@ async def test_refresh_from_api(self) -> None:
899899
with pytest.raises(gr.InvalidGraphError):
900900
graph.validate()
901901

902-
client = mock.MagicMock(name="client", spec=ApiClient)
902+
client = mock.MagicMock(name="client", spec=MicrogridApiClient)
903903
client.components = mock.AsyncMock(name="client.components()", return_value=[])
904904
client.connections = mock.AsyncMock(
905905
name="client.connections()", return_value=[]

tests/microgrid/test_microgrid_api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ async def test_connection_manager(
126126
microgrid_client.metadata = AsyncMock(return_value=metadata)
127127

128128
with mock.patch(
129-
"frequenz.sdk.microgrid.connection_manager.ApiClient",
129+
"frequenz.sdk.microgrid.connection_manager.MicrogridApiClient",
130130
return_value=microgrid_client,
131131
):
132132
# Get instance without initializing git first.

0 commit comments

Comments
 (0)