From 5732892e5e5e2c6ca0cf06fa9b0a416a98439771 Mon Sep 17 00:00:00 2001 From: Tim Jenness Date: Thu, 17 Aug 2023 16:01:59 -0700 Subject: [PATCH] Fall back on exists() if datastore doesn't know about the deferred ref This is needed for execution butler where datastore doesn't know about files that do exist. --- python/lsst/daf/butler/_butler.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/python/lsst/daf/butler/_butler.py b/python/lsst/daf/butler/_butler.py index c70c2e3780..c4e77de83a 100644 --- a/python/lsst/daf/butler/_butler.py +++ b/python/lsst/daf/butler/_butler.py @@ -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)