ClusteredQuantumGraph

class lsst.ctrl.bps.ClusteredQuantumGraph(name, qgraph, qgraph_filename=None)

Bases: object

Graph where the data for a node is a subgraph of the full QuantumGraph represented by a list of node ids.

Parameters:
namestr

Name to be given to the ClusteredQuantumGraph.

qgraphlsst.pipe.base.QuantumGraph

The QuantumGraph to be clustered.

qgraph_filenamestr

Filename for given QuantumGraph if it has already been serialized.

Raises:
ValueError

Raised if invalid name (e.g., name contains /)

Notes

Using lsst.pipe.base.NodeId instead of integer because the QuantumGraph API requires them. Chose skipping the repeated creation of objects to use API over totally minimized memory usage.

Attributes Summary

name

The name of the ClusteredQuantumGraph.

qgraph

The QuantumGraph associated with this Clustered QuantumGraph.

Methods Summary

add_cluster(clusters_for_adding)

Add a cluster of quanta as a node in the graph.

add_dependency(parent, child)

Add a directed dependency between a parent cluster and a child

clusters()

Iterate over clusters.

draw(filename[, format_])

Draw the ClusteredQuantumGraph in a given format.

get_cluster(name)

Retrieve a cluster from the ClusteredQuantumGraph by name.

get_quantum_node(id_)

Retrieve a QuantumNode from the ClusteredQuantumGraph by ID.

load(filename[, format_])

Load a ClusteredQuantumGraph from the given file.

predecessors(name)

Return clusters that are predecessors of the cluster with the given name.

save(filename[, format_])

Save the ClusteredQuantumGraph in a format that is loadable.

successors(name)

Return clusters that are successors of the cluster with the given name.

Attributes Documentation

name

The name of the ClusteredQuantumGraph.

qgraph

The QuantumGraph associated with this Clustered QuantumGraph.

Methods Documentation

add_cluster(clusters_for_adding)

Add a cluster of quanta as a node in the graph.

Parameters:
clusters_for_adding: `QuantaCluster` or `Iterable` [`QuantaCluster`]

The cluster to be added to the ClusteredQuantumGraph.

add_dependency(parent, child)
Add a directed dependency between a parent cluster and a child

cluster.

Parameters:
parentstr or QuantaCluster

Parent cluster.

childstr or QuantaCluster

Child cluster.

Raises:
KeyError

Raised if either the parent or child doesn’t exist in the ClusteredQuantumGraph.

clusters()

Iterate over clusters.

Returns:
clustersIterator [lsst.ctrl.bps.QuantaCluster]

Iterator over clusters in topological order.

draw(filename, format_=None)

Draw the ClusteredQuantumGraph in a given format.

Parameters:
filenamestr

File to which the ClusteredQuantumGraph should be serialized.

format_str, optional

Format in which to draw the data. It defaults to dot format.

get_cluster(name)

Retrieve a cluster from the ClusteredQuantumGraph by name.

Parameters:
namestr

Name of cluster to retrieve.

Returns:
clusterQuantaCluster

QuantaCluster matching given name.

Raises:
KeyError

Raised if the ClusteredQuantumGraph does not contain a cluster with given name.

get_quantum_node(id_)

Retrieve a QuantumNode from the ClusteredQuantumGraph by ID.

Parameters:
id_lsst.pipe.base.NodeId or int

ID of the QuantumNode to retrieve.

Returns:
quantum_nodelsst.pipe.base.QuantumNode

QuantumNode matching given ID.

Raises:
KeyError

Raised if the ClusteredQuantumGraph does not contain a QuantumNode with given ID.

classmethod load(filename, format_=None)

Load a ClusteredQuantumGraph from the given file.

Parameters:
filenamestr

File from which to read the ClusteredQuantumGraph.

format_str, optional

Format of data to expect when loading from stream. It defaults to pickle format.

Returns:
ClusteredQuantumGraphlsst.ctrl.bps.ClusteredQuantumGraph

ClusteredQuantumGraph workflow loaded from the given file. The QuantumGraph is loaded from its own file specified in the saved ClusteredQuantumGraph.

predecessors(name)

Return clusters that are predecessors of the cluster with the given name.

Parameters:
namestr

Name of cluster for which need the predecessors.

Returns:
clustersIterator [lsst.ctrl.bps.QuantaCluster]

Iterator over predecessors of given cluster.

save(filename, format_=None)

Save the ClusteredQuantumGraph in a format that is loadable. The QuantumGraph is saved separately if hasn’t already been serialized.

Parameters:
filenamestr

File to which the ClusteredQuantumGraph should be serialized.

format_str, optional

Format in which to write the data. It defaults to pickle format.

successors(name)

Return clusters that are successors of the cluster with the given name.

Parameters:
namestr

Name of cluster for which need the successors.

Returns:
clustersIterator [lsst.ctrl.bps.QuantaCluster]

Iterator over successors of given cluster.