pydra.engine.graph module
Data structure to support Workflow
tasks.
- class pydra.engine.graph.DiGraph(name=None, nodes=None, edges=None)[source]
Bases:
object
A simple Directed Graph object.
- add_edges_description(new_edge_details)[source]
adding detailed description of the connections, filling _nodes_details
- calculate_max_paths()[source]
Calculate maximum paths.
Maximum paths are calculated between any node without “history” (no predecessors) and all of the connections.
- copy()[source]
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')[source]
creates a detailed dotfile (detailed connections - input/output fields, but no nested structure)
- create_dotfile_nested(outdir, name='graph')[source]
dotfile that includes the nested structures for workflows
- 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')[source]
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)[source]
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)[source]
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)[source]
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.
- property sorted_nodes
Return sorted nodes (runs sorting if needed).
- property sorted_nodes_names
Return a list of sorted nodes names.