Memory management
Memory, MemoryManager and memory components
Module: core
Memory
Manage data
__init__
Arguments:
directory (Optional[str], optional): Path to directory. Defaults to None.
initial_data (Optional[Dict[str, Any]], optional): Data for initialization of memory. Defaults to None.
add_store
Save state with the given identifier
Arguments:
identifier (str): Identifier that will be used.
state (Any): State that will be associated with provided identifier.
retrieve_store
Retrieve state by its identifier, either from memory or disk
Arguments:
identifier (str): Identifier that will be used.
Raises:
KeyError: If identiifier is invalid.
Returns:
Any: Data associated with identifier.
delete_store
Delete a state by its identifier from both memory and disk
Arguments:
identifier (str): Identifier to delete.
flush
Clean memory
MemorySetInstruction
Set memory instruction
SET
Set data to memory
MOVE
Set data to memory and remove it from current data
SetMemory
Subclass of Component
__init__
Arguments:
set_key (str): Destination key.
get_key (Optional[str], optional): Key that used to retrieve data from register. If equals to None, complete register will be added to memory. Defaults to None.
memory_instruction (MemorySetInstruction, optional): Strategy for memory setting. Defaults to MemorySetInstruction.SET.
__call__
Arguments:
input_data (Transformable): Current data.
evaluator (Optional[Evaluator], optional): Evaluator in context of which executed. If equals to None, default evaluator will be created. Defaults to None.
Raises:
InavalidMemoryInstruction: If provided instruction doesnt exists.
Returns:
Transformable: Result of execution.
MemoryGetInstruction
Get memory instruction
GET
Get data from memory
POP
Get data from memory and delete it from memory
GetMemory
Subclass of Component
__init__
Arguments:
identifiers (List[Union[str, Tuple[str, str]]]): Key/keys that will be used to access data in memory and for setting to register.
default (Dict[str, Any]): A map of values to be returned for each provided identifier if the identifier(s) are not found. If an identifier is not found and no default value is provided for it, an exception will be raised. Defaults to None.
memory_instruction (MemoryGetInstruction, optional): Strategy for memory access. Defaults to MemoryGetInstruction.GET.
__call__
Arguments:
input_data (Transformable): Current data.
evaluator (Optional[Evaluator], optional): Evaluator in context of which executed. If equals to None, default evaluator will be created. Defaults to None.
Raises:
InavalidMemoryInstruction: If provided instruction doesnt exists.
Returns:
Transformable: Result of execution.
DeleteMemory
Delete data from memory
__init__
Arguments:
identifiers (Optional[List[str]], optional): Keys associated with data. If equals to None, flushes memory. Defaults to None.
__call__
Arguments:
input_data (Transformable): Current data.
evaluator (Optional[Evaluator], optional): Evaluator in context of which executed. If equals to None, default evaluator will be created. Defaults to None.
Raises:
InavalidMemoryInstruction: If provided instruction doesnt exists.
Returns:
Transformable: Result of execution.
MemoryManager
Manage memory
__init__
Arguments:
directory (Optional[str], optional): Path to directory. Defaults to None.
initial_data (Optional[Dict[str, Any]], optional): Data for initialization of memory. Defaults to None.
get
Get data from memory
Arguments:
register (Transformable): Current data.
identifiers (List[Union[str, Tuple[str, str]]]): Key/keys that will be used to access data in memory and for setting to register.
default (Dict[str, Any]): A map of values to be returned for each provided identifier if the identifier(s) are not found. If an identifier is not found and no default value is provided for it, an exception will be raised. Defaults to None.
delete (bool, optional): If equals to True, deletes accessed memory identifiers. Defaults to False.
Returns:
Transformable: Result of execution.
set
Set data to memory
Arguments:
register (Transformable): Current data.
get_key (str): Source of data.
set_key (str): Destination in memory.
delete
Delete specified identifier from memory
Arguments:
identifier (str): Identifier to delete.
flush
Clean memory
Last updated