Skip to content

Conversation

@Marenz
Copy link
Contributor

@Marenz Marenz commented Jan 28, 2025

  • WIP: Support dipatches refering to different actors

developed together with https://github.com/frequenz-io/frequenz-app-edge/pull/59

@github-actions github-actions bot added part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:dispatcher Affects the high-level dispatcher interface labels Jan 28, 2025
@llucax llucax mentioned this pull request Jan 29, 2025
@Marenz Marenz marked this pull request as ready for review February 4, 2025 18:50
@Marenz Marenz requested a review from a team as a code owner February 4, 2025 18:50
@Marenz
Copy link
Contributor Author

Marenz commented Feb 4, 2025

@llucax ready for review

@Marenz Marenz requested a review from llucax February 10, 2025 10:31
Copy link
Contributor

@llucax llucax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few comments, LGTM in general, awesome to see this finally taking form!

I think it could also use some updates to the documentation, in particular getting started type of examples.

Fix broken MergeByTypeTarge.identity function

Pending: I still need to investigate why the existing tests didn't catch
this.

Is this pending for this PR? If not maybe create an issue?

Comment on lines +38 to +41
@fixture
def generator() -> DispatchGenerator:
"""Return a dispatch generator."""
return DispatchGenerator()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the future, we can register new fixtures to pytest automatically in the client by making it a pytest plugin, then client users could just magically use dispatch_generator as a fixture without creating one or importing it, like we can do with mocker and other fixtures.

Pending: I still need to investigate why the existing tests didn't catch
this.

Signed-off-by: Mathias L. Baumann <[email protected]>
@github-actions github-actions bot added the part:tooling Affects the development tooling (CI, deployment, dependency management, etc.) label Feb 10, 2025
llucax
llucax previously approved these changes Feb 11, 2025
Copy link
Contributor

@llucax llucax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if the new round was done because there was no new request for review but I had a look and for me only a documentation update is missing, but I'm also OK to leave that for a follow-up PR, so approving.

@Marenz
Copy link
Contributor Author

Marenz commented Feb 11, 2025

@llucax fixed release notes and added 2 further commits with features I found important after trying to integrate this interface in FCR & AFRR

llucax
llucax previously approved these changes Feb 12, 2025
Copy link
Contributor

@llucax llucax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be an awesome release! 🎉

Comment on lines +190 to +206
try:
_logger.info("Starting actor for dispatch type %r", dispatch.type)
actor = self._actor_factory(
dispatch_update,
self._updates_channel.new_receiver(limit=1, warn_on_overflow=False),
)
self._actors[self._dispatch_identity(dispatch)] = actor

actor.start()

except Exception as e: # pylint: disable=broad-except
_logger.error(
"Failed to start actor for dispatch type %r: %s",
dispatch.type,
e,
exc_info=True,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for this PR, as it is a separate feature that can be implemented separately, but I think it might be good to do the starting in a background task and retrying forever like the edge app "dispatch subsystem" does (maybe with the new dispatcher we can even get rid of the dispatch subsystem).

Not 100% sure, as doing this is making maybe too many assumptions about what clients want, but maybe it could also be opt-in/out by passing an option like in_background: bool, retries: int | INFINITE).

sent_str = ", sent a dispatch update instead of creating a new actor"
await self._updates_sender.send(dispatch_update)
_logger.warning(
_logger.info(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't get this change, the commit message says " Don't warn for changing dispatch parameters: It's a normal action ", does this mean that _start_actor is called every time a dispatch is updated? If so, I would even make this log a debug or remove it completely, because it seems misleading, as it was never the intention to start the actor if it was just a dispatch update.

If there is a way to tell if this is called because a dispatch just started or was updated, then maybe we can log more meaningful messages.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, there is a way, but it's not available to the actor_dispatcher (without restructuring).
The idea is that the dispatch instance tells us the desired state, no matter the previous state, so from that perspectives it doesn't matter whether it was an update or a new dispatch, both cases should do both, start or update a running actor instance..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would make this a debug then, because it is completely normal and probably not very useful to get that info when things are running. But not hung to block this PR on.

@Marenz Marenz added this pull request to the merge queue Feb 18, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 18, 2025
@Marenz Marenz merged commit c9c1181 into frequenz-floss:v0.x.x Feb 18, 2025
14 checks passed
@Marenz Marenz deleted the reediisee branch February 18, 2025 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:dispatcher Affects the high-level dispatcher interface part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:tooling Affects the development tooling (CI, deployment, dependency management, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants