ClusteredQuantumGraph

class lsst.ctrl.bps.ClusteredQuantumGraph(name: str, qgraph: PredictedQuantumGraph, qgraph_filename: str)

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.quantum_graph.PredictedQuantumGraph

The quantum graph to be clustered.

qgraph_filenamestr

Filename for given quantum graph.

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 quantum graph associated with this Clustered QuantumGraph.

qxgraph

A networkx graph of all quanta.

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_info(id_)

Retrieve a quantum info dict 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.

validate()

Check correctness of completed ClusteredQuantumGraph.

Attributes Documentation

name

The name of the ClusteredQuantumGraph.

qgraph

The quantum graph associated with this Clustered QuantumGraph.

qxgraph

A networkx graph of all quanta.

Methods Documentation

add_cluster(clusters_for_adding)

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

Parameters:
clusters_for_addingQuantaCluster 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_info(id_: UUID) QuantumInfo

Retrieve a quantum info dict from the ClusteredQuantumGraph by ID.

Parameters:
id_uuid.UUID

ID of the quantum to retrieve.

Returns:
quantum_infolsst.pipe.base.quantum_graph.QuantumInfo

Quantum info dictionary for the given ID.

Raises:
KeyError

Raised if the ClusteredQuantumGraph does not contain a quantum 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 quantum graph is assumed to have been saved separately.

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.

validate()

Check correctness of completed ClusteredQuantumGraph.

Raises:
RuntimeError

If the ClusteredQuantumGraph is not valid.