Action
Base action class
Module: core
Methods and properties
Main methods and properties
__init__
Arguments:
name (Optional[str], optional): Name for identification. If equals to None, class name will be used. Defaults to None.
default_key (str, optional): Default key used for results that is not of type Dict. Defaults to "output".
replace (ReplacingScope, optional): Replacing strategy. Defaults to ReplacingScope.INPLACE.
__call__
Component Call
Arguments:
input_data (Transformable): Data for processing
evaluator (Optional[Evaluator], optional): Evaluator in context of which component executed. If equals to None, default evaluator will be created. Defaults to None.
Raises:
ActionError: Raised if action was executed unsuccessfully
Returns:
Transformable: Result of executed component.
If result of Action.execute is None, will return input_data.
If result of Action.execute is not of type Dict, result will be seted to default_key (By default equals to "output").
execute
Main logic of action
Arguments:
input_data (ActionInput): Data for processing.
Returns:
ActionOutput: Result of execution.
use
Creates ActionExecutor which manages context
Arguments:
get_key (Optional[str], optional): Which key value of input_data will be used. If value equal to None, root dict will be used. Defaults to None.
set_key (Optional[str], optional): Which key will be used to set result value. If set_key value equal to None: - if result of type Dict[str, Any], update root dict; - else, set result to default_key. Defaults to None.
default_key (str, optional): Default key used for results that is not of type Dict. Defaults to "output".
replace (ReplacingScope, optional): Replacing strategy for executor. If equals to None, this action strategy will be used. Defaults to None.
Returns:
ActionExecutor: Wrapper of Action
ActionExecutor
Subclass of BaseExecutor. Wrapper of Action.
__call__
Component Call
Arguments:
input_data (Transformable): Data for processing
evaluator (Optional[Evaluator], optional): Evaluator in context of which component executed. If equals to None, default evaluator will be created. Defaults to None.
Raises:
ActionError: Raised if action was executed unsuccessfully
Returns:
Transformable: Result of executed component.
If result of Action.execute is None, will return input_data.
If result of Action.execute is not of type Dict and set_key is not specified, result will be seted to default_key (By default equals to "output").
Last updated