Skip to content

Commit 647149e

Browse files
committed
Remove the LoggingConfig.load method
We now have `frequenz.sdk.config.load_config()` for this. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent baf9b77 commit 647149e

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

src/frequenz/sdk/config/_logging_actor.py

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@
66
import logging
77
from collections.abc import Mapping
88
from dataclasses import field
9-
from typing import Annotated, Any, Self, cast
9+
from typing import Annotated, Any
1010

1111
import marshmallow
1212
import marshmallow.validate
1313
from frequenz.channels import Receiver
14-
from marshmallow import RAISE
15-
from marshmallow_dataclass import class_schema, dataclass
14+
from marshmallow_dataclass import dataclass
1615

1716
from frequenz.sdk.actor import Actor
1817

18+
from ._util import load_config
19+
1920
_logger = logging.getLogger(__name__)
2021

2122
LogLevel = Annotated[
@@ -69,22 +70,6 @@ class LoggingConfig:
6970
)
7071
"""The list of loggers configurations."""
7172

72-
@classmethod
73-
def load(cls, configs: Mapping[str, Any]) -> Self: # noqa: DOC502
74-
"""Load and validate configs from a dictionary.
75-
76-
Args:
77-
configs: The configuration to validate.
78-
79-
Returns:
80-
The configuration if they are valid.
81-
82-
Raises:
83-
ValidationError: if the configuration are invalid.
84-
"""
85-
schema = class_schema(cls)()
86-
return cast(Self, schema.load(configs, unknown=RAISE))
87-
8873

8974
class LoggingConfigUpdatingActor(Actor):
9075
"""Actor that listens for logging configuration changes and sets them.
@@ -174,7 +159,7 @@ async def _run(self) -> None:
174159
"""Listen for configuration changes and update logging."""
175160
async for message in self._config_recv:
176161
try:
177-
new_config = LoggingConfig.load(message)
162+
new_config = load_config(LoggingConfig, message)
178163
except marshmallow.ValidationError:
179164
_logger.exception(
180165
"Invalid logging configuration received. Skipping config update"

0 commit comments

Comments
 (0)