Skip to content

Commit

Permalink
Use FileNotFoundError with NullDatastore.get() and getURI
Browse files Browse the repository at this point in the history
This makes it match the other datastores when the dataset
is not present.
  • Loading branch information
timj committed Jul 21, 2023
1 parent 038055c commit a926967
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions python/lsst/daf/butler/core/datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,7 @@ def get(
parameters: Mapping[str, Any] | None = None,
storageClass: StorageClass | str | None = None,
) -> Any:
raise NotImplementedError("This is a no-op datastore that can not access a real datastore")
raise FileNotFoundError("This is a no-op datastore that can not access a real datastore")

def put(self, inMemoryDataset: Any, datasetRef: DatasetRef) -> None:
raise NotImplementedError("This is a no-op datastore that can not access a real datastore")
Expand All @@ -1265,10 +1265,10 @@ def transfer_from(
raise NotImplementedError("This is a no-op datastore that can not access a real datastore")

def getURIs(self, datasetRef: DatasetRef, predict: bool = False) -> DatasetRefURIs:
raise NotImplementedError("This is a no-op datastore that can not access a real datastore")
raise FileNotFoundError("This is a no-op datastore that can not access a real datastore")

def getURI(self, datasetRef: DatasetRef, predict: bool = False) -> ResourcePath:
raise NotImplementedError("This is a no-op datastore that can not access a real datastore")
raise FileNotFoundError("This is a no-op datastore that can not access a real datastore")

def retrieveArtifacts(
self,
Expand Down
4 changes: 3 additions & 1 deletion tests/test_butler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2377,8 +2377,10 @@ def test_fallback(self) -> None:
ref = DatasetRef(datasetType, {}, run="MYRUN")

# Check that datastore will complain.
with self.assertRaises(NotImplementedError):
with self.assertRaises(FileNotFoundError):
butler.get(ref)
with self.assertRaises(FileNotFoundError):
butler.getURI(ref)


def setup_module(module: types.ModuleType) -> None:
Expand Down
8 changes: 4 additions & 4 deletions tests/test_datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -1762,15 +1762,15 @@ def test_basics(self) -> None:
self.assertFalse(knows[ref])
null.validateConfiguration(ref)

with self.assertRaises(NotImplementedError):
with self.assertRaises(FileNotFoundError):
null.get(ref)
with self.assertRaises(NotImplementedError):
null.put("", ref)
with self.assertRaises(NotImplementedError):
with self.assertRaises(FileNotFoundError):
null.getURI(ref)
with self.assertRaises(NotImplementedError):
with self.assertRaises(FileNotFoundError):
null.getURIs(ref)
with self.assertRaises(NotImplementedError):
with self.assertRaises(FileNotFoundError):
null.getManyURIs([ref])
with self.assertRaises(NotImplementedError):
null.getLookupKeys()
Expand Down

0 comments on commit a926967

Please sign in to comment.