Skip to content

refactor(actor)!: Move lifecycle handling into state hooks - #938

Merged
gfieni merged 1 commit into
masterfrom
refactor/actor-state-lifecycle
Sep 25, 2026
Merged

gfieni merged 1 commit into
masterfrom
refactor/actor-state-lifecycle

Conversation

@gfieni

@gfieni gfieni commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

PR overview:

  • Add initialize() and teardown() lifecycle hooks to actor states.
  • Move actor-specific initialization and cleanup logic into state implementations.
  • Consolidate message handlers under powerapi.actor package.
  • Make handlers generic by message type and move message dispatching into State.
  • Make actor state non-optional.
  • Add FormulaActor.create_state() so formula implementations can provide specialized states.
  • Replace specialized lifecycle handlers with generic start and poison-pill handlers.

BREAKING CHANGES:

  • Remove the powerapi.handler package.
  • Remove actor-specific start and poison-pill handlers.
  • Rename InitHandler to InitializedStateHandler.
  • Require actor-specific lifecycle behavior to be implemented through State.initialize() and State.teardown().
  • Formula implementations should override create_state() and call super().setup() instead of creating state or registering lifecycle handlers themselves.

Add initialize and teardown hooks to actor states.
Consolidate message-generic handlers under `powerapi.actor` package.
Move message dispatching into State and make actor state non-optional.
Add `FormulaActor.create_state()` for specialized formula states.

BREAKING CHANGE: powerapi.handler and specialized lifecycle handlers
have been removed. Handlers must be imported from powerapi.actor, and
actor-specific lifecycle must be implemented through `State` hooks.
@gfieni gfieni self-assigned this Sep 25, 2026
@gfieni
gfieni requested a review from a team as a code owner September 25, 2026 16:44
@sonarqubecloud

Copy link
Copy Markdown

Comment thread src/powerapi/actor/handler.py Dismissed
Comment thread src/powerapi/actor/state.py Dismissed
Comment thread src/powerapi/processor/handlers.py Dismissed
@codecov

codecov Bot commented Sep 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.80892% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.28%. Comparing base (9f45e7a) to head (ec95119).

Files with missing lines Patch % Lines
src/powerapi/actor/handler.py 83.33% 5 Missing ⚠️
src/powerapi/actor/state.py 76.92% 3 Missing ⚠️
src/powerapi/actor/actor.py 50.00% 2 Missing ⚠️
src/powerapi/dispatcher/dispatcher_actor.py 80.00% 2 Missing ⚠️
src/powerapi/puller/puller_actor.py 88.88% 2 Missing ⚠️
src/powerapi/pusher/pusher_actor.py 93.33% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #938      +/-   ##
==========================================
+ Coverage   82.93%   84.28%   +1.35%     
==========================================
  Files          86       81       -5     
  Lines        2854     2826      -28     
==========================================
+ Hits         2367     2382      +15     
+ Misses        487      444      -43     
Files with missing lines Coverage Δ
src/powerapi/actor/__init__.py 100.00% <100.00%> (ø)
src/powerapi/dispatcher/handlers.py 100.00% <100.00%> (ø)
src/powerapi/formula/__init__.py 100.00% <ø> (+100.00%) ⬆️
src/powerapi/formula/formula_actor.py 100.00% <100.00%> (+100.00%) ⬆️
src/powerapi/processor/handlers.py 66.66% <100.00%> (ø)
src/powerapi/processor/pre/k8s/actor.py 100.00% <100.00%> (ø)
src/powerapi/processor/pre/k8s/handlers.py 100.00% <100.00%> (ø)
src/powerapi/processor/pre/openstack/actor.py 100.00% <100.00%> (ø)
src/powerapi/processor/pre/openstack/handlers.py 100.00% <100.00%> (ø)
src/powerapi/pusher/handlers.py 100.00% <100.00%> (ø)
... and 6 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gfieni
gfieni merged commit b017d46 into master Sep 25, 2026
10 checks passed
@gfieni
gfieni deleted the refactor/actor-state-lifecycle branch September 25, 2026 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants