jupytext | kernelspec | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
(how-to:data:share:archive:profile)=
This tutorial can be downloaded and run as a Jupyter Notebook: {nb-download}`archive_profile.ipynb` {octicon}`download`, together with the archive {download}`include/process.aiida`.
The AiiDA archive is a file format for long term storage of data from a particular profile.
See {ref}how-to:share: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)
The {py:func}~aiida.manage.configuration.profile_context
function works similarly to the {py:func}~aiida.manage.configuration.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())
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))
This is directly equivalent to the command-line call:
!verdi archive info include/process.aiida
Note, that once the context manager is exited, the storage is closed, and will except on further calls.
print(storage)
As per a standard profile, we can now use the {py:class}~aiida.orm.QueryBuilder
, to find and query for data:
with profile_context(archive_profile):
process = orm.QueryBuilder().append(orm.ProcessNode).first(flat=True)
print(process)
and also use {py:class}~aiida.tools.visualization.graph.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