Skip to content

Commit 12a3368

Browse files
authored
2 parents 023e50c + 6b45e92 commit 12a3368

9 files changed

+28
-22
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ async def run():
4747
print(f"Executing dispatch {dispatch.id}, due on {dispatch.start_time}")
4848
if actor.is_running:
4949
actor.reconfigure(
50-
components=dispatch.selector,
50+
components=dispatch.target,
5151
run_parameters=dispatch.payload, # custom actor parameters
5252
dry_run=dispatch.dry_run,
5353
until=dispatch.until,
@@ -56,7 +56,7 @@ async def run():
5656
# this will start a new actor with the given components
5757
# and run it for the duration of the dispatch
5858
actor.start(
59-
components=dispatch.selector,
59+
components=dispatch.target,
6060
run_parameters=dispatch.payload, # custom actor parameters
6161
dry_run=dispatch.dry_run,
6262
until=dispatch.until,

RELEASE_NOTES.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
## Summary
44

5-
<!-- Here goes a general summary of what this release is about -->
5+
* Updates lots of dependencies and through those gets a few new features:
6+
* `start_immediately` when creating dispatches is now supported.
7+
* `http2 keepalive` is now supported and enabled by default.
8+
* Some bugfixes from the channels & sdk libraries. are now included.
9+
610

711
## Upgrading
812

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ dependencies = [
3939
# Make sure to update the version for cross-referencing also in the
4040
# mkdocs.yml file when changing the version here (look for the config key
4141
# plugins.mkdocstrings.handlers.python.import)
42-
"frequenz-sdk >= 1.0.0-rc900, < 1.0.0-rc1100",
43-
"frequenz-channels >= 1.2.0, < 2.0.0",
44-
"frequenz-client-dispatch >= 0.7.1, < 0.8.0",
42+
"frequenz-sdk >= 1.0.0-rc1300, < 1.0.0-rc1400",
43+
"frequenz-channels >= 1.3.0, < 2.0.0",
44+
"frequenz-client-dispatch >= 0.8.1, < 0.9.0",
4545
]
4646
dynamic = ["version"]
4747

src/frequenz/dispatch/_dispatch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
from typing import Iterator, cast
1212

1313
from dateutil import rrule
14+
from frequenz.client.dispatch.recurrence import Frequency, Weekday
1415
from frequenz.client.dispatch.types import Dispatch as BaseDispatch
15-
from frequenz.client.dispatch.types import Frequency, Weekday
1616

1717
_logger = logging.getLogger(__name__)
1818
"""The logger for this module."""

src/frequenz/dispatch/_dispatcher.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ async def run():
8080
print(f"Executing dispatch {dispatch.id}, due on {dispatch.start_time}")
8181
if actor.is_running:
8282
actor.reconfigure(
83-
components=dispatch.selector,
83+
components=dispatch.target,
8484
run_parameters=dispatch.payload, # custom actor parameters
8585
dry_run=dispatch.dry_run,
8686
until=dispatch.until,
@@ -89,7 +89,7 @@ async def run():
8989
# this will start a new actor with the given components
9090
# and run it for the duration of the dispatch
9191
actor.start(
92-
components=dispatch.selector,
92+
components=dispatch.target,
9393
run_parameters=dispatch.payload, # custom actor parameters
9494
dry_run=dispatch.dry_run,
9595
until=dispatch.until,
@@ -164,7 +164,7 @@ async def run():
164164
type="ECHO_FREQUENCY", # replace with your own type
165165
start_time=datetime.now(tz=timezone.utc) + timedelta(minutes=10),
166166
duration=timedelta(minutes=5),
167-
selector=ComponentCategory.INVERTER,
167+
target=ComponentCategory.INVERTER,
168168
payload={"font": "Times New Roman"}, # Arbitrary payload data
169169
)
170170

src/frequenz/dispatch/_managing_actor.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from typing import Any, Set
99

1010
from frequenz.channels import Receiver, Sender
11-
from frequenz.client.dispatch.types import ComponentSelector
11+
from frequenz.client.dispatch.types import TargetComponents
1212
from frequenz.sdk.actor import Actor
1313

1414
from ._dispatch import Dispatch, RunningState
@@ -20,7 +20,7 @@
2020
class DispatchUpdate:
2121
"""Event emitted when the dispatch changes."""
2222

23-
components: ComponentSelector
23+
components: TargetComponents
2424
"""Components to be used."""
2525

2626
dry_run: bool
@@ -39,7 +39,7 @@ class DispatchManagingActor(Actor):
3939
import os
4040
import asyncio
4141
from frequenz.dispatch import Dispatcher, DispatchManagingActor, DispatchUpdate
42-
from frequenz.client.dispatch.types import ComponentSelector
42+
from frequenz.client.dispatch.types import TargetComponents
4343
from frequenz.client.common.microgrid.components import ComponentCategory
4444
4545
from frequenz.channels import Receiver, Broadcast
@@ -60,15 +60,15 @@ async def _run(self) -> None:
6060
self._dry_run = update.dry_run
6161
self._options = update.options
6262
63-
def set_components(self, components: ComponentSelector) -> None:
63+
def set_components(self, components: TargetComponents) -> None:
6464
match components:
6565
case [int(), *_] as component_ids:
6666
print("Dispatch: Setting components to %s", components)
6767
case [ComponentCategory.BATTERY, *_]:
6868
print("Dispatch: Using all battery components")
6969
case unsupported:
7070
print(
71-
"Dispatch: Requested an unsupported selector %r, "
71+
"Dispatch: Requested an unsupported target component %r, "
7272
"but only component IDs or category BATTERY are supported.",
7373
unsupported,
7474
)
@@ -166,7 +166,7 @@ async def _handle_dispatch(self, dispatch: Dispatch) -> None:
166166
_logger.info("Updated by dispatch %s", dispatch.id)
167167
await self._updates_sender.send(
168168
DispatchUpdate(
169-
components=dispatch.selector,
169+
components=dispatch.target,
170170
dry_run=dispatch.dry_run,
171171
options=dispatch.payload,
172172
)

src/frequenz/dispatch/actor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ def _update_changed_running_state(
338338
runtime_state_attributes = [
339339
"running",
340340
"type",
341-
"selector",
341+
"target",
342342
"duration",
343343
"dry_run",
344344
"payload",

tests/test_frequenz_dispatch.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# License: MIT
2-
# Copyright © 2024 Frequenz Energy-as-a-Service GmbH
2+
# Copyright © 2024 Frequenz Energy-as-a-Service GmbH
33

44
"""Tests for the frequenz.dispatch.actor package."""
55

@@ -12,10 +12,10 @@
1212
import async_solipsism
1313
import time_machine
1414
from frequenz.channels import Broadcast, Receiver
15+
from frequenz.client.dispatch.recurrence import Frequency, RecurrenceRule
1516
from frequenz.client.dispatch.test.client import FakeClient, to_create_params
1617
from frequenz.client.dispatch.test.generator import DispatchGenerator
1718
from frequenz.client.dispatch.types import Dispatch as BaseDispatch
18-
from frequenz.client.dispatch.types import Frequency, RecurrenceRule
1919
from pytest import fixture
2020

2121
from frequenz.dispatch import (
@@ -196,6 +196,8 @@ async def test_existing_dispatch_updated(
196196
running_state_change_synced=dispatch.running_state_change_synced,
197197
)
198198

199+
await asyncio.sleep(1)
200+
199201

200202
async def test_existing_dispatch_deleted(
201203
actor_env: ActorTestEnv,

tests/test_mananging_actor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
import async_solipsism
1313
import time_machine
1414
from frequenz.channels import Broadcast, Receiver, Sender
15+
from frequenz.client.dispatch.recurrence import Frequency
1516
from frequenz.client.dispatch.test.generator import DispatchGenerator
16-
from frequenz.client.dispatch.types import Frequency
1717
from frequenz.sdk.actor import Actor
1818
from pytest import fixture
1919

@@ -116,7 +116,7 @@ async def test_simple_start_stop(
116116

117117
event = await test_env.updates_receiver.receive()
118118
assert event.options == {"test": True}
119-
assert event.components == dispatch.selector
119+
assert event.components == dispatch.target
120120
assert event.dry_run is False
121121

122122
assert test_env.actor.is_running is True
@@ -173,7 +173,7 @@ async def test_dry_run(test_env: TestEnv, fake_time: time_machine.Coordinates) -
173173
event = await test_env.updates_receiver.receive()
174174

175175
assert event.dry_run is dispatch.dry_run
176-
assert event.components == dispatch.selector
176+
assert event.components == dispatch.target
177177
assert event.options == dispatch.payload
178178
assert test_env.actor.is_running is True
179179

0 commit comments

Comments
 (0)