Skip to content

Commit

Permalink
Make Instrument registration idempotent.
Browse files Browse the repository at this point in the history
  • Loading branch information
TallJimbo committed Oct 16, 2020
1 parent 0b6c65b commit ea8d6ce
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions python/lsst/obs/lsst/_instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,21 @@ def register(self, registry):
# The maximum values below make Gen3's ObservationDataIdPacker produce
# outputs that match Gen2's ccdExposureId.
obsMax = self.translatorClass.max_detector_exposure_id()
registry.insertDimensionData("instrument",
{"name": self.getName(),
"detector_max": self.translatorClass.DETECTOR_MAX,
"visit_max": obsMax,
"exposure_max": obsMax,
"class_name": getFullTypeName(self),
})

records = [self.extractDetectorRecord(detector) for detector in self.getCamera()]
registry.insertDimensionData("detector", *records)

self._registerFilters(registry)
with registry.transaction():
registry.syncDimensionData(
"instrument",
{
"name": self.getName(),
"detector_max": self.translatorClass.DETECTOR_MAX,
"visit_max": obsMax,
"exposure_max": obsMax,
"class_name": getFullTypeName(self),
}
)
for detector in self.getCamera():
registry.syncDimensionData("detector", self.extractDetectorRecord(detector))

self._registerFilters(registry)

def extractDetectorRecord(self, camGeomDetector):
"""Create a Gen3 Detector entry dict from a cameraGeom.Detector.
Expand Down

0 comments on commit ea8d6ce

Please sign in to comment.