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:
- 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.
- name
- 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
The name of the ClusteredQuantumGraph.
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
orQuantaCluster
Parent cluster.
- child
str
orQuantaCluster
Child cluster.
- parent
- 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 in topological order.
- clusters
- draw(filename, format_=None)¶
Draw the ClusteredQuantumGraph in a given format.
- get_cluster(name)¶
Retrieve a cluster from the ClusteredQuantumGraph by name.
- Parameters:
- name
str
Name of cluster to retrieve.
- name
- Returns:
- cluster
QuantaCluster
QuantaCluster matching given name.
- cluster
- 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.
- id_
- Returns:
- quantum_node
lsst.pipe.base.QuantumNode
QuantumNode matching given ID.
- quantum_node
- 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:
- 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.
- 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.
- name
- Returns:
- clusters
Iterator
[lsst.ctrl.bps.QuantaCluster
] Iterator over predecessors of given cluster.
- clusters
- save(filename, format_=None)¶
Save the ClusteredQuantumGraph in a format that is loadable. The QuantumGraph is saved separately if hasn’t already been serialized.
- 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.
- name
- Returns:
- clusters
Iterator
[lsst.ctrl.bps.QuantaCluster
] Iterator over successors of given cluster.
- clusters