Skip to content

Commit

Permalink
Only use ephemeral URIs when we need them in get_many_uris
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Sep 6, 2024
1 parent c2c7073 commit e14eae1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions python/lsst/daf/butler/datastores/chainedDatastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,8 @@ def getManyURIs(
# Docstring inherited

uris: dict[DatasetRef, DatasetRefURIs] = {}
ephemeral_uris: dict[DatasetRef, DatasetRefURIs] = {}

missing_refs = set(refs)

# If predict is True we don't want to predict a dataset in the first
Expand All @@ -666,11 +668,23 @@ def getManyURIs(
except NotImplementedError:
# some datastores may not implement generating URIs
continue
if datastore.isEphemeral:
# Only use these as last resort so do not constrain
# subsequent queries.
ephemeral_uris.update(got_uris)
continue

missing_refs -= got_uris.keys()
uris.update(got_uris)
if not missing_refs:
break

if missing_refs and ephemeral_uris:
ephemeral_refs = missing_refs.intersection(ephemeral_uris.keys())
for ref in ephemeral_refs:
uris[ref] = ephemeral_uris[ref]
missing_refs.remove(ref)

if missing_refs and not allow_missing:
raise FileNotFoundError(f"Dataset(s) {missing_refs} not in this datastore.")

Expand Down

0 comments on commit e14eae1

Please sign in to comment.