morpheus.utils.execution_chain.ExecutionChain#
- class ExecutionChain(function_chain=None)[source]#
Bases:
objectA class that represents a chain of functions to be executed sequentially.
- Attributes:
- functionsList[Callable]
List of functions to be executed in the chain.
Methods
__call__(**kwargs):
Executes all the functions in the chain.
add_function(function: Callable, position: int = -1):
Adds a function to the chain at a specified position.
remove_function(function: Callable):
Removes a specific function from the chain.
replace_function(old_function: Callable, new_function: Callable):
Replaces a specific function in the chain with a new one.
validate_chain():
Validates the function chain.
- add_function(function, position=-1)[source]#
Adds a function to the chain at a specified position. Default is end of the chain.
- Parameters:
- functionCallable
The function to add to the chain.
- positionint, optional
The position in the chain to add the function to, by default -1 which corresponds to the end of the chain.
- remove_function(function)[source]#
Removes a specific function from the chain.
- Parameters:
- functionCallable
The function to remove from the chain.