Skip to content

Commit 35bf9b4

Browse files
committed
Improve documentation for power distributor's Request
Also improve the imports and type annotations. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 7e4ae50 commit 35bf9b4

File tree

1 file changed

+20
-12
lines changed
  • src/frequenz/sdk/actor/power_distributing

1 file changed

+20
-12
lines changed

src/frequenz/sdk/actor/power_distributing/request.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,30 @@
22
# Copyright © 2022 Frequenz Energy-as-a-Service GmbH
33
"""Definition of the user request."""
44

5-
from dataclasses import dataclass
6-
from typing import Set
5+
from __future__ import annotations
76

7+
import dataclasses
88

9-
@dataclass
9+
10+
@dataclasses.dataclass
1011
class Request:
11-
"""Request from the user."""
12+
"""Request to set power to the `PowerDistributingActor`."""
1213

13-
# How much power to set
1414
power: int
15-
# In which batteries the power should be set
16-
batteries: Set[int]
17-
# Timeout for the server to respond on the requests.
15+
"""The amount of power to be set."""
16+
17+
batteries: set[int]
18+
"""The set of batteries to use when requesting the power to be set."""
19+
1820
request_timeout_sec: float = 5.0
19-
# If True and requested power value is above upper bound, then the power will be
20-
# decreased to match the bounds. Only the decreased power will be set.
21-
# If False and the requested power is above upper bound, then request won't
22-
# be processed. result.OutOfBound message will be send back to the user.
21+
"""The maximum amount of time to wait for the request to be fulfilled."""
22+
2323
adjust_power: bool = True
24+
"""Whether to adjust the power to match the bounds.
25+
26+
If `True`, the power will be adjusted (lowered) to match the bounds, so
27+
only the decreased power will be set.
28+
29+
If `False` and the power is outside the batteries' bounds, the request will
30+
fail and replied to with an `OutOfBound` result.
31+
"""

0 commit comments

Comments
 (0)