Memory#
- class src.openCHA.datapipes.memory.Memory(*, data: Dict[str, Dict] | None = {})[source]#
- Description: - This class inherits from DataPipe and uses simple on memory python dictionary. - retrieve(key) Any[source]#
- Retrieves stored data using the given key. - This method retrieves the data associated with the provided key from the memory data dictionary. If the key does not exist in the dictionary, it raises a ValueError with an appropriate error message. - Parameters:
- self (object) – The instance of the class. 
- key (str) – The key associated with the data to be retrieved. 
 
- Returns:
- The data associated with the provided key. 
- Return type:
- Any 
- Raises:
- ValueError – If the key does not exist in the data dictionary. 
 - Example - from openCHA.datapipes import DatapipeType memory = initialize_datapipe(datapipe=DatapipeType.MEMORY) memory.retrieve("UUID key returned from store") 
 - store(data) str[source]#
- Stores data using a randomly generated key and returns the key. - This method stores the provided data in the memory data dictionary using a generated key. The generated key is created using UUID (Universally Unique Identifier) ensuring having unique keys for multiple data stores. The stored data can later be accessed using this key. - Parameters:
- self (object) – The instance of the class. 
- data (Any) – The data to be stored. 
 
- Returns:
- The generated key associated with the stored data. 
- Return type:
- str 
 - Example - from openCHA.datapipes import DatapipeType memory = initialize_datapipe(datapipe=DatapipeType.MEMORY) key = memory.store("this is sample string to be stored") 
 
 
    