Skip to content

Commit

Permalink
Update microgrid client to latest version (#1109)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marenz authored Nov 19, 2024
2 parents 6cb8bee + 40f7e64 commit 53792f2
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

## New Features

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

## Bug Fixes

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies = [
# Make sure to update the mkdocs.yml file when
# changing the version
# (plugins.mkdocstrings.handlers.python.import)
"frequenz-client-microgrid >= 0.5.1, < 0.6.0",
"frequenz-client-microgrid >= 0.6.0, < 0.7.0",
"frequenz-channels >= 1.2.0, < 2.0.0",
"frequenz-quantities == 1.0.0rc3",
"networkx >= 2.8, < 4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
selected_from,
)
from frequenz.client.microgrid import (
ApiClient,
ApiClientError,
ComponentCategory,
EVChargerData,
MicrogridApiClient,
)
from frequenz.quantities import Power, Voltage
from typing_extensions import override
Expand Down Expand Up @@ -292,7 +292,7 @@ async def _run(self) -> None: # pylint: disable=too-many-locals

async def _set_api_power(
self,
api: ApiClient,
api: MicrogridApiClient,
target_power_changes: dict[int, Power],
api_request_timeout: timedelta,
) -> Result:
Expand Down
4 changes: 2 additions & 2 deletions src/frequenz/sdk/microgrid/component_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@

import networkx as nx
from frequenz.client.microgrid import (
ApiClient,
Component,
ComponentCategory,
Connection,
InverterType,
MicrogridApiClient,
)

_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -559,7 +559,7 @@ def refresh_from(

async def refresh_from_api(
self,
api: ApiClient,
api: MicrogridApiClient,
correct_errors: Callable[["_MicrogridComponentGraph"], None] | None = None,
) -> None:
"""Refresh the contents of a component graph from the remote API.
Expand Down
14 changes: 7 additions & 7 deletions src/frequenz/sdk/microgrid/connection_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import logging
from abc import ABC, abstractmethod

from frequenz.client.microgrid import ApiClient, Location, Metadata
from frequenz.client.microgrid import Location, Metadata, MicrogridApiClient

from .component_graph import ComponentGraph, _MicrogridComponentGraph

Expand Down Expand Up @@ -41,8 +41,8 @@ def server_url(self) -> str:

@property
@abstractmethod
def api_client(self) -> ApiClient:
"""Get ApiClient.
def api_client(self) -> MicrogridApiClient:
"""Get the MicrogridApiClient.
Returns:
api client
Expand Down Expand Up @@ -97,7 +97,7 @@ def __init__(self, server_url: str) -> None:
`grpc://localhost:1090?ssl=true`.
"""
super().__init__(server_url)
self._api = ApiClient(server_url)
self._api = MicrogridApiClient(server_url)
# To create graph from the api we need await.
# So create empty graph here, and update it in `run` method.
self._graph = _MicrogridComponentGraph()
Expand All @@ -106,8 +106,8 @@ def __init__(self, server_url: str) -> None:
"""The metadata of the microgrid."""

@property
def api_client(self) -> ApiClient:
"""Get ApiClient.
def api_client(self) -> MicrogridApiClient:
"""Get the MicrogridApiClient.
Returns:
api client
Expand Down Expand Up @@ -154,7 +154,7 @@ async def _update_api(self, server_url: str) -> None:
"""
await super()._update_api(server_url) # pylint: disable=protected-access

self._api = ApiClient(server_url)
self._api = MicrogridApiClient(server_url)
await self._initialize()

async def _initialize(self) -> None:
Expand Down
4 changes: 2 additions & 2 deletions tests/microgrid/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

import pytest
from frequenz.client.microgrid import (
ApiClient,
Component,
ComponentCategory,
ComponentMetadata,
Connection,
Fuse,
InverterType,
MicrogridApiClient,
)

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

client = mock.MagicMock(name="client", spec=ApiClient)
client = mock.MagicMock(name="client", spec=MicrogridApiClient)
client.components = mock.AsyncMock(name="client.components()", return_value=[])
client.connections = mock.AsyncMock(
name="client.connections()", return_value=[]
Expand Down
2 changes: 1 addition & 1 deletion tests/microgrid/test_microgrid_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ async def test_connection_manager(
microgrid_client.metadata = AsyncMock(return_value=metadata)

with mock.patch(
"frequenz.sdk.microgrid.connection_manager.ApiClient",
"frequenz.sdk.microgrid.connection_manager.MicrogridApiClient",
return_value=microgrid_client,
):
# Get instance without initializing git first.
Expand Down

0 comments on commit 53792f2

Please sign in to comment.