ExternalStorage
#
- class gufe.storage.externalresource.base.ExternalStorage#
Abstract base for external storage.
Methods
Delete an existing data chunk from the backend.
Check whether a given label has already been used.
Obtain the metadata associated with the actual stored data.
Iterate over the labels in this storage.
Load data for the given chunk in a context manager.
Store given data in the backend.
- delete(location)#
Delete an existing data chunk from the backend.
Subclasses should implement
_delete
.- Parameters:
location (str) – label for the data to delete
- Raises:
MissingExternalResourceError – If the resource to be deleted does not exist
- exists(location) bool #
Check whether a given label has already been used.
Subclasses should implement
_exists
.- Parameters:
location (str) – the label to check for
- Returns:
True if this label has associated data in the backend, False if not
- Return type:
bool
- get_filename(location) str #
- get_metadata(location: str) Metadata #
Obtain the metadata associated with the actual stored data.
We always and only obtain the metadata after the data has been stored. This is because some potential metadata fields, such as last-modified timestamps, may not be known until the data is stored.
- Parameters:
location (str) – the label to obtain the metadata about
- Returns:
Metadata for this object.
- Return type:
- iter_contents(prefix='')#
Iterate over the labels in this storage.
- Parameters:
prefix (str) – Only iterate over paths that start with the given prefix.
- Returns:
Contents of this storage, which may include items without metadata.
- Return type:
Iterator[str]
- load_stream(location) ContextManager #
Load data for the given chunk in a context manager.
This returns a
_ForceContext
, which requires that the returned object be used as a context manager. That_ForcedContext
should wrap a byteslike objet.Subclasses should implement
_load_stream
.- Parameters:
location (str) – the label for the data to load
metadata (str) – metadata to validate that the loaded data is still valid
Returns
_ForceContext – Wrapper around the byteslike
- store_bytes(location, byte_data)#
Store given data in the backend.
Subclasses should implement
_store
.- Parameters:
location (str) – label associated with the data to store
byte_data (bytes) – bytes to store
- store_path(location, path: Path)#