-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Description
Current Situation
The object cache of the LocalFileObjectStore is not initialised when a new instance of the class is created. This means that the files it is intended to contain are not loaded initially.
basyx-python-sdk/sdk/basyx/aas/backend/local_file.py
Lines 34 to 49 in e622edc
| def __init__(self, directory_path: str): | |
| """ | |
| Initializer of class LocalFileObjectStore | |
| :param directory_path: Path to the local file backend (the path where you want to store your AAS JSON files) | |
| """ | |
| self.directory_path: str = directory_path.rstrip("/") | |
| # A dictionary of weak references to local replications of stored objects. Objects are kept in this cache as | |
| # long as there is any other reference in the Python application to them. We use this to make sure that only one | |
| # local replication of each object is kept in the application and retrieving an object from the store always | |
| # returns the **same** (not only equal) object. Still, objects are forgotten, when they are not referenced | |
| # anywhere else to save memory. | |
| self._object_cache: weakref.WeakValueDictionary[model.Identifier, model.Identifiable] \ | |
| = weakref.WeakValueDictionary() | |
| self._object_cache_lock = threading.Lock() |
Consequently, calling CRUD operations such as discard() on newly initialised instances raises a KeyError.
Proposed Change
Add an initialisation routine to the constructor that adds all local files of the LocalFileObjectStore to its cache from initialisation onwards.
Metadata
Metadata
Assignees
Labels
No labels