aiida.manage.backup package

Submodules

class aiida.manage.backup.backup_base.AbstractBackup(backup_info_filepath, additional_back_time_mins)[source]

Bases: object

This class handles the backup of the AiiDA repository that is referenced by the current AiiDA database. The backup will start from the given backup timestamp (oldest_object_backedup) or the date of the oldest node/workflow object found and it will periodically backup (in periods of periodicity days) until the ending date of the backup specified by end_date_of_backup or days_to_backup.

BACKUP_DIR_KEY = 'backup_dir'
BACKUP_LENGTH_THRESHOLD_KEY = 'backup_length_threshold'
DAYS_TO_BACKUP_KEY = 'days_to_backup'
END_DATE_OF_BACKUP_KEY = 'end_date_of_backup'
OLDEST_OBJECT_BK_KEY = 'oldest_object_backedup'
PERIODICITY_KEY = 'periodicity'
__abstractmethods__ = frozenset(['_get_query_set_iterator', '_get_source_directory', '_get_query_sets', '_query_first_node', '_get_query_set_length'])
__dict__ = dict_proxy({'_days_to_backup': None, '_additional_back_time_mins': None, '__module__': 'aiida.manage.backup.backup_base', 'BACKUP_DIR_KEY': 'backup_dir', '_ignore_backup_dir_existence_check': False, '_get_query_set_iterator': <function _get_query_set_iterator>, '_backup_length_threshold': None, '__dict__': <attribute '__dict__' of 'AbstractBackup' objects>, '_end_date_of_backup': None, '_store_backup_info': <function _store_backup_info>, '__init__': <function __init__>, '_abc_cache': <_weakrefset.WeakSet object>, '_get_source_directory': <function _get_source_directory>, '_read_backup_info_from_dict': <function _read_backup_info_from_dict>, '_backup_needed_files': <function _backup_needed_files>, '_get_query_set_length': <function _get_query_set_length>, '__abstractmethods__': frozenset(['_get_query_set_iterator', '_get_source_directory', '_get_query_sets', '_query_first_node', '_get_query_set_length']), '_query_first_node': <function _query_first_node>, 'PERIODICITY_KEY': 'periodicity', 'BACKUP_LENGTH_THRESHOLD_KEY': 'backup_length_threshold', '_abc_negative_cache': <_weakrefset.WeakSet object>, '__doc__': '\n This class handles the backup of the AiiDA repository that is referenced\n by the current AiiDA database. The backup will start from the\n given backup timestamp (*oldest_object_backedup*) or the date of the\n oldest node/workflow object found and it will periodically backup\n (in periods of *periodicity* days) until the ending date of the backup\n specified by *end_date_of_backup* or *days_to_backup*.\n ', 'run': <function run>, '_read_backup_info_from_file': <function _read_backup_info_from_file>, 'OLDEST_OBJECT_BK_KEY': 'oldest_object_backedup', 'DAYS_TO_BACKUP_KEY': 'days_to_backup', '_find_files_to_backup': <function _find_files_to_backup>, '_internal_end_date_of_backup': None, '__weakref__': <attribute '__weakref__' of 'AbstractBackup' objects>, '_oldest_object_bk': None, '_abc_registry': <_weakrefset.WeakSet object>, '_get_repository_path': <function _get_repository_path>, '_extract_parent_dirs': <staticmethod object>, '_abc_negative_cache_version': 102, '_dictionarize_backup_info': <function _dictionarize_backup_info>, 'END_DATE_OF_BACKUP_KEY': 'end_date_of_backup', '_get_query_sets': <function _get_query_sets>, '_periodicity': None, '_backup_dir': None})
__init__(backup_info_filepath, additional_back_time_mins)[source]

x.__init__(…) initializes x; see help(type(x)) for signature

__module__ = 'aiida.manage.backup.backup_base'
__weakref__

list of weak references to the object (if defined)

