Skip to content
Merged
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 microgrid client dependency has been updated to version 0.9.0

## New Features

Expand Down
3 changes: 2 additions & 1 deletion benchmarks/power_distribution/power_distributor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
from typing import Any

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

from frequenz.sdk import microgrid
Expand Down
32 changes: 21 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ dependencies = [
# Make sure to update the mkdocs.yml file when
# changing the version
# (plugins.mkdocstrings.handlers.python.import)
"frequenz-client-microgrid >= 0.7.0, < 0.8.0",
"frequenz-channels >= 1.6.0, < 2.0.0",
"frequenz-client-microgrid >= 0.9.0, < 0.10.0",
"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",
"networkx >= 2.8, < 4",
"numpy >= 2, < 3",
"typing_extensions >= 4.6.1, < 5",
"typing_extensions >= 4.13.0, < 5",
"marshmallow >= 3.19.0, < 5",
"marshmallow_dataclass >= 8.7.1, < 9",
]
Expand Down Expand Up @@ -163,21 +164,30 @@ disable = [
max-attributes = 12

[tool.pytest.ini_options]
# We need to ignore PytestUnraisableExceptionWarning because we have some
# cleanup issues, and sometimes exceptions are raised in __del__ methods, for
# example when trying to do async stuff and the event loop is already closed.
# This could even be caused by the GC, some time after the test function that
# has the issue was completed.
# Please see this issue for more details:
# https://github.com/frequenz-floss/frequenz-sdk-python/issues/982
addopts = "-W=all -Werror -Wdefault::DeprecationWarning -Wdefault::PendingDeprecationWarning -Wdefault::pytest.PytestUnraisableExceptionWarning -vv"
addopts = "-vv"
testpaths = ["tests", "src"]
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function"
required_plugins = ["pytest-asyncio", "pytest-mock"]
markers = [
"integration: integration tests (deselect with '-m \"not integration\"')",
]
filterwarnings = [
"error",
"once::DeprecationWarning",
"once::PendingDeprecationWarning",
# We need to ignore PytestUnraisableExceptionWarning because we have some
# cleanup issues, and sometimes exceptions are raised in __del__ methods, for
# example when trying to do async stuff and the event loop is already closed.
# This could even be caused by the GC, some time after the test function that
# has the issue was completed.
# Please see this issue for more details:
# https://github.com/frequenz-floss/frequenz-sdk-python/issues/982
"default::pytest.PytestUnraisableExceptionWarning",
# We use a raw string (single quote) to avoid the need to escape special
# chars as this is a regex
'ignore:Protobuf gencode version .*exactly one major version older.*:UserWarning',
]

[tool.mypy]
explicit_package_bases = true
Expand Down
7 changes: 0 additions & 7 deletions src/frequenz/sdk/actor/_background_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,6 @@ def __await__(self) -> collections.abc.Generator[None, None, None]:
"""
return self.wait().__await__()

def __del__(self) -> None:
"""Destroy this instance.

Cancel all running tasks spawned by this background service.
"""
self.cancel("{self!r} was deleted")

Comment on lines -271 to -277
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the fix is to check if the event loop is running before calling cancel, because when the loop is there, we still want to cancel and cleanup.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about that, but I don't think we gain much from that tbh. Cleanup should not rely on del

def __repr__(self) -> str:
"""Return a string representation of this instance.

Expand Down
3 changes: 2 additions & 1 deletion src/frequenz/sdk/microgrid/_data_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
from datetime import timedelta

from frequenz.channels import Broadcast, Sender
from frequenz.client.microgrid import ComponentCategory, ComponentId, InverterType
from frequenz.client.common.microgrid.components import ComponentId
from frequenz.client.microgrid import ComponentCategory, InverterType

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
from dataclasses import dataclass
from datetime import datetime

from frequenz.client.microgrid import ComponentId, ComponentMetricId
from frequenz.client.common.microgrid.components import ComponentId
from frequenz.client.microgrid import ComponentMetricId

__all__ = ["ComponentMetricRequest", "ComponentMetricId"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
from typing import Any

from frequenz.channels import Receiver, Sender
from frequenz.client.common.microgrid.components import ComponentId
from frequenz.client.microgrid import (
BatteryData,
ComponentCategory,
ComponentId,
ComponentMetricId,
EVChargerData,
InverterData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
from datetime import timedelta

from frequenz.channels import LatestValueCache, Receiver, Sender
from frequenz.client.common.microgrid.components import ComponentId
from frequenz.client.microgrid import (
ApiClientError,
BatteryData,
ComponentCategory,
ComponentId,
InverterData,
OperationOutOfRange,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import collections.abc

from frequenz.channels import Sender
from frequenz.client.microgrid import ComponentId
from frequenz.client.common.microgrid.components import ComponentId

from .._component_status import ComponentPoolStatus
from ..request import Request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from dataclasses import dataclass, field
from datetime import timedelta

from frequenz.client.microgrid import ComponentId
from frequenz.client.common.microgrid.components import ComponentId
from frequenz.quantities import Current


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
select,
selected_from,
)
from frequenz.client.common.microgrid.components import ComponentId
from frequenz.client.microgrid import (
ApiClientError,
ComponentCategory,
ComponentId,
EVChargerData,
MicrogridApiClient,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from datetime import datetime
from typing import Iterable

from frequenz.client.microgrid import ComponentId, EVChargerData
from frequenz.client.common.microgrid.components import ComponentId
from frequenz.client.microgrid import EVChargerData
from frequenz.quantities import Power


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
from datetime import timedelta

from frequenz.channels import LatestValueCache, Sender
from frequenz.client.common.microgrid.components import ComponentId
from frequenz.client.microgrid import (
ApiClientError,
ComponentCategory,
ComponentId,
InverterData,
InverterType,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from datetime import timedelta

from frequenz.channels import Broadcast, Merger, Receiver, Sender, merge
from frequenz.client.microgrid import ComponentId
from frequenz.client.common.microgrid.components import ComponentId

from ..._internal._asyncio import cancel_and_await
from ._component_status import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@

from frequenz.channels import Receiver, Sender, select, selected_from
from frequenz.channels.timer import SkipMissedAndDrift, Timer
from frequenz.client.common.microgrid.components import ComponentId
from frequenz.client.microgrid import (
BatteryComponentState,
BatteryData,
BatteryRelayState,
ComponentCategory,
ComponentData,
ComponentId,
ErrorLevel,
InverterComponentState,
InverterData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from datetime import timedelta

from frequenz.channels import Receiver, Sender
from frequenz.client.microgrid import ComponentId
from frequenz.client.common.microgrid.components import ComponentId

from ....actor._background_service import BackgroundService

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

from frequenz.channels import Receiver, Sender, select, selected_from
from frequenz.channels.timer import SkipMissedAndDrift, Timer
from frequenz.client.common.microgrid.components import ComponentId
from frequenz.client.microgrid import (
ComponentId,
EVChargerCableState,
EVChargerComponentState,
EVChargerData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

from frequenz.channels import Receiver, Sender, select, selected_from
from frequenz.channels.timer import SkipMissedAndDrift, Timer
from frequenz.client.microgrid import ComponentId, InverterComponentState, InverterData
from frequenz.client.common.microgrid.components import ComponentId
from frequenz.client.microgrid import InverterComponentState, InverterData
from typing_extensions import override

from ...._internal._asyncio import run_forever
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from dataclasses import dataclass
from typing import NamedTuple, Sequence

from frequenz.client.microgrid import BatteryData, ComponentId, InverterData
from frequenz.client.common.microgrid.components import ComponentId
from frequenz.client.microgrid import BatteryData, InverterData
from frequenz.quantities import Power

from ...._internal._math import is_close_to_zero
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@
from datetime import timedelta

from frequenz.channels import Receiver, Sender
from frequenz.client.microgrid import (
ComponentCategory,
ComponentId,
ComponentType,
InverterType,
)
from frequenz.client.common.microgrid.components import ComponentId
from frequenz.client.microgrid import ComponentCategory, ComponentType, InverterType
from typing_extensions import override

from ...actor._actor import Actor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import dataclasses
from collections import abc

from frequenz.client.microgrid import ComponentId
from frequenz.client.common.microgrid.components import ComponentId
from frequenz.quantities import Power


Expand Down
3 changes: 1 addition & 2 deletions src/frequenz/sdk/microgrid/_power_distributing/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import dataclasses
from collections import abc

from frequenz.client.microgrid import ComponentId
from frequenz.client.common.microgrid.components import ComponentId
from frequenz.quantities import Power

from .request import Request
Expand Down Expand Up @@ -119,7 +119,6 @@ class OutOfBounds(_BaseResultMixin):
from frequenz.sdk.actor.power_distributing.request import Request
from frequenz.sdk.actor.power_distributing.result import PowerBounds
from frequenz.quantities import Power
from frequenz.client.microgrid import ComponentId

def handle_power_request_result(result: Result) -> None:
match result:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import enum
import typing

from frequenz.client.microgrid import ComponentId
from frequenz.client.common.microgrid.components import ComponentId
from frequenz.quantities import Power

from ... import timeseries
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import typing
from datetime import timedelta

from frequenz.client.microgrid import ComponentId
from frequenz.client.common.microgrid.components import ComponentId
from frequenz.quantities import Power
from typing_extensions import override

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@

from frequenz.channels import Receiver, Sender, select, selected_from
from frequenz.channels.timer import SkipMissedAndDrift, Timer
from frequenz.client.microgrid import (
ComponentCategory,
ComponentId,
ComponentType,
InverterType,
)
from frequenz.client.common.microgrid.components import ComponentId
from frequenz.client.microgrid import ComponentCategory, ComponentType, InverterType
from typing_extensions import override

from ..._internal._asyncio import run_forever
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import typing
from datetime import timedelta

from frequenz.client.microgrid import ComponentId
from frequenz.client.common.microgrid.components import ComponentId
from frequenz.quantities import Power
from typing_extensions import override

Expand Down
2 changes: 1 addition & 1 deletion src/frequenz/sdk/microgrid/component_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
from collections.abc import Callable, Iterable

import networkx as nx
from frequenz.client.common.microgrid.components import ComponentId
from frequenz.client.microgrid import (
Component,
ComponentCategory,
ComponentId,
Connection,
InverterType,
MicrogridApiClient,
Expand Down
8 changes: 2 additions & 6 deletions src/frequenz/sdk/microgrid/connection_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@
import logging
from abc import ABC, abstractmethod

from frequenz.client.microgrid import (
Location,
Metadata,
MicrogridApiClient,
MicrogridId,
)
from frequenz.client.common.microgrid import MicrogridId
from frequenz.client.microgrid import Location, Metadata, MicrogridApiClient

from .component_graph import ComponentGraph, _MicrogridComponentGraph

Expand Down
8 changes: 2 additions & 6 deletions src/frequenz/sdk/timeseries/_grid_frequency.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@
import logging

from frequenz.channels import Receiver, Sender
from frequenz.client.microgrid import (
Component,
ComponentCategory,
ComponentId,
ComponentMetricId,
)
from frequenz.client.common.microgrid.components import ComponentId
from frequenz.client.microgrid import Component, ComponentCategory, ComponentMetricId
from frequenz.quantities import Frequency, Quantity

from .._internal._channels import ChannelRegistry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import uuid
from collections import abc

from frequenz.client.microgrid import ComponentId
from frequenz.client.common.microgrid.components import ComponentId
from frequenz.quantities import Energy, Percentage, Power, Temperature

from ... import timeseries
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from typing import Any

from frequenz.channels import Receiver, Sender
from frequenz.client.microgrid import ComponentCategory, ComponentId
from frequenz.client.common.microgrid.components import ComponentId
from frequenz.client.microgrid import ComponentCategory

from ..._internal._asyncio import cancel_and_await
from ..._internal._channels import ChannelRegistry, ReceiverFetcher
Expand Down
Loading
Loading