Skip to content

Commit

Permalink
Use Instrument in 2to3 conversion to determine curated calibrations t…
Browse files Browse the repository at this point in the history
…o skip
  • Loading branch information
timj committed Aug 21, 2020
1 parent ec58088 commit 35775c7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
2 changes: 1 addition & 1 deletion python/lsst/obs/base/gen2to3/calibRepoConverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(self, *, mapper: CameraMapper, **kwds):

def isDatasetTypeSpecial(self, datasetTypeName: str) -> bool:
# Docstring inherited from RepoConverter.
return datasetTypeName in self.task.config.curatedCalibrations
return datasetTypeName in self.instrument.getCuratedCalibrationNames()

def iterMappings(self) -> Iterator[Tuple[str, CameraMapperMapping]]:
# Docstring inherited from RepoConverter.
Expand Down
18 changes: 3 additions & 15 deletions python/lsst/obs/base/gen2to3/convertRepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,18 +250,6 @@ class ConvertRepoConfig(Config):
dtype=bool,
default=False,
)
curatedCalibrations = ListField(
"Dataset types that are handled by `Instrument.writeCuratedCalibrations()` "
"and thus should not be converted using the standard calibration "
"conversion system.",
dtype=str,
default=["camera",
"transmission_sensor",
"transmission_filter",
"transmission_optics",
"transmission_atmosphere",
"bfKernel"]
)

@property
def transfer(self):
Expand Down Expand Up @@ -482,12 +470,12 @@ def run(self, root: str, *,

# Make converters for all Gen2 repos.
converters = []
rootConverter = RootRepoConverter(task=self, root=root, subset=subset)
rootConverter = RootRepoConverter(task=self, root=root, subset=subset, instrument=self.instrument)
converters.append(rootConverter)
for calibRoot, run in calibs.items():
if not os.path.isabs(calibRoot):
calibRoot = os.path.join(rootConverter.root, calibRoot)
converter = CalibRepoConverter(task=self, root=calibRoot, run=run,
converter = CalibRepoConverter(task=self, root=calibRoot, run=run, instrument=self.instrument,
mapper=rootConverter.mapper,
subset=rootConverter.subset)
converters.append(converter)
Expand All @@ -496,7 +484,7 @@ def run(self, root: str, *,
if not os.path.isabs(runRoot):
runRoot = os.path.join(rootConverter.root, runRoot)
converter = StandardRepoConverter(task=self, root=runRoot, run=spec.runName,
subset=rootConverter.subset)
instrument=self.instrument, subset=rootConverter.subset)
converters.append(converter)

# Register the instrument if we're configured to do so.
Expand Down
6 changes: 5 additions & 1 deletion python/lsst/obs/base/gen2to3/repoConverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
from .convertRepo import ConvertRepoTask
from .scanner import PathElementHandler
from lsst.daf.butler import StorageClass, Registry, SkyPixDimension, FormatterParameter
from .._instrument import Instrument


@dataclass
Expand Down Expand Up @@ -187,6 +188,8 @@ class RepoConverter(ABC):
root : `str`
Root of the Gen2 repo being converted. Will be converted to an
absolute path, resolving symbolic links and ``~``, if necessary.
instrument : `Instrument`
Gen3 instrument class to use for this conversion.
collections : `list` of `str`
Gen3 collections with which all converted datasets should be
associated.
Expand All @@ -204,10 +207,11 @@ class RepoConverter(ABC):
implementation.
"""

def __init__(self, *, task: ConvertRepoTask, root: str, run: Optional[str],
def __init__(self, *, task: ConvertRepoTask, root: str, instrument: Instrument, run: Optional[str],
subset: Optional[ConversionSubset] = None):
self.task = task
self.root = os.path.realpath(os.path.expanduser(root))
self.instrument = instrument
self.subset = subset
self._run = run
self._repoWalker = None # Created in prep
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/obs/base/gen2to3/rootRepoConverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def isDatasetTypeSpecial(self, datasetTypeName: str) -> bool:
super().isDatasetTypeSpecial(datasetTypeName)
or datasetTypeName in ("raw", "ref_cat", "ref_cat_config")
# in Gen2, some of these are in the root repo, not a calib repo
or datasetTypeName in self.task.config.curatedCalibrations
or datasetTypeName in self.instrument.getCuratedCalibrationNames()
)

def getSpecialDirectories(self) -> List[str]:
Expand Down

0 comments on commit 35775c7

Please sign in to comment.