modelrunner.storage.tools module
Functions that provide convenience on top of the storage classes
- class open_storage(storage=None, *, loc=None, **kwargs)[source]
Bases:
StorageGroup
open a storage and return the root
StorageGroup
Example
This can be either used like a function
storage = open_storage(...) # use the storage storage.close()
or as a context manager
with open_storage(...) as storage: # use the storage
- Parameters:
storage (StorageID) – The path to a file or directory or a
StorageBase
instance. The special value None creates aMemoryStorage
loc (str or list of str) – Denotes the location that will be opened within the storage. The default None opens the root group of the storage.
mode (str or
ModeType
) – The file mode with which the storage is accessed, which determines the allowed operations. Common options are “read”, “full”, “append”, and “truncate”.**kwargs – All other arguments are passed on to the storage class
- close()[source]
close the storage (and flush all data to persistent storage if necessary)
- Return type:
None
- property mode: AccessMode
access mode
- Type: