Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-25458: Refactor raw/calib collection naming #265

Merged
merged 8 commits into from
Jun 20, 2020
21 changes: 21 additions & 0 deletions python/lsst/obs/base/_instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,27 @@ 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``.

Returns
-------
coll : `str`
Collection name to be used as the default for this generic label.
"""
if label == "raw":
label = "raw/all"
return cls.constructCollectionName(label)

timj marked this conversation as resolved.
Show resolved Hide resolved
@classmethod
def constructCollectionName(cls, label: str) -> str:
timj marked this conversation as resolved.
Show resolved Hide resolved
"""Get the instrument-specific collection string to use as derived
Expand Down
5 changes: 3 additions & 2 deletions python/lsst/obs/base/gen2to3/convertTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ 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.constructCollectionName("raw"))
self.collections.add(self.instrumentClass.constructDefaultCollectionName("raw"))
if len(self.refcats) > 0:
self.collections.add("refcats")
if self.skymapName is not None:
Expand Down Expand Up @@ -269,8 +269,9 @@ 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=self.instrumentClass.constructCollectionName("raw"))
collections=instrument.constructDefaultCollectionName("raw"))
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
Original file line number Diff line number Diff line change
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.constructCollectionName("raw")
this_run = instrumentClass.constructDefaultCollectionName("raw")
else:
this_run = run
if this_run not in runs:
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/obs/base/script/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ 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.constructCollectionName("raw"))
butler = lsst.daf.butler.Butler(butlerConfig, run=instr.constructDefaultCollectionName("raw"))
convertRepoTask = ConvertRepoTask(config=convertRepoConfig, butler3=butler)
convertRepoTask.run(
root=gen2root,
Expand Down