aim2dat.aiida_workflows.workflow_builder

WorkflowBuilder and auxiliary functions.

Module Contents

Classes

MultipleWorkflowBuilder

Workflow builder that can manage a worklfow for several parent nodes at once.

WorkflowBuilder

Class to manage complex AiiDA workflows.

Attributes

AiidaCode

exception aim2dat.aiida_workflows.workflow_builder.WorkflowProtocolError[source]

Bases: Exception

Error for incomplete or inconsistent workflow protocols.

class args

Overview

Methods

with_traceback()

Exception.with_traceback(tb) –

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class aim2dat.aiida_workflows.workflow_builder.MultipleWorkflowBuilder(aiida_group=None, protocol=None, graph_attributes={'graph_attr': {'size': '10!,6'}}, use_uuid=False)[source]

Bases: _BaseWorkflowBuilder

Workflow builder that can manage a worklfow for several parent nodes at once.

Overview

Properties

aiida_group

Only consider processes in the AiiDA group.

graph_attributes

Graphiz graph attributes for the provenance graph.

protocol

Protocol used for the workflow.

task_queue

Return the task queue.

tasks

Return all tasks of the workflow.

use_uuid

Whether to use the uuid (str) to represent AiiDA nodes instead of the primary key

user_input

Input parameters set by the user.

Methods

add_parent_node(parent_node)

Add new parent node.

add_to_task_queue(task_label, run_type)

Add a task to the task queue.

adopt_input_nodes_from_workflow(parent_node)

Import input parameters for the workflow based on another parent node.

execute_task_queue(interval, node_ids)

Execute a series of AiiDA processes for several tasks consecutively for all parent nodes

from_file(file_name)

class -

generate_inputs(parent_node, task)

Generate a dictionary or builder for a certain task of the workflow for a specific parent

generate_provenance_graph(parent_node_index)

Generate provenance graph of the workflow.

import_parent_nodes_from_aiida_db(group_labels)

Import parent nodes from the AiiDA database.

import_parent_nodes_from_pandas_df(data_frame, parent_node)

Extract parent nodes from a pandas data frame. The data frame needs to have a column

reset_task_queue()

Reset the task queue.

return_process_nodes()

Return a pandas data frame containing the process nodes of all completed tasks.

return_results(include, exclude)

Return a pandas data frame containing the calculated results of all completed tasks.

return_runtimes(unit)

Return a pandas data frame containing the runtimes of all completed tasks.

return_workflow_states(unformatted)

Return a pandas data frame containing the current state of workflow.

run_task(task_label, interval, node_ids)

Run the AiiDA processes of the task for all parent nodes.

set_user_input(input_port, value)

Set a user input parameter of the workflow for all parent nodes.

submit_task(task_label, interval, node_ids)

Submit the AiiDA processes of the task for all parent nodes.

to_file(file_name)

-

property aiida_group

Only consider processes in the AiiDA group.

Type:

str or aiida.orm.Group

property graph_attributes

Graphiz graph attributes for the provenance graph.

property protocol

Protocol used for the workflow.

property task_queue

Return the task queue.

property tasks

Return all tasks of the workflow.

property use_uuid

Whether to use the uuid (str) to represent AiiDA nodes instead of the primary key (int).

Type:

bool

property user_input

Input parameters set by the user.

add_parent_node(parent_node)[source]

Add new parent node.

Parameters:

parent_node (aiida.orm.Node)

add_to_task_queue(task_label, run_type='run')[source]

Add a task to the task queue.

Parameters:
  • task_label (str) – Label of the task.

  • run_type (str (optional)) – Run type of the process, either run or submit. The default value is run.

adopt_input_nodes_from_workflow(parent_node)[source]

Import input parameters for the workflow based on another parent node.

Parameters:

parent_node (aiida.node) – Parent AiiDA node.

execute_task_queue(interval=None, node_ids=None)[source]

Execute a series of AiiDA processes for several tasks consecutively for all parent nodes as defined in the task_queue attribute.

Parameters:
  • interval (tuple (optional)) – Lower and upper bound of the interval of workflows that are executed. None to run all workflows. The default value is None.

  • node_ids (list (optional)) – List of primary keys or uuids of the parent nodes of the workflows that are started. None to run all workflows.

classmethod from_file(file_name='workflow.yaml')
generate_inputs(parent_node, task)[source]

Generate a dictionary or builder for a certain task of the workflow for a specific parent node.

Parameters:
  • parent_node (aiida.orm.node or str or int) – Uuid, primary key or the AiiDA node itself.

  • task (str) – Task label.

generate_provenance_graph(parent_node_index)[source]

Generate provenance graph of the workflow.

Returns:

aiida.tools.visualization.graph.Graph – Provenance graph.

import_parent_nodes_from_aiida_db(group_labels)[source]

Import parent nodes from the AiiDA database.

Parameters:

group_labels (str or list) – AiiDA group label or list of group labels.

import_parent_nodes_from_pandas_df(data_frame, parent_node='structure_node')[source]

Extract parent nodes from a pandas data frame. The data frame needs to have a column called ‘aiida_uuid’ with the universally unique identifier (uuid) of the nodes.

Parameters:
  • data_frame (pandas.DataFrame) – Pandas data frame containing the uuids, primary keys of the AiiDA nodes or the AiiDA nodes themselves.

  • parent_node (str (optional)) – Label of the column containing the parent nodes for the workflow. The default value is 'structure_node'.

reset_task_queue()[source]

Reset the task queue.

return_process_nodes()[source]

