Skip to content

feat!: Modernize actor architecture and rework dependent components#778

Merged
gfieni merged 36 commits intomasterfrom
refactor/actor-picklable-args
Mar 9, 2026
Merged

feat!: Modernize actor architecture and rework dependent components#778
gfieni merged 36 commits intomasterfrom
refactor/actor-picklable-args

Conversation

@gfieni
Copy link
Contributor

@gfieni gfieni commented Mar 9, 2026

This PR is a broad rework of the actor module to support multiprocessing spawn/forkserver methods that requires attributes of classes to be serializable with pickle.

Detailed changes :

  • Reworked actor communication around an ActorProxy abstraction
  • Moved actor state initialization and cleanup into the setup method
  • Added the teardown lifecycle hook to handle cleanup of the actor resources
  • Reworked actor supervisors
  • Simplified and standardized handler wiring/cleanup in dispatcher, processor, puller, and pusher actors
  • Reworked report filtering and puller flow, including dispatcher replacement support in filters
  • Updated CLI binding manager and generator with the new actors APIs
  • Reworked and expanded unit tests (actors handlers are now directly tested)
  • Moved MongoClient initialization to the connect method of the driver (unpickable lock objects)
  • General improvement of docstrings and type hints, dead code removal

Breaking Changes:

  • Actor communication methods are now accessed through the proxy abstraction, and several actor internals/lifecycle expectations changed accordingly.

gfieni added 30 commits March 9, 2026 13:46
Move the actors to actor communications methods into a proxy class.
This allow to pass a proxy object instead of the actor object, thus
preventing the pickle errors when serializing.
Instead of using a class attribute as timeout parameter, add a timeout
argument to the `receive()` method.
- Rename the `SilentFakeDB` to `LocalQueueDatabase`.
- Add the `FailingLocalQueueDatabase` with configurable failure modes.
- General cleanup of the code and docstrings.
- General code cleanup and performance improvements
- Add `ReportFilter` interface
- Add `BroadcastReportFilter` to send message to all dispatchers
- Add `RulesetReportFilter` to filter reports based on rules
- General code cleanup
- Move dispatchers connection handling to poller thread
- Improve start/stop reliability for the poller thread
- Rework unit tests
Tests the handlers directly instead of passing through the actor.
Tests the components directly instead of passing through the actor.
gfieni added 4 commits March 9, 2026 13:46
- Derive pre-processor puller targets from config instead of actor state
- Simplify dispatcher replacement using new report filter API
- Update pre-processor factories to new actor/config signatures
- Remove unused post-processor generator/binding code
- Align unit tests with new binding and actor APIs
Instead of creating the MongoDB client from the `__init__` of the
database driver, the client will be created in the `connect` method.
This prevents unpickable attributes to block the initialization of the
actors on Linux platforms.
@gfieni gfieni self-assigned this Mar 9, 2026
@gfieni gfieni added the enhancement New feature or request label Mar 9, 2026
@gfieni gfieni requested a review from a team as a code owner March 9, 2026 13:09
@codecov
Copy link

codecov bot commented Mar 9, 2026

Codecov Report

❌ Patch coverage is 72.99107% with 121 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.88%. Comparing base (8372e06) to head (c057670).
⚠️ Report is 144 commits behind head on master.

Files with missing lines Patch % Lines
.../powerapi/backend_supervisor/backend_supervisor.py 0.00% 41 Missing ⚠️
src/powerapi/actor/actor.py 67.69% 21 Missing ⚠️
src/powerapi/formula/formula_actor.py 0.00% 19 Missing ⚠️
src/powerapi/puller/database_poller.py 38.88% 11 Missing ⚠️
src/powerapi/cli/generator.py 70.00% 6 Missing ⚠️
src/powerapi/processor/pre/k8s/handlers.py 25.00% 6 Missing ⚠️
src/powerapi/database/mongodb/driver.py 42.85% 4 Missing ⚠️
src/powerapi/dispatcher/dispatcher_actor.py 88.88% 3 Missing ⚠️
src/powerapi/processor/pre/openstack/handlers.py 0.00% 3 Missing ⚠️
src/powerapi/processor/pre/openstack/actor.py 71.42% 2 Missing ⚠️
... and 5 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #778      +/-   ##
==========================================
+ Coverage   67.16%   69.88%   +2.72%     
==========================================
  Files          91       91              
  Lines        2945     2919      -26     
==========================================
+ Hits         1978     2040      +62     
+ Misses        967      879      -88     
Files with missing lines Coverage Δ
src/powerapi/actor/__init__.py 100.00% <100.00%> (ø)
src/powerapi/actor/socket_interface.py 100.00% <100.00%> (+3.40%) ⬆️
src/powerapi/actor/state.py 100.00% <100.00%> (+23.80%) ⬆️
src/powerapi/actor/supervisor.py 100.00% <100.00%> (+34.04%) ⬆️
src/powerapi/cli/binding_manager.py 97.91% <100.00%> (+25.31%) ⬆️
src/powerapi/dispatcher/__init__.py 100.00% <100.00%> (ø)
src/powerapi/dispatcher/handlers.py 100.00% <100.00%> (+50.00%) ⬆️
src/powerapi/dispatcher/route_table.py 100.00% <100.00%> (+8.33%) ⬆️
src/powerapi/filter/__init__.py 100.00% <100.00%> (ø)
src/powerapi/filter/filter.py 100.00% <100.00%> (+46.66%) ⬆️
... and 20 more

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 9, 2026

@gfieni gfieni merged commit 897a8fd into master Mar 9, 2026
11 checks passed
@gfieni gfieni deleted the refactor/actor-picklable-args branch March 9, 2026 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant