Skip to content

Commit

Permalink
Update dependencies (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marenz authored Nov 19, 2024
2 parents 023e50c + 6b45e92 commit 12a3368
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 22 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

## Summary

<!-- Here goes a general summary of what this release is about -->
* 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

Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
2 changes: 1 addition & 1 deletion src/frequenz/dispatch/_dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
6 changes: 3 additions & 3 deletions src/frequenz/dispatch/_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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
)
Expand Down
12 changes: 6 additions & 6 deletions src/frequenz/dispatch/_managing_actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,7 +20,7 @@
class DispatchUpdate:
"""Event emitted when the dispatch changes."""

components: ComponentSelector
components: TargetComponents
"""Components to be used."""

dry_run: bool
Expand All @@ -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
Expand All @@ -60,15 +60,15 @@ 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)
case [ComponentCategory.BATTERY, *_]:
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,
)
Expand Down Expand Up @@ -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,
)
Expand Down
2 changes: 1 addition & 1 deletion src/frequenz/dispatch/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def _update_changed_running_state(
runtime_state_attributes = [
"running",
"type",
"selector",
"target",
"duration",
"dry_run",
"payload",
Expand Down
6 changes: 4 additions & 2 deletions tests/test_frequenz_dispatch.py
Original file line number Diff line number Diff line change
@@ -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."""

Expand All @@ -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 (
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions tests/test_mananging_actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 12a3368

Please sign in to comment.