Skip to content

Commit

Permalink
Address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
natelust committed Jun 30, 2023
1 parent 5432818 commit ef41fb5
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
1 change: 0 additions & 1 deletion doc/changes/DM-39582.api.md

This file was deleted.

1 change: 1 addition & 0 deletions doc/changes/DM-39582.removal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deprecate reconstituteDimensions argument from `Quantum.from_simple`.
7 changes: 0 additions & 7 deletions python/lsst/daf/butler/core/datastoreRecordData.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ def direct(
This method should only be called when the inputs are trusted.
"""
key = frozenset(dataset_ids)
cache = PersistenceContextVars.serializedDatastoreRecordMapping.get()
if cache is not None and (value := cache.get(key)) is not None:
return value

data = SerializedDatastoreRecordData.__new__(cls)
setter = object.__setattr__
# JSON makes strings out of UUIDs, need to convert them back
Expand All @@ -89,8 +84,6 @@ def direct(
if (id := record.get("dataset_id")) is not None:
record["dataset_id"] = uuid.UUID(id) if isinstance(id, str) else id
setter(data, "records", records)
if cache is not None:
cache[key] = data
return data


Expand Down
8 changes: 1 addition & 7 deletions python/lsst/daf/butler/core/persistenceContext.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
if TYPE_CHECKING:
from .datasets.ref import DatasetRef
from .datasets.type import DatasetType, SerializedDatasetType
from .datastoreRecordData import DatastoreRecordData, SerializedDatastoreRecordData
from .datastoreRecordData import DatastoreRecordData
from .dimensions._coordinate import DataCoordinate, SerializedDataCoordinate
from .dimensions._records import DimensionRecord, SerializedDimensionRecord

Expand Down Expand Up @@ -99,12 +99,6 @@ class PersistenceContextVars:
r"""A cache of `SerializedDimensionRecord`\ s.
"""

serializedDatastoreRecordMapping: ContextVar[
dict[frozenset[str | uuid.UUID], SerializedDatastoreRecordData] | None
] = ContextVar("serializedDatastoreRecordMapping", default=None)
r"""A cache of `SerializedDatastoreRecord`\ s.
"""

loadedTypes: ContextVar[dict[tuple[str, str], DatasetType] | None] = ContextVar(
"loadedTypes", default=None
)
Expand Down
4 changes: 3 additions & 1 deletion python/lsst/daf/butler/core/quantum.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from typing import Any

from lsst.utils import doImportType
from lsst.utils.introspection import find_outside_stacklevel
from pydantic import BaseModel

from .datasets import DatasetRef, DatasetType, SerializedDatasetRef, SerializedDatasetType
Expand Down Expand Up @@ -416,7 +417,8 @@ def from_simple(
if reconstitutedDimensions is not None:
warnings.warn(
"The reconstitutedDimensions argument is now ignored and may be removed after v 27",
category=DeprecationWarning,
category=FutureWarning,
stacklevel=find_outside_stacklevel("lsst.daf.butler"),
)

# Unpersist all the init inputs
Expand Down
18 changes: 16 additions & 2 deletions python/lsst/daf/butler/transfers/_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import uuid
import warnings
from collections import defaultdict
from collections import UserDict, defaultdict
from collections.abc import Iterable, Mapping
from datetime import datetime
from typing import IO, TYPE_CHECKING, Any
Expand Down Expand Up @@ -64,7 +64,21 @@
this version of the code.
"""

_refIntId2UUID = defaultdict[int, uuid.UUID](uuid.uuid4)

class _RefMapper(UserDict[int, uuid.UUID]):
"""Create a local dict subclass which creates new deterministic UUID for
missing keys.
"""

_namespace = uuid.UUID("4d4851f4-2890-4d41-8779-5f38a3f5062b")

def __missing__(self, key: int) -> uuid.UUID:
newUUID = uuid.uuid3(namespace=self._namespace, name=str(key))
self[key] = newUUID
return newUUID


_refIntId2UUID = _RefMapper()


def _uuid_representer(dumper: yaml.Dumper, data: uuid.UUID) -> yaml.Node:
Expand Down

0 comments on commit ef41fb5

Please sign in to comment.