Provides export functionalities.
aiida.tools.importexport.dbexport.
export
Export AiiDA data
Deprecated since version 1.2.1: Support for the parameters what and outfile will be removed in v2.0.0. Please use entities and filename instead, respectively.
entities (list) – a list of entity instances; they can belong to different models/entities.
filename (str) – the filename (possibly including the absolute path) of the file on which to export.
file_format (str, ExportFileFormat) – See ExportFileFormat for complete list of valid values (default: ‘zip’).
overwrite (bool) – if True, overwrite the output file without asking, if it exists. If False, raise an ArchiveExportError if the output file already exists.
ArchiveExportError
silent (bool) – suppress console prints and progress bar.
use_compression (bool) – Whether or not to compress the archive file (only valid for the zip file format).
allowed_licenses (list) – List or function. If a list, then checks whether all licenses of Data nodes are in the list. If a function, then calls function for licenses of Data nodes expecting True if license is allowed, False otherwise.
forbidden_licenses (list) – List or function. If a list, then checks whether all licenses of Data nodes are in the list. If a function, then calls function for licenses of Data nodes expecting True if license is allowed, False otherwise.
include_comments (bool) – In-/exclude export of comments for given node(s) in entities. Default: True, include comments in export (as well as relevant users).
entities
include_logs (bool) – In-/exclude export of logs for given node(s) in entities. Default: True, include logs in export.
kwargs – graph traversal rules. See aiida.common.links.GraphTraversalRules what rule names are toggleable and what the defaults are.
aiida.common.links.GraphTraversalRules
ArchiveExportError – if there are any internal errors when exporting.
LicensingException – if any node is licensed under forbidden license.
ExportFileFormat
Bases: str, enum.Enum
str
enum.Enum
Export file formats
TAR_GZIPPED
ZIP
__dict__
__module__
__weakref__
list of weak references to the object (if defined)
_generate_next_value_
_member_map_
_member_names_
_member_type_
alias of builtins.str
builtins.str
_value2member_map_
Utility functions for export of AiiDA entities
aiida.tools.importexport.dbexport.utils.
check_licenses
Check licenses
check_process_nodes_sealed
Check ProcessNode s are sealed Only sealed ProcessNode s may be exported.
ProcessNode
nodes (list, int) – ProcessNode s to be checked. Should be their PK(s).
ExportValidationError – if a ProcessNode is not sealed or nodes is not a list, set, or int.
deprecated_parameters
Handle deprecated parameter (where it is replaced with another)
old (dict) – The old, deprecated parameter as a dict with keys “name” and “value”
new (dict) – The new parameter as a dict with keys “name” and “value”
New parameter’s value (if not defined, then old parameter’s value)
fill_in_query
This function recursively constructs QueryBuilder queries that are needed for the SQLA export function. To manage to construct such queries, the relationship dictionary is consulted (which shows how to reference different AiiDA entities in QueryBuilder. To find the dependencies of the relationships of the exported data, the get_all_fields_info (which described the exported schema and its dependencies) is consulted.
serialize_dict
Serialize the dict using the serialize_field function to serialize each field.
remove_fields –
a list of strings. If a field with key inside the remove_fields list is found, it is removed from the dict.
This is only used at level-0, no removal is possible at deeper levels.
rename_fields –
a dictionary in the format {"oldname": "newname"}.
{"oldname": "newname"}
If the “oldname” key is found, it is replaced with the “newname” string in the output dictionary.
This is only used at level-0, no renaming is possible at deeper levels.
track_conversion – if True, a tuple is returned, where the first element is the serialized dictionary, and the second element is a dictionary with the information on the serialized fields.
serialize_field
Serialize a single field.
Generalize such that it the proper function is selected also during import
summary
Print summary for export
Export a zip-file.
aiida.tools.importexport.dbexport.zip.
MyWritingZipFile
Bases: object
object
__enter__
__exit__
__init__
Initialize self. See help(type(self)) for accurate signature.
close
open
write
ZipFolder
To improve: if zipfile is closed, do something (e.g. add explicit open method, rename open to openfile, set _zipfile to None, …)
zipfolder_or_fname – either another ZipFolder instance, of which you want to get a subfolder, or a filename to create.
mode – the file mode; see the zipfile.ZipFile docs for valid strings. Note: can be specified only if zipfolder_or_fname is a string (the filename to generate)
subfolder – the subfolder that specified the “current working directory” in the zip file. If zipfolder_or_fname is a ZipFolder, subfolder is a relative path from zipfolder_or_fname.subfolder
use_compression – either True, to compress files in the Zip, or False if you just want to pack them together without compressing. It is ignored if zipfolder_or_fname is a ZipFolder isntance.
_get_internal_path
exists
Check whether path already exists in the ZipFolder
get_subfolder
insert_path
pwd