Module for file repository backend implementations.
aiida.repository.backend.
AbstractRepositoryBackend
Bases: object
object
Class that defines the abstract interface for an object repository.
The repository backend only deals with raw bytes, both when creating new objects as well as when returning a stream or the content of an existing object. The encoding and decoding of the byte content should be done by the client upstream. The file repository backend is also not expected to keep any kind of file hierarchy but must be assumed to be a simple flat data store. When files are created in the file object repository, the implementation will return a string-based key with which the content of the stored object can be addressed. This key is guaranteed to be unique and persistent. Persisting the key or mapping it onto a virtual file hierarchy is again up to the client upstream.
__abstractmethods__
__dict__
__module__
__weakref__
list of weak references to the object (if defined)
_abc_impl
_put_object_from_filelike
delete_object
Delete the object from the repository.
key – fully qualified identifier for the object within the repository.
FileNotFoundError – if the file does not exist.
OSError – if the file could not be deleted.
erase
Delete the repository itself and all its contents.
Note
This should not merely delete the contents of the repository but any resources it created. For example, if the repository is essentially a folder on disk, the folder itself should also be deleted, not just its contents.
get_object_content
Return the content of a object identified by key.
OSError – if the file could not be opened.
get_object_hash
Return the SHA-256 hash of an object stored under the given key.
Important
A SHA-256 hash should always be returned, to ensure consistency across different repository implementations.
has_object
Return whether the repository has an object with the given key.
True if the object exists, False otherwise.
initialise
Initialise the repository if it hasn’t already been initialised.
kwargs – parameters for the initialisation.
is_initialised
Return whether the repository has been initialised.
is_readable_byte_stream
open
Open a file handle to an object stored under the given key.
this should only be used to open a handle to read an existing file. To write a new file use the method put_object_from_filelike instead.
put_object_from_filelike
yield a byte stream object.
put_object_from_file
Store a new object with contents of the file located at filepath on this file system.
filepath – absolute path of file whose contents to copy to the repository.
the generated fully qualified identifier for the object within the repository.
TypeError – if the handle is not a byte stream.
Store the byte contents of a file in the repository.
handle – filelike object with the byte content to be stored.
uuid
Return the unique identifier of the repository.
DiskObjectStoreRepositoryBackend
Bases: aiida.repository.backend.abstract.AbstractRepositoryBackend
aiida.repository.backend.abstract.AbstractRepositoryBackend
Implementation of the AbstractRepositoryBackend using the disk-object-store as the backend.
disk-object-store
__init__
Initialize self. See help(type(self)) for accurate signature.
__str__
Return the string representation of this repository.
container
SandboxRepositoryBackend
Implementation of the AbstractRepositoryBackend using a sandbox folder on disk as the backend.
__del__
Delete the entire sandbox folder if it was instantiated and still exists.
sandbox
Return the sandbox instance of this repository.
A sandbox folder does not have the concept of a unique identifier and so always returns None.
None
The scope of this class is intentionally very narrow. Any backend implementation should merely provide the methods to store binary blobs, or “objects”, and return a string-based key that unique identifies the object that was just created. This key should then be able to be used to retrieve the bytes of the corresponding object or to delete it.
aiida.repository.backend.abstract.
Implementation of the AbstractRepositoryBackend using the disk-objectstore as the backend.
disk-objectstore
aiida.repository.backend.disk_object_store.
aiida.repository.backend.sandbox.