PredictedQuantumGraphComponents

class lsst.pipe.base.quantum_graph.PredictedQuantumGraphComponents(*, header: ~lsst.pipe.base.quantum_graph._common.HeaderModel = <factory>, pipeline_graph: ~lsst.pipe.base.pipeline_graph._pipeline_graph.PipelineGraph, dimension_data: ~lsst.daf.butler.dimensions._record_set.DimensionDataAttacher | None = None, init_quanta: ~lsst.pipe.base.quantum_graph._predicted.PredictedInitQuantaModel = <factory>, thin_graph: ~lsst.pipe.base.quantum_graph._predicted.PredictedThinGraphModel = <factory>, quantum_datasets: dict[uuid.UUID, lsst.pipe.base.quantum_graph._predicted.PredictedQuantumDatasetsModel] = <factory>, quantum_indices: dict[uuid.UUID, int] = <factory>)

Bases: object

A helper class for building and writing predicted quantum graphs.

Notes

This class is a simple struct of model classes to allow different tools that build predicted quantum graphs to assemble them in whatever order they prefer. It does not enforce any internal invariants (e.g. the quantum and dataset counts in the header, different representations of quanta, internal ID sorting, etc.), but it does provide methods that can satisfy them.

Attributes Summary

dimension_data

Object that can attach dimension records to data IDs.

Methods Summary

assemble()

Construct a PredictedQuantumGraph from these components.

from_old_quantum_graph(old_quantum_graph)

Construct from an old QuantumGraph instance.

read_execution_quanta(uri[, quantum_ids, ...])

Read one or more executable quanta from a quantum graph file.

set_header_counts()

Populate the quantum and dataset counts in the header from the quantum_indices, thin_graph, init_quanta, and quantum_datasets components.

set_quantum_indices()

Populate the quantum_indices component by sorting the UUIDs in the init_quanta and quantum_datasets components (which must both be complete).

set_thin_graph()

Populate the thin_graph component from the pipeline_graph, quantum_datasets and quantum_indices components (which must all be complete).

update_output_run(output_run)

Update the output RUN collection name in all datasets and regenerate all output dataset and quantum UUIDs.

write(uri, *[, zstd_level, zstd_dict_size, ...])

Write the graph to a file.

Attributes Documentation

dimension_data: DimensionDataAttacher | None = None

Object that can attach dimension records to data IDs.

Methods Documentation

assemble() PredictedQuantumGraph

Construct a PredictedQuantumGraph from these components.

classmethod from_old_quantum_graph(old_quantum_graph: QuantumGraph) PredictedQuantumGraphComponents

Construct from an old QuantumGraph instance.

Parameters:
old_quantum_graphQuantumGraph

Quantum graph to transform.

Returns:
componentsPredictedQuantumGraphComponents

Components for a new predicted quantum graph.

classmethod read_execution_quanta(uri: str | ParseResult | ResourcePath | Path, quantum_ids: Iterable[UUID] | None = None, page_size: int = 5000000) PredictedQuantumGraphComponents

Read one or more executable quanta from a quantum graph file.

Parameters:
uriconvertible to lsst.resources.ResourcePath

URI to open. Should have a .qg extension for new quantum graph files, or .qgraph for the old format.

quantum_idsIterable [ uuid.UUID ], optional

Iterable of quantum IDs to load. If not provided, all quanta will be loaded. The UUIDs of special init quanta will be ignored.

page_sizeint, optional

Approximate number of bytes to read at once from address files. Note that this does not set a page size for all reads, but it does affect the smallest, most numerous reads.

Returns:
componentsPredictedQuantumGraphComponents ]

Components for quantum graph that can build execution quanta for all of the given IDs.

set_header_counts() None

Populate the quantum and dataset counts in the header from the quantum_indices, thin_graph, init_quanta, and quantum_datasets components.

set_quantum_indices() None

Populate the quantum_indices component by sorting the UUIDs in the init_quanta and quantum_datasets components (which must both be complete).

set_thin_graph() None

Populate the thin_graph component from the pipeline_graph, quantum_datasets and quantum_indices components (which must all be complete).

update_output_run(output_run: str) None

Update the output RUN collection name in all datasets and regenerate all output dataset and quantum UUIDs.

Parameters:
output_runstr

New output RUN collection name.

write(uri: str | ParseResult | ResourcePath | Path, *, zstd_level: int = 10, zstd_dict_size: int = 32768, zstd_dict_n_inputs: int = 512) None

Write the graph to a file.

Parameters:
uriconvertible to lsst.resources.ResourcePath

Path to write to. Should have a .qg extension, or .qgraph to force writing the old format.

zstd_levelint, optional

ZStandard compression level to use on JSON blocks.

zstd_dict_sizeint, optional

Size of a ZStandard dictionary that shares compression information across components. Set to zero to disable the dictionary. Dictionary compression is automatically disabled if the number of quanta is smaller than zstd_dict_n_inputs.

zstd_dict_n_inputsint, optional

Maximum number of PredictedQuantumDatasetsModel JSON representations to feed the ZStandard dictionary training routine.

Notes

Only a complete predicted quantum graph with all components fully populated should be written.