Skip to content

Commit

Permalink
Fall back on exists() if datastore doesn't know about the deferred ref
Browse files Browse the repository at this point in the history
This is needed for execution butler where datastore doesn't
know about files that do exist.
  • Loading branch information
timj committed Aug 17, 2023
1 parent 17191b8 commit 5732892
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions python/lsst/daf/butler/_butler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1341,9 +1341,14 @@ def getDeferred(
Raised if no collections were provided.
"""
if isinstance(datasetRefOrType, DatasetRef):
if not self._datastore.knows(datasetRefOrType):
# Do the quick check first and if that fails, check for artifact
# existence. This is necessary for datastores that are configured
# in trust mode where there won't be a record but there will be
# a file.
if self._datastore.knows(datasetRefOrType) or self._datastore.exists(datasetRefOrType):
ref = datasetRefOrType
else:
raise LookupError(f"Dataset reference {datasetRefOrType} does not exist.")
ref = datasetRefOrType
else:
ref = self._findDatasetRef(datasetRefOrType, dataId, collections=collections, **kwargs)
return DeferredDatasetHandle(butler=self, ref=ref, parameters=parameters, storageClass=storageClass)
Expand Down

0 comments on commit 5732892

Please sign in to comment.