Skip to content

Commit

Permalink
Use targeted raw-specific ingest run collection name method
Browse files Browse the repository at this point in the history
We need something to give us the default raw collection
name but since we can't predict all the other defaults
at this time, change the default method to specifically
relate to raws.

As part of this we move from "construct" to "make" in
the API.
  • Loading branch information
timj committed Jun 19, 2020
1 parent 60c6f07 commit befdfbb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 23 deletions.
24 changes: 8 additions & 16 deletions python/lsst/obs/base/_instrument.py
Expand Up @@ -266,7 +266,7 @@ def writeCuratedCalibrations(self, butler, run=None):
# name and eventually the data package version. The camera geom
# is currently special in that it is not in the _data package.
if run is None:
run = self.constructCollectionName("calib")
run = self.makeCollectionName("calib")
butler.registry.registerCollection(run, type=CollectionType.RUN)
self.writeCameraGeom(butler, run=run)
self.writeStandardTextCuratedCalibrations(butler, run=run)
Expand Down Expand Up @@ -443,28 +443,20 @@ def makeDataIdTranslatorFactory(self) -> TranslatorFactory:
raise NotImplementedError("Must be implemented by derived classes.")

@classmethod
def constructDefaultCollectionName(cls, label: str) -> str:
"""Get the default instrument-specific collection string from the
supplied label.
Parameters
----------
label : `str`
Generic type of collection from which to derive the default
name. For example for ``raw`` this would return a string of the
form ``instrument_name/raw/all``.
def makeDefaultRawIngestRunName(cls) -> str:
"""Make the default instrument-specific run collection string for raw
data ingest.
Returns
-------
coll : `str`
Collection name to be used as the default for this generic label.
Run collection name to be used as the default for ingestion of
raws.
"""
if label == "raw":
label = "raw/all"
return cls.constructCollectionName(label)
return cls.makeCollectionName("raw/all")

@classmethod
def constructCollectionName(cls, label: str) -> str:
def makeCollectionName(cls, label: str) -> str:
"""Get the instrument-specific collection string to use as derived
from the supplied label.
Expand Down
7 changes: 3 additions & 4 deletions python/lsst/obs/base/gen2to3/convertTests.py
Expand Up @@ -141,13 +141,13 @@ def setUp(self):
self.gen3root = tempfile.mkdtemp()
self.gen2Butler = lsst.daf.persistence.Butler(root=self.gen2root, calibRoot=self.gen2calib)
self.collections = set(type(self).collections)
self.collections.add(self.instrumentClass.constructDefaultCollectionName("raw"))
self.collections.add(self.instrumentClass.makeDefaultRawIngestRunName())
if len(self.refcats) > 0:
self.collections.add("refcats")
if self.skymapName is not None:
self.collections.add("skymaps")
if self.gen2calib:
self.collections.add(self.instrumentClass.constructCollectionName("calib"))
self.collections.add(self.instrumentClass.makeCollectionName("calib"))

def tearDown(self):
shutil.rmtree(self.gen3root, ignore_errors=True)
Expand Down Expand Up @@ -269,9 +269,8 @@ def test_convert(self):
"""Test that all data are converted correctly.
"""
self._run_convert()
instrument = self.instrumentClass
gen3Butler = lsst.daf.butler.Butler(self.gen3root,
collections=instrument.constructDefaultCollectionName("raw"))
collections=self.instrumentClass.makeDefaultRawIngestRunName())
self.check_collections(gen3Butler)

# check every raw detector that the gen2 butler knows about
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/obs/base/ingest.py
Expand Up @@ -462,7 +462,7 @@ def run(self, files, *, pool: Optional[Pool] = None, processes: int = 1, run: Op
# Override default run if nothing specified explicitly
if run is None:
instrumentClass = exposure.files[0].instrumentClass
this_run = instrumentClass.constructDefaultCollectionName("raw")
this_run = instrumentClass.makeDefaultRawIngestRunName()
else:
this_run = run
if this_run not in runs:
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/obs/base/script/convert.py
Expand Up @@ -92,10 +92,10 @@ def convert(repo, gen2root, instrument, skymap_name, skymap_config, calibs, reru
chainName=f"shared/{instr.getName()}", parents=[]) for rerun in reruns]

# create a new butler instance for running the convert repo task
butler = lsst.daf.butler.Butler(butlerConfig, run=instr.constructDefaultCollectionName("raw"))
butler = lsst.daf.butler.Butler(butlerConfig, run=instr.makeDefaultRawIngestRunName())
convertRepoTask = ConvertRepoTask(config=convertRepoConfig, butler3=butler)
convertRepoTask.run(
root=gen2root,
reruns=rerunsArg,
calibs=None if calibs is None else {calibs: instr.constructCollectionName("calib")}
calibs=None if calibs is None else {calibs: instr.makeCollectionName("calib")}
)

0 comments on commit befdfbb

Please sign in to comment.