models
models copied to clipboard
[Orbit] Add PeriodicAction utility
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
PeriodicActionclass which wraps any callableAction - It checks
global_step % interval == 0to decide whether to execute the wrapped action - Added
orbit/actions/periodic_action_test.pyto verify the execution
actions/init Changes:
- Exported
PeriodicActioninorbit/actions/__init__.pyfor 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_stepmatches 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.