aiida.storage.sqlite_dos package#
Storage implementation using Sqlite database and disk-objectstore container.
Submodules#
Storage implementation using Sqlite database and disk-objectstore container.
- class aiida.storage.sqlite_dos.backend.SqliteDosMigrator(profile: Profile)[source]#
Bases:
PsqlDosMigrator
Storage implementation using Sqlite database and disk-objectstore container.
This storage backend is not recommended for use in production. The sqlite database is not the most performant and it does not support all the
QueryBuilder
functionality that is supported by thecore.psql_dos
storage backend. This storage is ideally suited for use cases that want to test or demo AiiDA as it requires no server but just a folder on the local filesystem.- __annotations__ = {}#
- __module__ = 'aiida.storage.sqlite_dos.backend'#
- class aiida.storage.sqlite_dos.backend.SqliteDosStorage(profile: Profile)[source]#
Bases:
PsqlDosBackend
A lightweight storage that is easy to install.
This backend implementation uses an SQLite database and a disk-objectstore container as the file repository. As such, this storage plugin does not require any services, making it easy to install and use on most systems.
- class Model(**data: Any)[source]#
Bases:
BaseModel
Model describing required information to configure an instance of the storage.
- __abstractmethods__ = frozenset({})#
- __annotations__ = {'__class_vars__': 'ClassVar[set[str]]', '__private_attributes__': 'ClassVar[Dict[str, ModelPrivateAttr]]', '__pydantic_complete__': 'ClassVar[bool]', '__pydantic_core_schema__': 'ClassVar[CoreSchema]', '__pydantic_custom_init__': 'ClassVar[bool]', '__pydantic_decorators__': 'ClassVar[_decorators.DecoratorInfos]', '__pydantic_extra__': 'dict[str, Any] | None', '__pydantic_fields_set__': 'set[str]', '__pydantic_generic_metadata__': 'ClassVar[_generics.PydanticGenericMetadata]', '__pydantic_parent_namespace__': 'ClassVar[Dict[str, Any] | None]', '__pydantic_post_init__': "ClassVar[None | Literal['model_post_init']]", '__pydantic_private__': 'dict[str, Any] | None', '__pydantic_root_model__': 'ClassVar[bool]', '__pydantic_serializer__': 'ClassVar[SchemaSerializer]', '__pydantic_validator__': 'ClassVar[SchemaValidator | PluggableSchemaValidator]', '__signature__': 'ClassVar[Signature]', 'filepath': 'str', 'model_computed_fields': 'ClassVar[Dict[str, ComputedFieldInfo]]', 'model_config': 'ClassVar[ConfigDict]', 'model_fields': 'ClassVar[Dict[str, FieldInfo]]'}#
- __dict__#
- __module__ = 'aiida.storage.sqlite_dos.backend'#
- __private_attributes__: ClassVar[Dict[str, ModelPrivateAttr]] = {}#
Metadata about the private attributes of the model.
- __pydantic_complete__: ClassVar[bool] = True#
Whether model building is completed, or if there are still undefined fields.
- __pydantic_core_schema__: ClassVar[CoreSchema] = {'cls': <class 'aiida.storage.sqlite_dos.backend.SqliteDosStorage.Model'>, 'config': {'title': 'Model'}, 'custom_init': False, 'metadata': {'pydantic_js_annotation_functions': [], 'pydantic_js_functions': [functools.partial(<function modify_model_json_schema>, cls=<class 'aiida.storage.sqlite_dos.backend.SqliteDosStorage.Model'>, title=None), <bound method BaseModel.__get_pydantic_json_schema__ of <class 'aiida.storage.sqlite_dos.backend.SqliteDosStorage.Model'>>]}, 'ref': 'aiida.storage.sqlite_dos.backend.SqliteDosStorage.Model:94480886696208', 'root_model': False, 'schema': {'computed_fields': [], 'fields': {'filepath': {'metadata': {'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>], 'pydantic_js_functions': []}, 'schema': {'default_factory': <function SqliteDosStorage.Model.<lambda>>, 'schema': {'function': {'function': <bound method SqliteDosStorage.Model.filepath_is_absolute of <class 'aiida.storage.sqlite_dos.backend.SqliteDosStorage.Model'>>, 'type': 'no-info'}, 'schema': {'type': 'str'}, 'type': 'function-after'}, 'type': 'default'}, 'type': 'model-field'}}, 'model_name': 'Model', 'type': 'model-fields'}, 'type': 'model'}#
The core schema of the model.
- __pydantic_decorators__: ClassVar[_decorators.DecoratorInfos] = DecoratorInfos(validators={}, field_validators={'filepath_is_absolute': Decorator(cls_ref='aiida.storage.sqlite_dos.backend.SqliteDosStorage.Model:94480886696208', cls_var_name='filepath_is_absolute', func=<bound method SqliteDosStorage.Model.filepath_is_absolute of <class 'aiida.storage.sqlite_dos.backend.SqliteDosStorage.Model'>>, shim=None, info=FieldValidatorDecoratorInfo(fields=('filepath',), mode='after', check_fields=None, json_schema_input_type=PydanticUndefined))}, root_validators={}, field_serializers={}, model_serializers={}, model_validators={}, computed_fields={})#
Metadata containing the decorators defined on the model. This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
- __pydantic_extra__: dict[str, Any] | None#
A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to ‘allow’.
- __pydantic_generic_metadata__: ClassVar[_generics.PydanticGenericMetadata] = {'args': (), 'origin': None, 'parameters': ()}#
Metadata for generic models; contains data used for a similar purpose to __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these.
- __pydantic_parent_namespace__: ClassVar[Dict[str, Any] | None] = {'__doc__': 'A lightweight storage that is easy to install.\n\n This backend implementation uses an SQLite database and a disk-objectstore container as the file repository. As\n such, this storage plugin does not require any services, making it easy to install and use on most systems.\n ', '__module__': 'aiida.storage.sqlite_dos.backend', '__qualname__': 'SqliteDosStorage', 'migrator': <pydantic._internal._model_construction._PydanticWeakRef object>, 'subject': <pydantic._internal._mock_val_ser.MockValSer object>}#
Parent namespace of the model, used for automatic rebuilding of models.
- __pydantic_post_init__: ClassVar[None | Literal['model_post_init']] = None#
The name of the post-init method for the model, if defined.
- __pydantic_private__: dict[str, Any] | None#
Values of private attributes set on the model instance.
- __pydantic_serializer__: ClassVar[SchemaSerializer] = SchemaSerializer(serializer=Model( ModelSerializer { class: Py( 0x000055ee0bb08910, ), serializer: Fields( GeneralFieldsSerializer { fields: { "filepath": SerField { key_py: Py( 0x00007fc247e0d0a0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: DefaultFactory( Py( 0x00007fc23c9f09a0, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, }, computed_fields: Some( ComputedFields( [], ), ), mode: SimpleDict, extra_serializer: None, filter: SchemaFilter { include: None, exclude: None, }, required_fields: 1, }, ), has_extra: false, root_model: false, name: "Model", }, ), definitions=[])#
The pydantic-core SchemaSerializer used to dump instances of the model.
- __pydantic_validator__: ClassVar[SchemaValidator | PluggableSchemaValidator] = SchemaValidator(title="Model", validator=Model( ModelValidator { revalidate: Never, validator: ModelFields( ModelFieldsValidator { fields: [ Field { name: "filepath", lookup_key: Simple { key: "filepath", py_key: Py( 0x00007fc20ccd91f0, ), path: LookupPath( [ S( "filepath", Py( 0x00007fc20ccd0f70, ), ), ], ), }, name_py: Py( 0x00007fc247e0d0a0, ), validator: WithDefault( WithDefaultValidator { default: DefaultFactory( Py( 0x00007fc23c9f09a0, ), ), on_error: Raise, validator: FunctionAfter( FunctionAfterValidator { validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), func: Py( 0x00007fc23c9e4940, ), config: Py( 0x00007fc20d14a080, ), name: "function-after[filepath_is_absolute(), str]", field_name: None, info_arg: false, }, ), validate_default: false, copy_default: false, name: "default[function-after[filepath_is_absolute(), str]]", undefined: Py( 0x00007fc24570ee20, ), }, ), frozen: false, }, ], model_name: "Model", extra_behavior: Ignore, extras_validator: None, strict: false, from_attributes: false, loc_by_alias: true, }, ), class: Py( 0x000055ee0bb08910, ), post_init: None, frozen: false, custom_init: false, root_model: false, undefined: Py( 0x00007fc24570ee20, ), name: "Model", }, ), definitions=[], cache_strings=True)#
The pydantic-core SchemaValidator used to validate instances of the model.
- __weakref__#
list of weak references to the object
- _abc_impl = <_abc._abc_data object>#
- classmethod filepath_is_absolute(value: str) str [source]#
Return the resolved and absolute filepath.
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'defer_build': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'filepath': FieldInfo(annotation=str, required=False, default_factory=<lambda>, title='Directory of the backend', description='Filepath of the directory in which to store data for this backend.')}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- __abstractmethods__ = frozenset({})#
- __module__ = 'aiida.storage.sqlite_dos.backend'#
- _abc_impl = <_abc._abc_data object>#
- _backup(dest: str, keep: int | None = None)[source]#
Create a backup of the storage.
- Parameters:
dest – Path to where the backup will be created. Can be a path on the local file system, or a path on a remote that can be accessed over SSH in the form
<user>@<host>:<path>
.keep – The maximum number of backups to keep. If the number of copies exceeds this number, the oldest backups are removed.
- _backup_storage(manager: BackupManager, path: Path, prev_backup: Path | None = None) None [source]#
Create a backup of the sqlite database and disk-objectstore to the provided path.
- Parameters:
manager – BackupManager from backup_utils containing utilities such as for calling the rsync.
path – Path to where the backup will be created.
prev_backup – Path to the previous backup. Rsync calls will be hard-linked to this path, making the backup incremental and efficient.
- static _get_mapper_from_entity(entity_type: EntityTypes, with_pk: bool)[source]#
Return the Sqlalchemy mapper and fields corresponding to the given entity.
- Parameters:
with_pk – if True, the fields returned will include the primary key
- _initialise_session()[source]#
Initialise the SQLAlchemy session factory.
Only one session factory is ever associated with a given class instance, i.e. once the instance is closed, it cannot be reopened.
The session factory, returns a session that is bound to the current thread. Multi-thread support is currently required by the REST API. Although, in the future, we may want to move the multi-thread handling to higher in the AiiDA stack.
- property authinfos#
Return the collection of authorisation information objects
- property comments#
Return the collection of comments
- property computers#
Return the collection of computers
- get_backend_entity(model) BackendEntity [source]#
Return the backend entity that corresponds to the given Model instance.
- get_repository() DiskObjectStoreRepositoryBackend [source]#
Return the object repository configured for this backend.
- property groups#
Return the collection of groups
- classmethod initialise(profile: Profile, reset: bool = False) bool [source]#
Initialise the storage backend.
This is typically used once when a new storage backed is created. If this method returns without exceptions the storage backend is ready for use. If the backend already seems initialised, this method is a no-op.
- Parameters:
reset – If
true
, destroy the backend if it already exists including all of its data before recreating and initialising it. This is useful for example for test profiles that need to be reset before or after tests having run.- Returns:
True
if the storage was initialised by the function call,False
if it was already initialised.
- property logs#
Return the collection of logs
- migrator#
alias of
SqliteDosMigrator
- property nodes#
Return the collection of nodes
- query() SqliteQueryBuilder [source]#
Return an instance of a query builder implementation for this backend
- property users#
Return the collection of users