aiida.tools.importexport.dbimport.backends package

Submodules

Common import functions for both database backend

aiida.tools.importexport.dbimport.backends.common._copy_node_repositories(*, uuids_to_create: List[str], reader: aiida.tools.importexport.archive.readers.ArchiveReaderAbstract)[source]

Copy repositories of new nodes from the archive to the AiiDa profile.

Parameters
  • uuids_to_create – the node UUIDs to copy

  • reader – the archive reader

aiida.tools.importexport.dbimport.backends.common._make_import_group(*, group: Optional[aiida.orm.groups.ImportGroup], node_pks: List[int])aiida.orm.groups.ImportGroup[source]

Make an import group containing all imported nodes.

Parameters
  • group – Use an existing group

  • node_pks – node pks to add to group

aiida.tools.importexport.dbimport.backends.common._sanitize_extras(fields: dict)dict[source]

Remove unwanted extra keys.

Parameters

fields – the database fields for the entity

aiida.tools.importexport.dbimport.backends.common._strip_checkpoints(fields: dict)dict[source]

Remove checkpoint from attributes of process nodes.

Parameters

fields – the database fields for the entity

Django-specific import of AiiDA entities

aiida.tools.importexport.dbimport.backends.django._add_nodes_to_groups(*, group_count: int, group_uuids: Iterable[Tuple[str, Set[str]]], foreign_ids_reverse_mappings: Dict[str, Dict[str, int]])[source]

Add nodes to imported groups.

aiida.tools.importexport.dbimport.backends.django._select_entity_data(*, entity_name: str, reader: aiida.tools.importexport.archive.readers.ArchiveReaderAbstract, new_entries: Dict[str, Dict[str, dict]], existing_entries: Dict[str, Dict[str, dict]], foreign_ids_reverse_mappings: Dict[str, Dict[str, int]], extras_mode_new: str)[source]

Select the data to import by comparing the AiiDA database to the archive contents.

aiida.tools.importexport.dbimport.backends.django._store_entity_data(*, reader: aiida.tools.importexport.archive.readers.ArchiveReaderAbstract, entity_name: str, comment_mode: str, extras_mode_existing: str, new_entries: Dict[str, Dict[str, dict]], existing_entries: Dict[str, Dict[str, dict]], foreign_ids_reverse_mappings: Dict[str, Dict[str, int]], import_unique_ids_mappings: Dict[str, Dict[int, str]], ret_dict: dict, batch_size: int)[source]

Store the entity data on the AiiDA profile.

Store node links to the database.

aiida.tools.importexport.dbimport.backends.django.import_data_dj(in_path: str, group: Optional[aiida.orm.groups.Group] = None, ignore_unknown_nodes: bool = False, extras_mode_existing: str = 'kcl', extras_mode_new: str = 'import', comment_mode: str = 'newest', silent: Optional[bool] = None, **kwargs: Any)[source]

Import exported AiiDA archive to the AiiDA database and repository.

Specific for the Django backend. If in_path is a folder, calls extract_tree; otherwise, tries to detect the compression format (zip, tar.gz, tar.bz2, …) and calls the correct function.

Parameters
  • in_path (str) – the path to a file or folder that can be imported in AiiDA.

  • group (Group) – Group wherein all imported Nodes will be placed.

  • extras_mode_existing (str) – 3 letter code that will identify what to do with the extras import. The first letter acts on extras that are present in the original node and not present in the imported node. Can be either: ‘k’ (keep it) or ‘n’ (do not keep it). The second letter acts on the imported extras that are not present in the original node. Can be either: ‘c’ (create it) or ‘n’ (do not create it). The third letter defines what to do in case of a name collision. Can be either: ‘l’ (leave the old value), ‘u’ (update with a new value), ‘d’ (delete the extra), or ‘a’ (ask what to do if the content is different).

  • extras_mode_new (str) – ‘import’ to import extras of new nodes or ‘none’ to ignore them.

  • comment_mode (str) – Comment import nodes (when same UUIDs are found). Can be either: ‘newest’ (will keep the Comment with the most recent modification time (mtime)) or ‘overwrite’ (will overwrite existing Comments with the ones from the import file).

Returns

New and existing Nodes and Links.

Return type

dict

Raises

SQLAlchemy-specific import of AiiDA entities

aiida.tools.importexport.dbimport.backends.sqla._add_nodes_to_groups(*, group_count: int, group_uuids: Iterable[Tuple[str, Set[str]]], foreign_ids_reverse_mappings: Dict[str, Dict[str, int]])[source]

Add nodes to imported groups.

aiida.tools.importexport.dbimport.backends.sqla._select_entity_data(*, entity_name: str, reader: aiida.tools.importexport.archive.readers.ArchiveReaderAbstract, new_entries: Dict[str, Dict[str, dict]], existing_entries: Dict[str, Dict[str, dict]], foreign_ids_reverse_mappings: Dict[str, Dict[str, int]], extras_mode_new: str)[source]

Select the data to import by comparing the AiiDA database to the archive contents.

aiida.tools.importexport.dbimport.backends.sqla._store_entity_data(*, reader: aiida.tools.importexport.archive.readers.ArchiveReaderAbstract, entity_name: str, comment_mode: str, extras_mode_existing: str, new_entries: Dict[str, Dict[str, dict]], existing_entries: Dict[str, Dict[str, dict]], foreign_ids_reverse_mappings: Dict[str, Dict[str, int]], import_unique_ids_mappings: Dict[str, Dict[int, str]], ret_dict: dict, session: sqlalchemy.orm.session.Session)[source]

Store the entity data on the AiiDA profile.

Store node links to the database.

aiida.tools.importexport.dbimport.backends.sqla.import_data_sqla(in_path: str, group: Optional[aiida.orm.groups.Group] = None, ignore_unknown_nodes: bool = False, extras_mode_existing: str = 'kcl', extras_mode_new: str = 'import', comment_mode: str = 'newest', silent: Optional[bool] = None, **kwargs: Any)[source]

Import exported AiiDA archive to the AiiDA database and repository.

Specific for the SQLAlchemy backend. If in_path is a folder, calls extract_tree; otherwise, tries to detect the compression format (zip, tar.gz, tar.bz2, …) and calls the correct function.

Parameters
  • in_path (str) – the path to a file or folder that can be imported in AiiDA.

  • group (Group) – Group wherein all imported Nodes will be placed.

  • extras_mode_existing (str) – 3 letter code that will identify what to do with the extras import. The first letter acts on extras that are present in the original node and not present in the imported node. Can be either: ‘k’ (keep it) or ‘n’ (do not keep it). The second letter acts on the imported extras that are not present in the original node. Can be either: ‘c’ (create it) or ‘n’ (do not create it). The third letter defines what to do in case of a name collision. Can be either: ‘l’ (leave the old value), ‘u’ (update with a new value), ‘d’ (delete the extra), or ‘a’ (ask what to do if the content is different).

  • extras_mode_new (str) – ‘import’ to import extras of new nodes or ‘none’ to ignore them.

  • comment_mode (str) – Comment import modes (when same UUIDs are found). Can be either: ‘newest’ (will keep the Comment with the most recent modification time (mtime)) or ‘overwrite’ (will overwrite existing Comments with the ones from the import file).

  • silent (bool) – suppress progress bar and summary.

Returns

New and existing Nodes and Links.

Return type

dict

Raises
aiida.tools.importexport.dbimport.backends.sqla.sql_transaction()[source]

A context manager for the transaction.