QuantumGraph

class lsst.pipe.base.QuantumGraph(iterable=None)

Bases: list

QuantumGraph is a sequence of QuantumGraphTaskNodes objects.

Typically the order of the tasks in the list will be the same as the order of tasks in a pipeline (obviously depends on the code which constructs graph).

Parameters:
iterable : iterable of QuantumGraphTaskNodes, optional

Initial sequence of per-task nodes.

Methods Summary

append($self, object, /) Append object to the end of the list.
clear($self, /) Remove all items from list.
copy($self, /) Return a shallow copy of the list.
count($self, value, /) Return number of occurrences of value.
countQuanta() Return total count of quanta in a graph.
extend($self, iterable, /) Extend list by appending elements from the iterable.
index($self, value[, start, stop]) Return first index of value.
insert($self, index, object, /) Insert object before index.
load(file, universe) Read QuantumGraph from a file that was made by save.
pop($self[, index]) Remove and return item at index (default last).
quanta() Iterator over quanta in a graph.
quantaAsQgraph() Iterator over quanta in a graph.
remove($self, value, /) Remove first occurrence of value.
reverse($self, /) Reverse IN PLACE.
save(file) Save QuantumGraph to a file.
sort($self, /, *[, key, reverse]) Stable sort IN PLACE.
traverse() Return topologically ordered Quanta and their dependencies.

Methods Documentation

append($self, object, /)

Append object to the end of the list.

clear($self, /)

Remove all items from list.

copy($self, /)

Return a shallow copy of the list.

count($self, value, /)

Return number of occurrences of value.

countQuanta()

Return total count of quanta in a graph.

Returns:
count : int

Number of quanta in a graph.

extend($self, iterable, /)

Extend list by appending elements from the iterable.

index($self, value, start=0, stop=sys.maxsize, /)

Return first index of value.

Raises ValueError if the value is not present.

insert($self, index, object, /)

Insert object before index.

classmethod load(file, universe)

Read QuantumGraph from a file that was made by save.

Parameters:
file : io.BufferedIOBase

File with pickle data open in binary mode.

universe: `~lsst.daf.butler.DimensionUniverse`

DimensionUniverse instance, not used by the method itself but needed to ensure that registry data structures are initialized.

Returns:
graph : QuantumGraph

Resulting QuantumGraph instance.

Raises:
TypeError

Raised if pickle contains instance of a type other than QuantumGraph.

Notes

Reading Quanta from pickle requires existence of singleton DimensionUniverse which is usually instantiated during Registry initializaion. To make sure that DimensionUniverse exists this method accepts dummy DimensionUniverse argument.

pop($self, index=-1, /)

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

quanta()

Iterator over quanta in a graph.

Quanta are returned in unspecified order.

Yields:
taskDef : TaskDef

Task definition for a Quantum.

quantum : Quantum

Single quantum.

quantaAsQgraph()

Iterator over quanta in a graph.

QuantumGraph containing individual quanta are returned.

Yields:
graph : QuantumGraph
remove($self, value, /)

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse($self, /)

Reverse IN PLACE.

save(file)

Save QuantumGraph to a file.

Presently we store QuantumGraph in pickle format, this could potentially change in the future if better format is found.

Parameters:
file : io.BufferedIOBase

File to write pickle data open in binary mode.

sort($self, /, *, key=None, reverse=False)

Stable sort IN PLACE.

traverse()

Return topologically ordered Quanta and their dependencies.

This method iterates over all Quanta in topological order, enumerating them during iteration. Returned QuantumIterData object contains Quantum instance, its index and the index of all its prerequsites (Quanta that produce inputs for this Quantum):

  • the index values are generated by an iteration of a QuantumGraph, and are not intrinsic to the QuantumGraph
  • during iteration, each ID will appear in index before it ever appears in dependencies.
Yields:
quantumData : QuantumIterData