Skip to content

Commit

Permalink
Only register if instrument not already registered
Browse files Browse the repository at this point in the history
Rather than having a configuration option for registration,
check to see if the registry already knows about that instrument.
  • Loading branch information
timj committed Mar 23, 2020
1 parent 7bd9040 commit 6023e73
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions python/lsst/obs/base/gen2to3/convertRepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,6 @@ class ConvertRepoConfig(Config):
itemtype=str,
default={}
)
doRegisterInstrument = Field(
"If True (default), add dimension records for the Instrument and its "
"filters and detectors to the registry instead of assuming they are "
"already present.",
dtype=bool,
default=True,
)
doWriteCuratedCalibrations = Field(
"If True (default), ingest human-curated calibrations directly via "
"the Instrument interface. Note that these calibrations are never "
Expand Down Expand Up @@ -463,13 +456,13 @@ def run(self, root: str, collections: List[str], *,
# runs/collections, and transactions are managed at the Butler level.
# DM-21246 should let us fix this, assuming we actually want to keep
# the transaction open that long.
if self.config.doRegisterInstrument:
# Allow registration to fail on the assumption that this means
# we are reusing a butler
try:
self.instrument.register(self.registry)
except Exception:
pass
# Only register an instrument if it has not been previously registered
try:
# Need the list to force the query to happen
list(self.registry.queryDimensions("instrument",
instrument=self.instrument.getName()))
except LookupError:
self.instrument.register(self.registry)

# Make and prep converters for all Gen2 repos. This should not modify
# the Registry database or filesystem at all, though it may query it.
Expand Down

0 comments on commit 6023e73

Please sign in to comment.