models icon indicating copy to clipboard operation
models copied to clipboard

[Orbit] Add PeriodicAction utility

Open LINYV0719 opened this issue 1 month ago • 0 comments

Description

This PR adds a new utility class PeriodicAction to orbit/actions.

Motivation: Currently, actions in Orbit are typically executed every time the Controller loop completes (steps_per_loop). Users often need to execute certain actions at a different, less frequent interval without changing the steps_per_loop setting which might affect preemption granularity

Changes:

  • Added PeriodicAction class which wraps any callable Action
  • It checks global_step % interval == 0 to decide whether to execute the wrapped action
  • Added orbit/actions/periodic_action_test.py to verify the execution

actions/init Changes:

  • Exported PeriodicAction in orbit/actions/__init__.py for easier access

Type of change

  • [x] New feature

Tests

I added a new test suite orbit.actions.periodic_action_test to verify the logic.

Test Configuration:

  • OS: Windows 11
  • Python Version: 3.10
  • Command: python -m orbit.actions.periodic_action_test
  • Result: Passed (OK). Verified that the action is triggered exactly when global_step matches the interval.

Checklist

  • [x] I have signed the Contributor License Agreement.
  • [x] I have read guidelines for pull request.
  • [x] My code follows the coding guidelines.
  • [x] I have performed a self code review of my own code.
  • [x] I have commented my code, particularly in hard-to-understand areas.
  • [x] I have made corresponding changes to the documentation.
  • [x] My changes generate no new warnings.
  • [x] I have added tests that prove my fix is effective or that my feature works.

LINYV0719 avatar Dec 30 '25 16:12 LINYV0719