Warning: This document is for an old version of Pydra: A simple dataflow engine with scalable semantics. The main version is master.

pydra.engine.graph module

Data structure to support Workflow tasks.

class pydra.engine.graph.DiGraph(name=None, nodes=None, edges=None)

Bases: object

A simple Directed Graph object.

add_edges(new_edges)

Add new edges and sort the new graph.

add_edges_description(new_edge_details)

adding detailed description of the connections, filling _nodes_details

add_nodes(new_nodes)

Insert new nodes and sort the new graph.

calculate_max_paths()

Calculate maximum paths.

Maximum paths are calculated between any node without “history” (no predecessors) and all of the connections.

copy()

Duplicate this graph.

Create a copy that contains new lists and dictionaries, but runnable objects are the same.

create_dotfile_detailed(outdir, name='graph_det')

creates a detailed dotfile (detailed connections - input/output fields, but no nested structure)

create_dotfile_nested(outdir, name='graph')

dotfile that includes the nested structures for workflows

create_dotfile_simple(outdir, name='graph')

creates a simple dotfile (no nested structure)

property edges

Get a list of the links between nodes.

property edges_names

Get edges as pairs of the nodes they connect.

export_graph(dotfile, ext='png')

exporting dotfile to other format, equires the dot command

property nodes

Get a list of the nodes currently contained in the graph.

property nodes_details

dictionary with details of the nodes for each task, there are inputs/outputs and connections (with input/output fields names)

property nodes_names_map

Get a map of node names to nodes.

remove_nodes(nodes, check_ready=True)

Mark nodes for removal from the graph, re-sorting if needed.

Important

This method does not remove connections, see remove_node_connections(). Nodes are added to the _node_wip list, marking them for removal when all referring connections are removed.

Parameters:
  • nodes (list) – List of nodes to be marked for removal.

  • check_ready (:obj: bool) – checking if the node is ready to be removed

remove_nodes_connections(nodes)

Remove connections between nodes.

Also prunes the nodes from _node_wip.

Parameters:

nodes (list) – List of nodes which connections are to be removed.

remove_previous_connections(nodes)

Remove connections that the node has with predecessors.

Also prunes the nodes from _node_wip.

Parameters:

nodes (list) – List of nodes which connections are to be removed.

remove_successors_nodes(node)

Removing all the nodes that follow the node

property sorted_nodes

Return sorted nodes (runs sorting if needed).

property sorted_nodes_names

Return a list of sorted nodes names.

sorting(presorted=None)

Sort this graph.

Sorting starts either from self.nodes or the previously sorted list.

Parameters:

presorted (list) – A list of previously sorted nodes.