Skip to content

Commit

Permalink
Check universe version before registering dataset type (DM-49180)
Browse files Browse the repository at this point in the history
A mismatch in the universe versions causes some unexpected issues,
sometimes silently. A simple version check before new dataset type
registration should solve some of the cases.
  • Loading branch information
andy-slac committed Feb 27, 2025
1 parent e74e7f7 commit ecdc398
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions python/lsst/daf/butler/registry/datasets/byDimensions/_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,21 @@ def register_dataset_type(self, dataset_type: DatasetType) -> bool:
raise ValueError(
f"Component dataset types can not be stored in registry. Rejecting {dataset_type.name}"
)

# If database universe and dimension group universe are different it
# can cause unexpected effects.
db_universe_version = (self._dimensions.universe.namespace, self._dimensions.universe.version)
dataset_type_universe_version = (
dataset_type.dimensions.universe.namespace,
dataset_type.dimensions.universe.version,
)
if dataset_type_universe_version != db_universe_version:
raise ValueError(

Check warning on line 329 in python/lsst/daf/butler/registry/datasets/byDimensions/_manager.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/daf/butler/registry/datasets/byDimensions/_manager.py#L329

Added line #L329 was not covered by tests
"Incompatible dimension universe versions - "
f"database version: {db_universe_version}, "
f"dataset type version: {dataset_type_universe_version}."
)

record = self._fetch_dataset_type_record(dataset_type.name)
if record is None:
if (dynamic_tables := self._cache.get_by_dimensions(dataset_type.dimensions)) is None:
Expand Down

0 comments on commit ecdc398

Please sign in to comment.