ClusteredQuantumGraph

class lsst.ctrl.bps.ClusteredQuantumGraph(name, qgraph, qgraph_filename=None, butler_uri=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:
name : str

Name to be given to the ClusteredQuantumGraph.

qgraph : lsst.pipe.base.QuantumGraph

The QuantumGraph to be clustered.

qgraph_filename : str

Filename for given QuantumGraph if it has already been serialized.

butler_uri : str

Location of butler repo used to create the QuantumGraph.

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:
parent : str or QuantaCluster

Parent cluster.

child : str or QuantaCluster

Child cluster.

Raises:
KeyError

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

clusters()

Iterate over clusters.

Returns:
clusters : Iterator [lsst.ctrl.bps.QuantaCluster]

Iterator over clusters.

draw(filename, format_=None)

Draw the ClusteredQuantumGraph in a given format.

Parameters:
filename : str

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:
name : str

Name of cluster to retrieve.

Returns:
cluster : QuantaCluster

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_node : lsst.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:
filename : str

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:
ClusteredQuantumGraph : lsst.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:
name : str

Name of cluster for which need the predecessors.

Returns:
clusters : Iterator [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:
filename : str

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:
name : str

Name of cluster for which need the successors.

Returns:
clusters : Iterator [lsst.ctrl.bps.QuantaCluster]

Iterator over successors of given cluster.