Skip to content

Commit

Permalink
Complain if we try to export disassembled dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Apr 30, 2020
1 parent d89107d commit e340fdd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 6 additions & 2 deletions python/lsst/daf/butler/datastores/posixDatastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,13 @@ def export(self, refs: Iterable[DatasetRef], *,
directory: Optional[str] = None, transfer: Optional[str] = None) -> Iterable[FileDataset]:
# Docstring inherited from Datastore.export.
for ref in refs:
location, storedFileInfo = self._get_dataset_location_info(ref)
if location is None:
fileLocations = self._get_dataset_locations_info(ref)
if not fileLocations:
raise FileNotFoundError(f"Could not retrieve dataset {ref}.")
# For now we can not export disassembled datasets
if len(fileLocations) > 1:
raise NotImplementedError(f"Can not export disassembled datasets such as {ref}")
location, storedFileInfo = fileLocations[0]
if transfer is None:
# TODO: do we also need to return the readStorageClass somehow?
yield FileDataset(refs=[ref], path=location.pathInStore, formatter=storedFileInfo.formatter)
Expand Down
9 changes: 9 additions & 0 deletions tests/test_butler.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,15 @@ def testPutTemplates(self):
def testImportExport(self):
# Run put/get tests just to create and populate a repo.
storageClass = self.storageClassFactory.getStorageClass("StructuredDataNoComponents")
self.runImportExportTest(storageClass)

@unittest.expectedFailure
def testImportExportVirtualComposite(self):
# Run put/get tests just to create and populate a repo.
storageClass = self.storageClassFactory.getStorageClass("StructuredComposite")
self.runImportExportTest(storageClass)

def runImportExportTest(self, storageClass):
exportButler = self.runPutGetTest(storageClass, "test_metric")
# Test that the repo actually has at least one dataset.
datasets = list(exportButler.registry.queryDatasets(..., collections=...))
Expand Down

0 comments on commit e340fdd

Please sign in to comment.