aiida.common.additions.backup_script package

Submodules

class aiida.common.additions.backup_script.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_set_length', '_get_query_sets', '_query_first_node', '_query_first_workflow'])
__dict__ = dict_proxy({'_days_to_backup': None, '_additional_back_time_mins': None, '__module__': 'aiida.common.additions.backup_script.backup_base', '__metaclass__': <class 'abc.ABCMeta'>, '_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>, 'BACKUP_DIR_KEY': 'backup_dir', '_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_set_length', '_get_query_sets', '_query_first_node', '_query_first_workflow']), '_query_first_node': <function _query_first_node>, '_query_first_workflow': <function _query_first_workflow>, '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': 92, '_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

__metaclass__

alias of abc.ABCMeta

__module__ = 'aiida.common.additions.backup_script.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 = 92
_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(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

_query_first_workflow()[source]

Query first workflow

_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.common.additions.backup_script.backup_base.BackupError(value)[source]

Bases: exceptions.Exception

__init__(value)[source]

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

__module__ = 'aiida.common.additions.backup_script.backup_base'
__str__() <==> str(x)[source]
__weakref__

list of weak references to the object (if defined)

class aiida.common.additions.backup_script.backup_django.Backup(backup_info_filepath, additional_back_time_mins)[source]

Bases: aiida.common.additions.backup_script.backup_base.AbstractBackup

Backup for django backend

__abstractmethods__ = frozenset([])
__module__ = 'aiida.common.additions.backup_script.backup_django'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 95
_abc_registry = <_weakrefset.WeakSet object>
_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 end 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:

_query_first_workflow()[source]

Query first workflow :return:

class aiida.common.additions.backup_script.backup_setup.BackupSetup[source]

Bases: object

This class setups the main backup script related information & files like:

- the backup parameter file. It also allows the user to set it up by answering questions.
- the backup folders.
- the script that initiates the backup.
__dict__ = dict_proxy({'__module__': 'aiida.common.additions.backup_script.backup_setup', 'run': <function run>, 'print_info': <function print_info>, '__dict__': <attribute '__dict__' of 'BackupSetup' objects>, '__weakref__': <attribute '__weakref__' of 'BackupSetup' objects>, 'create_dir': <function create_dir>, 'construct_backup_variables': <function construct_backup_variables>, '__doc__': '\n This class setups the main backup script related information & files like::\n\n - the backup parameter file. It also allows the user to set it up by answering questions.\n - the backup folders.\n - the script that initiates the backup.\n ', '__init__': <function __init__>})
__init__()[source]

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

__module__ = 'aiida.common.additions.backup_script.backup_setup'
__weakref__

list of weak references to the object (if defined)

construct_backup_variables(file_backup_folder_abs)[source]
create_dir(question, dir_path)[source]
print_info()[source]
run()[source]
class aiida.common.additions.backup_script.backup_sqlalchemy.Backup(backup_info_filepath, additional_back_time_mins)[source]

Bases: aiida.common.additions.backup_script.backup_base.AbstractBackup

Backup for sqlalchemy backend

__abstractmethods__ = frozenset([])
__module__ = 'aiida.common.additions.backup_script.backup_sqlalchemy'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 95
_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:

_query_first_workflow()[source]

Query first workflow :return: