<jupyter_start><jupyter_text>Display provenance graph Plot the provenance graph for portions of the databaseTime: 2 mins<jupyter_code>from aiida import load_dbenv, is_dbenv_loaded
if not is_dbenv_loaded():
    load_dbenv()
from aiida.orm import load_node
from IPython.display import Image
import markdown
from pprint import pprint
def get_pk_from_uuid(uuid):
    return load_node(uuid).pk

def generate_graph(uuid):
    pk = get_pk_from_uuid(uuid)
    !verdi graph generate {pk} -f png
    return "{}.png".format(pk)<jupyter_output><empty_output><jupyter_text>Get the list of executed calculations<jupyter_code>!verdi calculation list -a<jupyter_output><empty_output><jupyter_text>Generate the graph for a calculation<jupyter_code>calculation_uuid = 'ce81c420-7751-48f6-af8e-eb7c6a30cec3'
png_file = generate_graph(calculation_uuid)<jupyter_output><empty_output><jupyter_text>Show the generated graph<jupyter_code>Image(filename=png_file)<jupyter_output><empty_output><jupyter_text>Load the node of the calculation and print its inputs<jupyter_code>calc = load_node(calculation_uuid)
calc.get_inputs(also_labels=True)<jupyter_output><empty_output><jupyter_text>Get the input structure of the calculation<jupyter_code>structure = calc.inp.structure<jupyter_output><empty_output><jupyter_text>Generate and show the graph of this input structure<jupyter_code>structure_png_filename = generate_graph(structure.pk)
Image(filename=structure_png_filename)<jupyter_output><empty_output><jupyter_text>Show the inputs of the structure<jupyter_code>structure.get_inputs(also_labels=True)<jupyter_output><empty_output><jupyter_text>List all the available structuresThis might be how you find the calculation that produced a structure of interest<jupyter_code>!verdi data structure list<jupyter_output><empty_output><jupyter_text>Generate the graph of an arbitrary structure and display it<jupyter_code>structure2_png_filename = generate_graph('2cfc7852-85de-4d25-93da-ee0fd39180c9')
Image(filename=structure2_png_filename)<jupyter_output><empty_output><jupyter_text>Load the calculation that has this structure as input and show its output parameters<jupyter_code>calc = load_node('ddf5a36d-06c2-4eb5-91ab-2b1603b43973')
print "Calculation PK: {}".format(calc.pk)
print pprint(calc.out.output_parameters.get_dict())<jupyter_output><empty_output><jupyter_text>You can also quickly display the graph from the command line if you only have a terminal<jupyter_code>!verdi work tree {calc.pk}<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08343313373253493, 'fraction_numerical': 0.023952095808383235, 'mean_word_length': 9.755364806866952, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '12', 'dir': 'jupyter-structured-clean-dedup', 'id': '315325', 'license': 'MIT', 'n_tokens_mistral': 878, 'n_tokens_neox': 838, 'n_words': 174, 'path': 'notebooks/graph_visualisation.ipynb', 'repo_name': 'd-tomerini/aiida_demos', 'size': '2505'}