MCPcopy
hub / github.com/apache/caldera / _restore_state

Method _restore_state

app/utility/base_knowledge_svc.py:288–308  ·  view source on GitHub ↗

Loads the internal store state from disk :return: None

(self)

Source from the content-addressed store, hash-verified

286 FACT_STORE_PATH.split(os.path.sep)[0])
287
288 async def _restore_state(self):
289 """
290 Loads the internal store state from disk
291
292 :return: None
293 """
294 if os.path.exists(FACT_STORE_PATH):
295 _, store = await self.get_service('file_svc').read_file(FACT_STORE_PATH.split(os.path.sep)[1],
296 FACT_STORE_PATH.split(os.path.sep)[0])
297 # Pickle is only used to load a local file that caldera creates. Pickled data is not
298 # received over the network.
299 ram = pickle.loads(store) # nosec
300 for key in ram.keys():
301 self.fact_ram[key] = []
302 for c_object in ram[key]:
303 handle = self._load_wrapper(key)
304 constraints = []
305 if c_object._knowledge_id in ram[key]:
306 constraints = ram[key][c_object._knowledge_id]
307 await handle(c_object, constraints=constraints)
308 self.log.debug('Restored data from persistent storage')
309
310 def _load_wrapper(self, key):
311 """

Callers 1

restore_stateMethod · 0.80

Calls 3

_load_wrapperMethod · 0.95
get_serviceMethod · 0.80
read_fileMethod · 0.45

Tested by

no test coverage detected