Skip to content

Commit

Permalink
Ignore conflicts with existing dimension records in import.
Browse files Browse the repository at this point in the history
  • Loading branch information
TallJimbo committed Apr 29, 2022
1 parent 1eb3da8 commit 7a934a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/transfers/_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def load(
for element, dimensionRecords in self.dimensions.items():
if skip_dimensions and element in skip_dimensions:
continue
self.registry.insertDimensionData(element, *dimensionRecords)
self.registry.insertDimensionData(element, *dimensionRecords, skip_existing=True)
# FileDatasets to ingest into the datastore (in bulk):
fileDatasets = []
for (datasetTypeName, run), records in self.datasets.items():
Expand Down
13 changes: 5 additions & 8 deletions tests/test_simpleButler.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ def testComponentExport(self):
[self.comparableRef(ref) for ref in datasets2],
)

def testDatasetImportTwice(self):
"""Test exporting all datasets from a repo and then importing them all
back in again twice.
def tesImportTwice(self):
"""Test exporting dimension records and datasets from a repo and then
importing them all back in again twice.
"""
if self.datasetsIdType is not uuid.UUID:
self.skipTest("This test can only work for UUIDs")
Expand All @@ -204,11 +204,8 @@ def testDatasetImportTwice(self):
butler2 = self.makeButler(writeable=True)
# Import it once.
butler2.import_(filename=file.name)
# Import it again, but ignore all dimensions
dimensions = set(
dimension.name for dimension in butler2.registry.dimensions.getStaticDimensions()
)
butler2.import_(filename=file.name, skip_dimensions=dimensions)
# Import it again
butler2.import_(filename=file.name)
datasets1 = list(butler1.registry.queryDatasets(..., collections=...))
datasets2 = list(butler2.registry.queryDatasets(..., collections=...))
self.assertTrue(all(isinstance(ref.id, self.datasetsIdType) for ref in datasets1))
Expand Down

0 comments on commit 7a934a5

Please sign in to comment.