diff --git a/README.md b/README.md index 5119f8d..95ae323 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ async def run(): print(f"Executing dispatch {dispatch.id}, due on {dispatch.start_time}") if actor.is_running: actor.reconfigure( - components=dispatch.selector, + components=dispatch.target, run_parameters=dispatch.payload, # custom actor parameters dry_run=dispatch.dry_run, until=dispatch.until, @@ -56,7 +56,7 @@ async def run(): # this will start a new actor with the given components # and run it for the duration of the dispatch actor.start( - components=dispatch.selector, + components=dispatch.target, run_parameters=dispatch.payload, # custom actor parameters dry_run=dispatch.dry_run, until=dispatch.until, diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 7c48eae..0174777 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -2,7 +2,11 @@ ## Summary - +* Updates lots of dependencies and through those gets a few new features: + * `start_immediately` when creating dispatches is now supported. + * `http2 keepalive` is now supported and enabled by default. + * Some bugfixes from the channels & sdk libraries. are now included. + ## Upgrading diff --git a/pyproject.toml b/pyproject.toml index ed64384..ce40613 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,9 +39,9 @@ dependencies = [ # Make sure to update the version for cross-referencing also in the # mkdocs.yml file when changing the version here (look for the config key # plugins.mkdocstrings.handlers.python.import) - "frequenz-sdk >= 1.0.0-rc900, < 1.0.0-rc1100", - "frequenz-channels >= 1.2.0, < 2.0.0", - "frequenz-client-dispatch >= 0.7.1, < 0.8.0", + "frequenz-sdk >= 1.0.0-rc1300, < 1.0.0-rc1400", + "frequenz-channels >= 1.3.0, < 2.0.0", + "frequenz-client-dispatch >= 0.8.1, < 0.9.0", ] dynamic = ["version"] diff --git a/src/frequenz/dispatch/_dispatch.py b/src/frequenz/dispatch/_dispatch.py index 6f5074f..e28bc7e 100644 --- a/src/frequenz/dispatch/_dispatch.py +++ b/src/frequenz/dispatch/_dispatch.py @@ -11,8 +11,8 @@ from typing import Iterator, cast from dateutil import rrule +from frequenz.client.dispatch.recurrence import Frequency, Weekday from frequenz.client.dispatch.types import Dispatch as BaseDispatch -from frequenz.client.dispatch.types import Frequency, Weekday _logger = logging.getLogger(__name__) """The logger for this module.""" diff --git a/src/frequenz/dispatch/_dispatcher.py b/src/frequenz/dispatch/_dispatcher.py index 69fac4b..01b327d 100644 --- a/src/frequenz/dispatch/_dispatcher.py +++ b/src/frequenz/dispatch/_dispatcher.py @@ -80,7 +80,7 @@ async def run(): print(f"Executing dispatch {dispatch.id}, due on {dispatch.start_time}") if actor.is_running: actor.reconfigure( - components=dispatch.selector, + components=dispatch.target, run_parameters=dispatch.payload, # custom actor parameters dry_run=dispatch.dry_run, until=dispatch.until, @@ -89,7 +89,7 @@ async def run(): # this will start a new actor with the given components # and run it for the duration of the dispatch actor.start( - components=dispatch.selector, + components=dispatch.target, run_parameters=dispatch.payload, # custom actor parameters dry_run=dispatch.dry_run, until=dispatch.until, @@ -164,7 +164,7 @@ async def run(): type="ECHO_FREQUENCY", # replace with your own type start_time=datetime.now(tz=timezone.utc) + timedelta(minutes=10), duration=timedelta(minutes=5), - selector=ComponentCategory.INVERTER, + target=ComponentCategory.INVERTER, payload={"font": "Times New Roman"}, # Arbitrary payload data ) diff --git a/src/frequenz/dispatch/_managing_actor.py b/src/frequenz/dispatch/_managing_actor.py index e9a631b..5538e95 100644 --- a/src/frequenz/dispatch/_managing_actor.py +++ b/src/frequenz/dispatch/_managing_actor.py @@ -8,7 +8,7 @@ from typing import Any, Set from frequenz.channels import Receiver, Sender -from frequenz.client.dispatch.types import ComponentSelector +from frequenz.client.dispatch.types import TargetComponents from frequenz.sdk.actor import Actor from ._dispatch import Dispatch, RunningState @@ -20,7 +20,7 @@ class DispatchUpdate: """Event emitted when the dispatch changes.""" - components: ComponentSelector + components: TargetComponents """Components to be used.""" dry_run: bool @@ -39,7 +39,7 @@ class DispatchManagingActor(Actor): import os import asyncio from frequenz.dispatch import Dispatcher, DispatchManagingActor, DispatchUpdate - from frequenz.client.dispatch.types import ComponentSelector + from frequenz.client.dispatch.types import TargetComponents from frequenz.client.common.microgrid.components import ComponentCategory from frequenz.channels import Receiver, Broadcast @@ -60,7 +60,7 @@ async def _run(self) -> None: self._dry_run = update.dry_run self._options = update.options - def set_components(self, components: ComponentSelector) -> None: + def set_components(self, components: TargetComponents) -> None: match components: case [int(), *_] as component_ids: print("Dispatch: Setting components to %s", components) @@ -68,7 +68,7 @@ def set_components(self, components: ComponentSelector) -> None: print("Dispatch: Using all battery components") case unsupported: print( - "Dispatch: Requested an unsupported selector %r, " + "Dispatch: Requested an unsupported target component %r, " "but only component IDs or category BATTERY are supported.", unsupported, ) @@ -166,7 +166,7 @@ async def _handle_dispatch(self, dispatch: Dispatch) -> None: _logger.info("Updated by dispatch %s", dispatch.id) await self._updates_sender.send( DispatchUpdate( - components=dispatch.selector, + components=dispatch.target, dry_run=dispatch.dry_run, options=dispatch.payload, ) diff --git a/src/frequenz/dispatch/actor.py b/src/frequenz/dispatch/actor.py index 3330991..2f58845 100644 --- a/src/frequenz/dispatch/actor.py +++ b/src/frequenz/dispatch/actor.py @@ -338,7 +338,7 @@ def _update_changed_running_state( runtime_state_attributes = [ "running", "type", - "selector", + "target", "duration", "dry_run", "payload", diff --git a/tests/test_frequenz_dispatch.py b/tests/test_frequenz_dispatch.py index 303974e..9771210 100644 --- a/tests/test_frequenz_dispatch.py +++ b/tests/test_frequenz_dispatch.py @@ -1,5 +1,5 @@ # License: MIT -# Copyright © 2024 Frequenz Energy-as-a-Service GmbH +# Copyright © 2024 Frequenz Energy-as-a-Service GmbH """Tests for the frequenz.dispatch.actor package.""" @@ -12,10 +12,10 @@ import async_solipsism import time_machine from frequenz.channels import Broadcast, Receiver +from frequenz.client.dispatch.recurrence import Frequency, RecurrenceRule from frequenz.client.dispatch.test.client import FakeClient, to_create_params from frequenz.client.dispatch.test.generator import DispatchGenerator from frequenz.client.dispatch.types import Dispatch as BaseDispatch -from frequenz.client.dispatch.types import Frequency, RecurrenceRule from pytest import fixture from frequenz.dispatch import ( @@ -196,6 +196,8 @@ async def test_existing_dispatch_updated( running_state_change_synced=dispatch.running_state_change_synced, ) + await asyncio.sleep(1) + async def test_existing_dispatch_deleted( actor_env: ActorTestEnv, diff --git a/tests/test_mananging_actor.py b/tests/test_mananging_actor.py index 2ffe48e..027b057 100644 --- a/tests/test_mananging_actor.py +++ b/tests/test_mananging_actor.py @@ -12,8 +12,8 @@ import async_solipsism import time_machine from frequenz.channels import Broadcast, Receiver, Sender +from frequenz.client.dispatch.recurrence import Frequency from frequenz.client.dispatch.test.generator import DispatchGenerator -from frequenz.client.dispatch.types import Frequency from frequenz.sdk.actor import Actor from pytest import fixture @@ -116,7 +116,7 @@ async def test_simple_start_stop( event = await test_env.updates_receiver.receive() assert event.options == {"test": True} - assert event.components == dispatch.selector + assert event.components == dispatch.target assert event.dry_run is False 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) - event = await test_env.updates_receiver.receive() assert event.dry_run is dispatch.dry_run - assert event.components == dispatch.selector + assert event.components == dispatch.target assert event.options == dispatch.payload assert test_env.actor.is_running is True