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-34919: Allow the generic butler tests to work with gen2 and gen3 #419

Merged
merged 4 commits into from Jun 1, 2022

Conversation

timj
Copy link
Member

@timj timj commented May 24, 2022

The mapper tests now disable themselves if no mapper is available.

Required by lsst/obs_lsst#402

Checklist

  • ran Jenkins
  • added a release note for user-visible changes to doc/changes

Copy link
Collaborator

@parejkoj parejkoj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should just remove the tests that are only ever going to be gen2.

I'm assuming the _is_gen3 stuff is so you don't have to modify other obs packages?

@@ -130,7 +133,17 @@ def setUp_butler_get(
raw_header_wcs=raw_header_wcs,
)

def _require_gen2(self):
if isinstance(self.butler, Butler):
self.skipTest("This test requires daf_persistence Butler, not daf_butler Butler.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just remove these tests instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm inclined to leave the gen2 tests there until we rip gen2 out of obs_base itself.

def test_exposureId_bits(self):
self._require_gen2()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should just remove this test.

@@ -139,13 +152,17 @@ def _test_exposure(self, name):
self.skipTest("Skipping %s as requested" % (inspect.currentframe().f_code.co_name))
exp = self.butler.get(name, self.dataIds[name])

exp_md = self.butler.get(name + "_md", self.dataIds[name])
md_component = ".metadata" if self._is_gen3() else "_md"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you doing the _is_gen3 thing to deal with obs packages that haven't moved their tests to gen3 yet?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the time I thought I had to do it because I assumed other obs packages used the obs_base tests. It seems like obs_lsst is the only one (other than possibly other external users). The butler_tests can work out from their own butler that it is gen2 vs gen3. At this point I'm inclined to leave the gen2 support in until all four of our obs packages drop gen2 and then rip it all out.

python/lsst/obs/base/butler_tests.py Outdated Show resolved Hide resolved
self.assertEqual(exp.getDetector().getSerial(), self.butler_get_data.detector_serials[name])
detector = exp.getDetector()
if detector:
# Some calibration files are missing the detector.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When does this happen? I thought we could always assume that the detector exists in LSST files?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some TS8 bias frames somehow don't have the detector. For all I know they were created by the camera team. I have no idea how easy it is to locate a newer TS8 example bias or if it should just be deleted.

python/lsst/obs/base/butler_tests.py Show resolved Hide resolved
python/lsst/obs/base/butler_tests.py Outdated Show resolved Hide resolved
The arguments to add.
"""
kwargs = {}
if isinstance(self.butler, Butler):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this use _is_gen3?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple inheritance makes it all a bit murky as to whether it will find it. I felt it was clearer for this temporary fix to do the explicit test in this file.

@@ -162,23 +168,28 @@ def test_map_metadata_data(self):
)

def test_keys(self):
self._check_mapper()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd argue that we should just remove mapper_tests and mapper_tests.MapperTests from ObsTests.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I kept changing my mind on this and decided to keep them around until obs_decam and obs_cfht stop using gen2 and obs_base can be completely cleaned out.

self.skipTest("This test requires daf_persistence Butler, not daf_butler Butler.")

def _is_gen3(self):
if isinstance(self.butler, Butler):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth flipping this around to be is_gen2 and call isinstance(self.butler, lsst.daf.persistence.Butler) instead, so that we have a very clear thing to remove when we finally remove daf_persistence?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_is_gen3 is going to be deleted when we clear out.

@timj
Copy link
Member Author

timj commented May 26, 2022

After I had made it compatible with gen2 and gen3 I realized that no obs package other than obs_lsst actually uses it (at least ours). In theory we could delete all these tests from obs_base. I'm no longer convinced that these tests cover anything more than we already test with the butler ingest code (where we ingest and then retrieve the raw and get components). Adding some extra queries in obs_lsst that use day_obs/seq_num may well cover everything.

The only extra thing these tests do is allow a bias to be retrieved for a couple of instruments.

@timj timj force-pushed the tickets/DM-34919 branch 3 times, most recently from 789635b to e6dad37 Compare May 31, 2022 21:34
timj added 3 commits May 31, 2022 14:34
The mapper tests now disable themselves if no mapper is
available.
It won't work for lsst data which has separate amps and whether
it works or not is dependent on the raw formatter in use.
Easier to remove the test for now.
@parejkoj
Copy link
Collaborator

parejkoj commented Jun 1, 2022

Originally, these tests were going to form the backbone for obs_decam and obs_subaru tests, too, but we were never able to complete that work. If you think we get good coverage from elsewhere, we might be able to remove them all. Maybe make a ticket to assess that after gen2 is gone (so we don't have as many places to look at coverage)?

@timj timj merged commit 1ab0d62 into main Jun 1, 2022
@timj timj deleted the tickets/DM-34919 branch June 1, 2022 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants