Skip to content

Workflow References

Stand-alone utilities

nodes_to_graph()

Builds a workflow graph (nx.DiGraph) from a NodeAttributesUniverse of node attributes as specified below.

Parameters:

Name Type Description Default
node_attributes_universe NodeAttributesUniverse

A NodeAttributesUniverse object containing the node

required

Returns:

Type Description
DiGraph

nx.DiGraph: description

User-relevant classes

NodeAttributes

Bases: BaseModel

NodeAttributes represents the attributes of a node in the NOMAD workflow graph.

Attributes:

Name Type Description
name str

A free-form string describing this node, which will be used as a label in the NOMAD workflow graph visualizer.

type Literal['input', 'output', 'workflow', 'task']

Specifies the type of node. Must be one of the specified options.

  • input: (meta)data taken as input for the entire workflow or a specific task. For simulations, often corresponds to a section within the archive (e.g., system, method).

  • output: (meta)data produced as output for the entire workflow or a specific task. For simulations, often corresponds to a section within the archive (e.g., calculation).

  • workflow: A node in the workflow which itself contains an internal (sub)workflow, that is recognized by NOMAD. Such nodes can be linked to existing workflows within NOMAD, providing functionalities within NOMAD's interactive workflow graphs.

  • task: A node in the workflow which represents an individual task (i.e., no underlying workflow), that is recognized by NOMAD.

entry_type Literal['simulation']

Specifies the type of node in terms of tasks or workflows recognized by NOMAD. Functionally, this attribute is used to create default inputs and outputs that are required for properly creating the edge visualizations in the NOMAD GUI.

path_info dict

Information for generating the NOMAD archive section paths (i.e., connections between nodes in terms of the NOMAD MetaInfo sections).

  • upload_id (str): NOMAD PID for the upload, if exists.

  • entry_id (str): NOMAD PID for the entry, if exists.

  • mainfile_path (str): Local (relative to the native upload) path to the mainfile, including the mainfile name with extension.

  • supersection_path (str): Archive path to the supersection, e.g., "run" or "workflow2/method".

  • supersection_index (int): The relevant index for the supersection, if it is a repeating subsection.

  • section_type (str): The name of the section for an input or output node, e.g., "system", "method", or "calculation".

  • section_index (int): The relevant index for the section, if it is a repeating subsection.

  • archive_path (str): Specifies the entire archive path to the section, e.g., "run/0/system/2".

inputs list[dict]

A list of input nodes to be added to the graph with in_edges to the parent node.

  • name (str): Will be set as the name for the input node created.

  • path_info (dict): Path information for the input node created, as specified for the node attributes above.

outputs list[dict]

A list of output nodes to be added to the graph with out_edges from the parent node.

  • name (str): Will be set as the name for the output node created.

  • path_info (dict): Path information for the output node created, as specified for the node attributes above.

in_edge_nodes list[int]

A list of integers specifying the node keys which contain in-edges to this node.

out_edge_nodes list[int]

A list of integers specifying the node keys which contain out-edges to this node.

get(key, default=None)

Allows dictionary-like access to the attributes of the NodeAttributes class.

Parameters:

Name Type Description Default
key str

The attribute name to retrieve.

required
default Any

The default value to return if the attribute is not found.

None

Returns:

Name Type Description
Any Any

The value of the attribute if it exists, otherwise the default value.

NodeAttributesUniverse

Bases: BaseModel

Container for all node attributes in a NOMAD workflow graph.

This class holds a mapping from node keys (integers) to their corresponding NodeAttributes objects, representing the full set of nodes in a workflow. It is used as the input for building the workflow graph and for serializing or deserializing workflow definitions.

Attributes:

Name Type Description
nodes dict[int, NodeAttributes]

Dictionary mapping node keys to their attributes.

NomadWorkflow

Bases: BaseModel

Represents a NOMAD workflow and provides methods to build and serialize it.

This class manages the workflow graph, node attributes, and the logic for constructing a NOMAD-compatible workflow archive. It supports registering nodes, resolving edges, adding default sections, and exporting the workflow to a YAML file for use with NOMAD systems.

Attributes:

Name Type Description
destination_filename str

Path to the output YAML file for the workflow archive.

m_def str

NOMAD m_def path for the workflow type.

name str

User-defined name for the workflow.

archive_section str

Root section of the archive to store the workflow.

node_attributes_universe NodeAttributesUniverse

Universe of node attributes for the workflow graph.

workflow_graph DiGraph

Directed graph representing the workflow structure.

task_elements dict[str, NomadSection]

Registered sections for each node in the workflow.

simulation_default_sections dict[str, list[str]]

Default input and output sections for simulation tasks.

build_workflow_yaml()

Construct and serialize the workflow archive to a YAML file.

This method registers all nodes in the workflow graph as sections, builds the internal task elements, generates the workflow archive, removes duplicate inputs/outputs, and writes the resulting archive to the YAML file specified by self.destination_filename. The resulting YAML file is compatible with the NOMAD workflow schema and can be used for further processing or import into NOMAD systems.

After writing the file, a summary message is logged with the output filename.