Skip to content

Commit

Permalink
Check Universe compatibility with Graph
Browse files Browse the repository at this point in the history
If a DimensionUniverse is supplied, check that it is compatible
with the one saved in the graph.
  • Loading branch information
natelust committed Jul 12, 2022
1 parent 0b6582a commit d915d8a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
8 changes: 6 additions & 2 deletions python/lsst/pipe/base/graph/_loadHelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,9 @@ def load(
universe: `~lsst.daf.butler.DimensionUniverse` or None
DimensionUniverse instance, not used by the method itself but
needed to ensure that registry data structures are initialized.
If None the universe saved with the graph is used if possible,
otherwise the global universe is used.
The universe saved with the graph is used, but if one is passed
it will be used to validate the compatibility with the loaded
graph universe.
nodes : `Iterable` of `UUID` or `str`; or `None`
The nodes to load from the graph, loads all if value is None
(the default)
Expand All @@ -240,6 +241,9 @@ def load(
Raised if one or more of the nodes requested is not in the
`QuantumGraph` or if graphID parameter does not match the graph
being loaded.
RuntimeError
Raise if Supplied DimensionUniverse is not compatible with the
DimensionUniverse saved in the graph
"""
# verify this is the expected graph
if graphID is not None and self.headerInfo._buildId != graphID:
Expand Down
7 changes: 6 additions & 1 deletion python/lsst/pipe/base/graph/_versionDeserializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,12 @@ def constructGraph(
taskToQuantumNode: DefaultDict[TaskDef, Set[QuantumNode]] = defaultdict(set)
recontitutedDimensions: Dict[int, Tuple[str, DimensionRecord]] = {}

if universe is None:
if universe is not None:
if not universe.checkCompatibility(self.infoMappings.universe):
raise RuntimeError(
"The saved dimension universe is not compatible with the supplied universe"
)
else:
universe = self.infoMappings.universe

for node in nodes:
Expand Down
13 changes: 9 additions & 4 deletions python/lsst/pipe/base/graph/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,8 +759,9 @@ def loadUri(
universe: `~lsst.daf.butler.DimensionUniverse` optional
DimensionUniverse instance, not used by the method itself but
needed to ensure that registry data structures are initialized.
If None it is loaded from the QuantumGraph saved structure. Only
pass this argument to overload explicitly.
If None it is loaded from the QuantumGraph saved structure. If
supplied, the DimensionUniverse from the loaded `QuantumGraph`
will be validated against the supplied argument for compatibility.
nodes: iterable of `int` or None
Numbers that correspond to nodes in the graph. If specified, only
these nodes will be loaded. Defaults to None, in which case all
Expand Down Expand Up @@ -790,6 +791,9 @@ def loadUri(
`QuantumGraph` or if graphID parameter does not match the graph
being loaded or if the supplied uri does not point at a valid
`QuantumGraph` save file.
RuntimeError
Raise if Supplied DimensionUniverse is not compatible with the
DimensionUniverse saved in the graph
Notes
Expand Down Expand Up @@ -1036,8 +1040,9 @@ def load(
universe: `~lsst.daf.butler.DimensionUniverse`, optional
DimensionUniverse instance, not used by the method itself but
needed to ensure that registry data structures are initialized.
If None it is loaded from the QuantumGraph saved structure. Only
pass this argument to overload explicitly.
If None it is loaded from the QuantumGraph saved structure. If
supplied, the DimensionUniverse from the loaded `QuantumGraph`
will be validated against the supplied argument for compatibility.
nodes: iterable of `int` or None
Numbers that correspond to nodes in the graph. If specified, only
these nodes will be loaded. Defaults to None, in which case all
Expand Down

0 comments on commit d915d8a

Please sign in to comment.