From 8dfcee82a45aad39965aa6661736aa831fab2286 Mon Sep 17 00:00:00 2001 From: "David H. Irving" Date: Wed, 11 Dec 2024 16:05:06 -0700 Subject: [PATCH] Rename cache class --- .../datasets/byDimensions/_dataset_type_cache.py | 4 ++-- .../butler/registry/datasets/byDimensions/tables.py | 12 +++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/python/lsst/daf/butler/registry/datasets/byDimensions/_dataset_type_cache.py b/python/lsst/daf/butler/registry/datasets/byDimensions/_dataset_type_cache.py index 064107cded..efc48d3870 100644 --- a/python/lsst/daf/butler/registry/datasets/byDimensions/_dataset_type_cache.py +++ b/python/lsst/daf/butler/registry/datasets/byDimensions/_dataset_type_cache.py @@ -33,7 +33,7 @@ from ...._dataset_type import DatasetType from ....dimensions import DimensionGroup -from .tables import DynamicTables, DynamicTablesCache +from .tables import DynamicTables, TableCache class DatasetTypeCache: @@ -54,7 +54,7 @@ class DatasetTypeCache: """ def __init__(self) -> None: - self.tables = DynamicTablesCache() + self.tables = TableCache() self._by_name_cache: dict[str, tuple[DatasetType, int]] = {} self._by_dimensions_cache: dict[DimensionGroup, DynamicTables] = {} self._full = False diff --git a/python/lsst/daf/butler/registry/datasets/byDimensions/tables.py b/python/lsst/daf/butler/registry/datasets/byDimensions/tables.py index 7254c8d104..8864cc451f 100644 --- a/python/lsst/daf/butler/registry/datasets/byDimensions/tables.py +++ b/python/lsst/daf/butler/registry/datasets/byDimensions/tables.py @@ -451,7 +451,7 @@ def makeCalibTableSpec( return tableSpec -DynamicTablesCache: TypeAlias = ThreadSafeCache[str, sqlalchemy.Table] +TableCache: TypeAlias = ThreadSafeCache[str, sqlalchemy.Table] @immutable @@ -519,7 +519,7 @@ def from_dimensions_key( calibs_name=makeCalibTableName(dimensions_key) if is_calibration else None, ) - def create(self, db: Database, collections: type[CollectionManager], cache: DynamicTablesCache) -> None: + def create(self, db: Database, collections: type[CollectionManager], cache: TableCache) -> None: """Create the tables if they don't already exist. Parameters @@ -551,7 +551,7 @@ def create(self, db: Database, collections: type[CollectionManager], cache: Dyna ) def add_calibs( - self, db: Database, collections: type[CollectionManager], cache: DynamicTablesCache + self, db: Database, collections: type[CollectionManager], cache: TableCache ) -> DynamicTables: """Create a calibs table for a dataset type whose dimensions already have a tags table. @@ -577,9 +577,7 @@ def add_calibs( return self.copy(calibs_name=calibs_name) - def tags( - self, db: Database, collections: type[CollectionManager], cache: DynamicTablesCache - ) -> sqlalchemy.Table: + def tags(self, db: Database, collections: type[CollectionManager], cache: TableCache) -> sqlalchemy.Table: """Return the "tags" table that associates datasets with data IDs in TAGGED and RUN collections. @@ -612,7 +610,7 @@ def tags( return cache.set_or_get(self.tags_name, table) def calibs( - self, db: Database, collections: type[CollectionManager], cache: DynamicTablesCache + self, db: Database, collections: type[CollectionManager], cache: TableCache ) -> sqlalchemy.Table: """Return the "calibs" table that associates datasets with data IDs and timespans in CALIBRATION collections.