Return a pandas data frame containing the process nodes of all completed tasks.

Returns:

pandas.DataFrame – Pandas data frame.

return_results(include='all', exclude=[])[source]

Return a pandas data frame containing the calculated results of all completed tasks.

Parameters:
  • include (list or str (optional)) – List of results that are included in the pandas data frame. The value 'all' returns all results. The default value is 'all'.

  • exclude (list (optional)) – List of results that are excluded in the pandas data frame. The default value is [].

Returns:

pandas.DataFrame – Pandas data frame.

return_runtimes(unit=None)[source]

Return a pandas data frame containing the runtimes of all completed tasks.

Returns:

pandas.DataFrame – Pandas data frame.

return_workflow_states(unformatted=False)[source]

Return a pandas data frame containing the current state of workflow.

Paramters

unformattedbool (optional)

If set to True an unformatted pandas.DataFrame object is returned otherwise a pandas.Styler object is returned.

returns:

pandas.DataFrame or pandas.Styler – Pandas data frame.

run_task(task_label, interval=None, node_ids=None)[source]

Run the AiiDA processes of the task for all parent nodes.

Parameters:
  • task_label (str) – Label of the workflow task.

  • interval (tuple (optional)) – Lower and upper bound of the interval of workflows that are submitted. None to run all workflows. The default value is None.

  • node_ids (list (optional)) – List of primary keys or uuids of the parent nodes of the workflows that are submitted. None to run all workflows.

set_user_input(input_port, value)[source]

Set a user input parameter of the workflow for all parent nodes.

Parameters:
  • input_port (str) – Input port of the Parameter.

  • value (variable) – Value of the input parameter.

submit_task(task_label, interval=None, node_ids=None)[source]

Submit the AiiDA processes of the task for all parent nodes.

Parameters:
  • task_label (str) – Label of the workflow task.

  • interval (tuple (optional)) – Lower and upper bound of the interval of workflows that are submitted. None to run all workflows. The default value is None.

  • node_ids (list (optional)) – List of primary keys or uuids of the parent nodes of the workflows that are submitted. None to run all workflows.

to_file(file_name='workflow.yaml')
class aim2dat.aiida_workflows.workflow_builder.WorkflowBuilder(parent_node=None, protocol=None, graph_attributes={'graph_attr': {'size': '10!,6'}}, use_uuid=False)[source]

Bases: _BaseWorkflowBuilder

Class to manage complex AiiDA workflows.

Overview

Properties

aiida_group

Only consider processes in the AiiDA group.

completed_tasks

Completed tasks.

failed_tasks

Failed tasks.

parent_node

Parent AiiDA node.

protocol

Protocol used for the workflow.

results

Results of the workflow.

running_tasks

Tasks which have not yet finished.

tasks

Return all tasks of the workflow.

use_uuid

Whether to use the uuid (str) to represent AiiDA nodes instead of the primary key

user_input

Input parameters set by the user.

Methods

adopt_input_nodes_from_workflow(parent_node)

Import input parameters for the workflow based on another parent node.

determine_workflow_state()

Determine which tasks of the workflow have been completed and which ones can be started

from_file(file_name)

class -

generate_inputs(task)

Generate a builder for an AiiDA work chain or calculation job.

generate_provenance_graph()

Generate provenance graph of the workflow.

run_task(task)

Run the underlying AiiDA process of the task.

set_user_input(input_port, value)

Set user input parameters of the workflow.

submit_task(task)

Submit the underlying AiiDA process of the task.

to_file(file_name)

-

property aiida_group

Only consider processes in the AiiDA group.

Type:

str or aiida.orm.Group

property completed_tasks

Completed tasks.

property failed_tasks

Failed tasks.

property parent_node

Parent AiiDA node.

property protocol

Protocol used for the workflow.

property results

Results of the workflow.

property running_tasks

Tasks which have not yet finished.

property tasks

Return all tasks of the workflow.

property use_uuid

Whether to use the uuid (str) to represent AiiDA nodes instead of the primary key (int).

Type:

bool

property user_input

Input parameters set by the user.

adopt_input_nodes_from_workflow(parent_node)[source]

Import input parameters for the workflow based on another parent node.

Parameters:

parent_node (aiida.node) – Parent AiiDA node.

determine_workflow_state()[source]

Determine which tasks of the workflow have been completed and which ones can be started next.

classmethod from_file(file_name='workflow.yaml')
generate_inputs(task)[source]

Generate a builder for an AiiDA work chain or calculation job.

Parameters:

task (str) – Workflow task.

Returns:

builder (aiida.work_chain or dict) – If the underlying AiiDA process is a work chain the builder of the work chain is returnedBuilder, otherwise a dictionary of the input parameters and the process is returned.

generate_provenance_graph()[source]

Generate provenance graph of the workflow.

Returns:

aiida.tools.visualization.graph.Graph – Provenance graph.

run_task(task)[source]

Run the underlying AiiDA process of the task.

Parameters:

task (str) – Workflow task.

Returns:

  • proc_node (aiida.node) – AiiDA process node.

  • result (aiida.node) – Results of the AiiDA process.

set_user_input(input_port, value)[source]

Set user input parameters of the workflow.

Parameters:
  • input_port (str) – Input port of the parameter.

  • value – Value.

submit_task(task)[source]

Submit the underlying AiiDA process of the task.

Parameters:

task (str) – Workflow task.

Returns:

proc_node (aiida.node) – AiiDA process node.

to_file(file_name='workflow.yaml')
aim2dat.aiida_workflows.workflow_builder.AiidaCode