Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dispatch Managing Actor #54

Merged
merged 11 commits into from
Sep 30, 2024
Merged

Dispatch Managing Actor #54

merged 11 commits into from
Sep 30, 2024

Conversation

Marenz
Copy link
Contributor

@Marenz Marenz commented Sep 11, 2024

  • Reset release notes
  • Add dispatch runner

@Marenz Marenz requested a review from a team as a code owner September 11, 2024 15:30
@github-actions github-actions bot added part:docs Affects the documentation part:dispatcher Affects the high-level dispatcher interface labels Sep 11, 2024
@github-actions github-actions bot added part:tests Affects the unit, integration and performance (benchmarks) tests part:actor Affects the dispatching actor labels Sep 11, 2024
Copy link
Contributor

@daniel-zullo-frequenz daniel-zullo-frequenz 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 really minor comments to check for, LGTM otherwise

tests/test_runner.py Outdated Show resolved Hide resolved
tests/test_runner.py Outdated Show resolved Hide resolved
src/frequenz/dispatch/_actor_runner.py Outdated Show resolved Hide resolved
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.

I would say all comments are mostly bike shedding, but in particular I think not using configuration and use dispatch update is important, I think it can get a bit confusing for people dealing with dispatches and configuration (as in config manager) too. I really think we should replace all `configuration mentions to update/dispatch update.

Also I found the example a bit confusing, which ideally it shouldn't be the case, the example should help make things less confusing :P

src/frequenz/dispatch/_actor_runner.py Outdated Show resolved Hide resolved
src/frequenz/dispatch/_actor_runner.py Outdated Show resolved Hide resolved
src/frequenz/dispatch/_actor_runner.py Outdated Show resolved Hide resolved
src/frequenz/dispatch/_actor_runner.py Outdated Show resolved Hide resolved
src/frequenz/dispatch/_actor_runner.py Outdated Show resolved Hide resolved
src/frequenz/dispatch/_actor_runner.py Outdated Show resolved Hide resolved
src/frequenz/dispatch/_actor_runner.py Outdated Show resolved Hide resolved
match running:
case RunningState.STOPPED:
_logger.info("Stopping dispatch...")
await self._stop_actors("Dispatch stopped")
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe "Stopped by a dispatch".

src/frequenz/dispatch/_actor_runner.py Outdated Show resolved Hide resolved
@Marenz
Copy link
Contributor Author

Marenz commented Sep 13, 2024

I don't like update much in this context either though. How about DispatchParameterUpdate

@llucax
Copy link
Contributor

llucax commented Sep 13, 2024

I don't like update much in this context either though. How about DispatchParameterUpdate

Why don't you like update? Adding Parameter doesn't make it better IMHO, there is no concept of a dispatch parameter in the API. Another option would be change instead of update, but for me update sounds more accurate in this context, this is why I wonder what you don't like about update.

@github-actions github-actions bot added the part:tooling Affects the development tooling (CI, deployment, dependency management, etc.) label Sep 16, 2024
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.

I see there was not much progress or replies on my comments. I guess you are focusing on getting shit to work, which sounds totally reasonable, but just saying that I didn't review much in this round.

RELEASE_NOTES.md Outdated Show resolved Hide resolved
@Marenz Marenz force-pushed the runner branch 3 times, most recently from 1509e1b to ba6bd9f Compare September 23, 2024 15:42
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.

Very nice to see the new scheduling algorithm! 🎉 Way better than what we had before.

Lots of comments, so here is a summary:

Things I think needs to be addressed before merging:

  1. These commits need a commit message with a body that describes what's going on, it is really hard to review them without more information of what was wrong and how it was fixed:

    • Fix wrong running behaviors with duration=None
    • Rewrite internal architecture to be more flexible
    • Add dispatch runner (less important but it would be nice, is not a trivial class)
  2. Finish the renaming of config -> update

  3. The hack in the tests (session-wide event_loop fixture), we can't really merge this if something is so fucked up that makes tests hang or make the interpreter segfault 😬

  4. Figure out if we really need to support multiple actors, it is still make noise in my head, my feeling is we should encourage having one actor to handle one dispatch type, if that actor needs other supporting actors, it should be the actor itself in charge of spawning them.

  5. If we are doing more renaming (like DispatchManagingActor and payload -> options), it might be good to do them now too to avoid having breaking changes in the future.

The rest is minor or too big for this PR, so I will create follow-up issues.

src/frequenz/dispatch/_actor_runner.py Outdated Show resolved Hide resolved
dry_run: bool
"""Whether this is a dry run."""

payload: dict[str, Any]
Copy link
Contributor

Choose a reason for hiding this comment

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

bikeshedding: Payload sounds weird to me. For a whole dispatch it makes sense (or at least it was the best we could find) but in this context maybe something like options is more intuitive? To be honest I think options might be a good choice for the specs too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

how about inputs?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that could work too, I think we discussed options at some point but wasn't perfectly accurate as some "options" might not be optional. I guess inputs is an improvement in that sense. Maybe parameters could work too.

src/frequenz/dispatch/_actor_runner.py Outdated Show resolved Hide resolved
src/frequenz/dispatch/_actor_runner.py Outdated Show resolved Hide resolved
src/frequenz/dispatch/_actor_runner.py Outdated Show resolved Hide resolved
src/frequenz/dispatch/_actor_runner.py Outdated Show resolved Hide resolved
src/frequenz/dispatch/_actor_runner.py Outdated Show resolved Hide resolved
src/frequenz/dispatch/_dispatch.py Show resolved Hide resolved
src/frequenz/dispatch/actor.py Show resolved Hide resolved
tests/test_frequenz_dispatch.py Outdated Show resolved Hide resolved
@Marenz
Copy link
Contributor Author

Marenz commented Sep 24, 2024

And I still think "update" sucks and "configuration" was better. "Update" doesn't fit at all in the whole naming scheme

@Marenz
Copy link
Contributor Author

Marenz commented Sep 24, 2024

Addressed points 1 - 5

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.

A few more instances of config and we need support for multiple actors for now (temporarily). I will also create issues for the stuff we can address in the future.

src/frequenz/dispatch/_managing_actor.py Outdated Show resolved Hide resolved
src/frequenz/dispatch/_actor_runner.py Outdated Show resolved Hide resolved
src/frequenz/dispatch/_actor_runner.py Outdated Show resolved Hide resolved
dry_run: bool
"""Whether this is a dry run."""

payload: dict[str, Any]
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that could work too, I think we discussed options at some point but wasn't perfectly accurate as some "options" might not be optional. I guess inputs is an improvement in that sense. Maybe parameters could work too.

src/frequenz/dispatch/_managing_actor.py Outdated Show resolved Hide resolved
tests/test_mananging_actor.py Outdated Show resolved Hide resolved
tests/test_mananging_actor.py Outdated Show resolved Hide resolved
tests/test_mananging_actor.py Outdated Show resolved Hide resolved
tests/test_mananging_actor.py Outdated Show resolved Hide resolved
tests/test_mananging_actor.py Outdated Show resolved Hide resolved
@Marenz
Copy link
Contributor Author

Marenz commented Sep 24, 2024

  • Added multiple actors back
  • fixed confi -> up stuff

@Marenz Marenz changed the title Dispatch Actor Runner Actor Dispatch Managing Actor Sep 24, 2024
@Marenz Marenz force-pushed the runner branch 2 times, most recently from bc76d7e to 7003801 Compare September 24, 2024 16:14
llucax
llucax previously approved these changes Sep 30, 2024
@@ -165,6 +165,7 @@ disable = [
[tool.pytest.ini_options]
testpaths = ["tests", "src"]
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function"
Copy link
Contributor

Choose a reason for hiding this comment

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

* Dispatch.running() was always returning RUNNING for duration None
* Dispatch.next_run_after() was made aware that there is no next run for
  inf. Duration
* Dispatch._until() now raises when used with Dispatch.None
* Actor: delay marking a Dispatch as deleted, otherwise checks wrongly
  detect it as no longer running.

Signed-off-by: Mathias L. Baumann <[email protected]>
The internal scheduling architecture was rewritten:

Instead of using one task per dispatch that will start/stop them,
we now have a queue of events and a timer that is rescheduled
to the earliest next event each time it triggers.

Previously we had to do complicated re-scheduling and cancelling of
tasks, now we always just update the event in the queue.

Signed-off-by: Mathias L. Baumann <[email protected]>
A useful actor to help control and manange another actor using
dispatches.

Signed-off-by: Mathias L. Baumann <[email protected]>
As recommended by the deprecation warning

Signed-off-by: Mathias L. Baumann <[email protected]>
@Marenz Marenz added this pull request to the merge queue Sep 30, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 30, 2024
@Marenz Marenz added this pull request to the merge queue Sep 30, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 30, 2024
@Marenz Marenz added this pull request to the merge queue Sep 30, 2024
Merged via the queue into frequenz-floss:v0.x.x with commit 2606895 Sep 30, 2024
14 checks passed
@Marenz Marenz deleted the runner branch September 30, 2024 14:13
@llucax
Copy link
Contributor

llucax commented Oct 1, 2024

It looks like now cross-arch tests are consistently failing. This must be definitely a timing issue, the slowest the system is, the more likely we hit this bug and tests hang. Created an issue about it:

@llucax llucax mentioned this pull request Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
part:actor Affects the dispatching actor 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