How to inspect an archive#
Note
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 aiida.storage.sqlite_zip.backend import SqliteZipBackend
archive_profile = SqliteZipBackend.create_profile('include/process.aiida')
print(archive_profile)
Profile<uuid='c5a8478d83ad4e7f8526140ca933c2a7' name='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):
print(manage.get_manager().get_profile())
Warning: You are currently using a post release development version of AiiDA: 2.4.0.post0
Warning: Be aware that this is not recommended for production and is not officially supported.
Warning: Databases used with this version may not be compatible with future releases of AiiDA
Warning: as you might not be able to automatically migrate your data.
Profile<uuid='c5a8478d83ad4e7f8526140ca933c2a7' name='process.aiida'>
/home/docs/checkouts/readthedocs.org/user_builds/aiida-core/envs/latest/lib/python3.10/site-packages/aiida/manage/configuration/settings.py:59: UserWarning: Creating AiiDA configuration folder `/home/docs/.aiida`.
warnings.warn(f'Creating AiiDA configuration folder `{path}`.')
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(storage)
print(json.dumps(storage.get_info(), indent=2))
Warning: You are currently using a post release development version of AiiDA: 2.4.0.post0
Warning: Be aware that this is not recommended for production and is not officially supported.
Warning: Databases used with this version may not be compatible with future releases of AiiDA
Warning: as you might not be able to automatically migrate your data.
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": [
"cff1e914-5a34-4930-9429-9dcc6d38feb1"
]
},
"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
-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:
- cff1e914-5a34-4930-9429-9dcc6d38feb1
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
Note, that once the context manager is exited, the storage is closed, and will except on further calls.
print(storage)
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)
print(process)
Warning: You are currently using a post release development version of AiiDA: 2.4.0.post0
Warning: Be aware that this is not recommended for production and is not officially supported.
Warning: Databases used with this version may not be compatible with future releases of AiiDA
Warning: as you might not be able to automatically migrate your data.
uuid: cff1e914-5a34-4930-9429-9dcc6d38feb1 (pk: 61)
and also use Graph
, to visualize data provenance:
from aiida.tools.visualization 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")
graph.graphviz
Warning: You are currently using a post release development version of AiiDA: 2.4.0.post0
Warning: Be aware that this is not recommended for production and is not officially supported.
Warning: Databases used with this version may not be compatible with future releases of AiiDA
Warning: as you might not be able to automatically migrate your data.