_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 102
_abc_registry = <_weakrefset.WeakSet object>
_additional_back_time_mins = None
_backup_dir = None
_backup_length_threshold = None
_backup_needed_files(query_sets)[source]
_days_to_backup = None
_dictionarize_backup_info()[source]

This dictionarises the backup information and returns the dictionary.

_end_date_of_backup = None
static _extract_parent_dirs(given_rel_dir, parent_dir_set)[source]

This method extracts the parent directories of the givenDir and populates the parent_dir_set.

_find_files_to_backup()[source]

Query the database for nodes that were created after the the start of the last backup. Return a query set.

_get_query_set_iterator(query_set)[source]

Get query set iterator

_get_query_set_length(query_set)[source]

Get query set length

_get_query_sets(start_of_backup, backup_end_for_this_round)[source]

Get query set

_get_repository_path()[source]
_get_source_directory(item)[source]

Get source directory of item :param self: :return:

_ignore_backup_dir_existence_check = False
_internal_end_date_of_backup = None
_oldest_object_bk = None
_periodicity = None
_query_first_node()[source]

Query first node

_read_backup_info_from_dict(backup_variables)[source]

This method reads the backup information from the given dictionary and sets the needed class variables.

_read_backup_info_from_file(backup_info_file_name)[source]

This method reads the backup information from the given file and passes the dictionary to the method responsible for the initialization of the needed class variables.

_store_backup_info(backup_info_file_name)[source]

This method writes the backup variables dictionary to a file with the given filename.

run()[source]
exception aiida.manage.backup.backup_base.BackupError(value)[source]

Bases: exceptions.Exception

__init__(value)[source]

x.__init__(…) initializes x; see help(type(x)) for signature

__module__ = 'aiida.manage.backup.backup_base'
__str__() <==> str(x)[source]
__weakref__

list of weak references to the object (if defined)

Backup implementation for SqlAlchemy backend.

class aiida.manage.backup.backup_sqlalchemy.Backup(backup_info_filepath, additional_back_time_mins)[source]

Bases: aiida.manage.backup.backup_base.AbstractBackup

Backup for sqlalchemy backend

__abstractmethods__ = frozenset([])
__module__ = 'aiida.manage.backup.backup_sqlalchemy'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 102
_abc_registry = <_weakrefset.WeakSet object>
_batch_size = 50
_get_query_set_iterator(query_set)[source]

Get query set iterator :param query_set: :return:

_get_query_set_length(query_set)[source]

Get query set length

_get_query_sets(start_of_backup, backup_end_for_this_round)[source]

Get Nodes and Worflows query set from start to en

d of backup. :param start_of_backup: :param backup_end_for_this_round: :return:

_get_source_directory(item)[source]
Parameters:item
Returns:
_query_first_node()[source]

Query first node :return:

Utilities for the backup functionality.

aiida.manage.backup.backup_utils.ask_question(question, reply_type, allow_none_as_answer=True)[source]

This method asks a specific question, tries to parse the given reply and then it verifies the parsed answer. :param question: The question to be asked. :param reply_type: The type of the expected answer (int, datetime etc). It is needed for the parsing of the answer. :param allow_none_as_answer: Allow empty answers? :return: The parsed reply.

aiida.manage.backup.backup_utils.query_string(question, default)[source]

Asks a question (with the option to have a default, predefined answer, and depending on the default answer and the answer of the user the following options are available: - If the user replies (with a non empty answer), then his answer is returned. - If the default answer is None then the user has to reply with a non-empty answer. - If the default answer is not None, then it is returned if the user gives an empty answer. In the case of empty default answer and empty reply from the user, None is returned. :param question: The question that we want to ask the user. :param default: The default answer (if there is any) to the question asked. :return: The returned reply.

aiida.manage.backup.backup_utils.query_yes_no(question, default='yes')[source]

Ask a yes/no question via input() and return their answer.

“question” is a string that is presented to the user. “default” is the presumed answer if the user just hits <Enter>. It must be “yes” (the default), “no” or None (meaning an answer is required of the user).

The “answer” return value is True for “yes” or False for “no”.