How to inspect an archive


This tutorial can be downloaded and run as a Jupyter Notebook: archive_profile.ipynb , together with the archive include/process.aiida.

The AiiDA archive is a file format for long term storage of data from a particular profile.

See Sharing AiiDA archives for information on how to create and migrate an archive. Once you have an archive at the latest version, you can inspect its contents in the same way you would with a standard AiiDA profile.

We first create a profile instance from the archive path:

from aiida import manage, orm, profile_context
from import SqliteZipBackend

archive_profile = SqliteZipBackend.create_profile('include/process.aiida')
Profile<'e8254176559e4c92bd5c82aa54e977ba' ('process.aiida')>

The profile_context() function works similarly to the load_profile() function, but is used within a context manager, that insures that the storage is properly closed when the context is exited. With this, we can load our archive as a profile:

with profile_context(archive_profile):
Profile<'e8254176559e4c92bd5c82aa54e977ba' ('process.aiida')>

To directly access the storage backend, and view information about it, we can use:

import json
with profile_context(archive_profile):
    storage = manage.get_manager().get_profile_storage()
    print(json.dumps(storage.get_info(), indent=2))
SqliteZip storage (read-only) [open] @ include/process.aiida
  "metadata": {
    "export_version": "main_0001",
    "aiida_version": "2.0.0a1",
    "key_format": "sha256",
    "compression": 6,
    "ctime": "2022-03-10T11:56:56.759722",
    "creation_parameters": {
      "entities_starting_set": {
        "node": [
      "include_authinfos": false,
      "include_comments": true,
      "include_logs": true,
      "graph_traversal_rules": {
        "input_calc_forward": false,
        "input_calc_backward": true,
        "create_forward": true,
        "create_backward": true,
        "return_forward": true,
        "return_backward": false,
        "input_work_forward": false,
        "input_work_backward": true,
        "call_calc_forward": true,
        "call_calc_backward": true,
        "call_work_forward": true,
        "call_work_backward": true

This is directly equivalent to the command-line call:

!verdi archive info include/process.aiida
  export_version: main_0001
  aiida_version: 2.0.0a1
  key_format: sha256
  compression: 6
  ctime: '2022-03-10T11:56:56.759722'
      - cff1e914-5a34-4930-9429-9dcc6d38feb1
    include_authinfos: false
    include_comments: true
    include_logs: true
      input_calc_forward: false
      input_calc_backward: true
      create_forward: true
      create_backward: true
      return_forward: true
      return_backward: false
      input_work_forward: false
      input_work_backward: true
      call_calc_forward: true
      call_calc_backward: true
      call_work_forward: true
      call_work_backward: true

Note, that once the context manager is exited, the storage is closed, and will except on further calls.

SqliteZip storage (read-only) [closed] @ include/process.aiida

As per a standard profile, we can now use the QueryBuilder, to find and query for data:

with profile_context(archive_profile):
    process = orm.QueryBuilder().append(orm.ProcessNode).first(flat=True)
uuid: cff1e914-5a34-4930-9429-9dcc6d38feb1 (pk: 61)

and also use Graph, to visualize data provenance:

from import Graph

with profile_context(archive_profile):
    process = orm.QueryBuilder().append(orm.ProcessNode).first(flat=True)
    graph = Graph(graph_attr={"size": "8!,8!", "rankdir": "LR"})
    graph.add_incoming(process, annotate_links="both")
    graph.add_outgoing(process, annotate_links="both")