ModusaPlugin¶
- class modusa.plugins.base.ModusaPlugin[source]¶
Bases:
ABC
Base class for any Plugin that follows the modusa framework.
- abstract property allowed_input_signal_types: tuple[type, ...]¶
Define the expected signal types for this plugin.
Note
Must be implemented by every ModusaPlugin subclass.
Clearly states what signal types are accepted in .apply().
Return a tuple of accepted signal classes.
Examples
# Single type from modusa.signals import Signal1D return (Signal1D, ) # Multiple types from modusa.signals import Signal1D, Signal2D return (Signal1D, Signal2D)
- abstract property allowed_output_signal_types: tuple[type, ...]¶
Defines the allowed return types from the .apply() method.
Note
Must be implemented by every ModusaPlugin subclass.
Clearly declares what return types are valid.
Return a tuple of accepted types (usually signal classes).
Examples
# Single type allowed from modusa.signals import Signal1D return (Signal1D, ) # Multiple types allowed from modusa.signals import Signal1D, Signal2D return (Signal1D, Signal2D) # Return type can also be None (e.g., for plot-only plugins) from modusa.signals import Signal1D, Signal2D return (Signal1D, Signal2D, type(None))
- abstract apply(signal: Any) Any [source]¶
Defines the main processing logic of the plugin.
Note
Must be implemented by every ModusaPlugin subclass.
- It is highly advised to wrap it with @plugin_safety_check() to:
Validate input and output types.
Enforce plugin contracts for safe execution.
Warning
You should not make this method as classmethod or staticmethod, this will break plugin safety check.
Example
@plugin_safety_check() def apply(self, signal: "TimeDomainSignal") -> "TimeDomainSignal": from modusa.engines import SomeEngine new_signal: TimeDomainSignal = SomeEngine.run(signal) return new_signal