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-43712: Add configurable buffer for template and refcat preload #204

Merged
merged 13 commits into from
Nov 13, 2024

Conversation

hsinfang
Copy link
Collaborator

No description provided.

Copy link
Member

@kfindeisen kfindeisen left a comment

Choose a reason for hiding this comment

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

Many thanks for the well-organized changes! However, I'm a bit worried that they're eroding the (already shaky) coherence of MiddlewareInterface, specifically with the region state variable and the splitting of queries across multiple _filter_datasets calls. I tried to offer some specific suggestions, but I'd like to take another look at the final result.

python/activator/middleware_interface.py Outdated Show resolved Hide resolved
python/activator/middleware_interface.py Outdated Show resolved Hide resolved
python/activator/middleware_interface.py Outdated Show resolved Hide resolved
tests/test_middleware_interface.py Outdated Show resolved Hide resolved
python/activator/middleware_interface.py Outdated Show resolved Hide resolved
etc/export_comCamSim.yaml Outdated Show resolved Hide resolved
python/activator/middleware_interface.py Outdated Show resolved Hide resolved
python/activator/middleware_interface.py Outdated Show resolved Hide resolved
.github/workflows/build-service.yml Outdated Show resolved Hide resolved
python/activator/middleware_interface.py Outdated Show resolved Hide resolved
@hsinfang hsinfang force-pushed the tickets/DM-43712 branch 3 times, most recently from 6839a4b to 5653980 Compare October 4, 2024 17:06
@hsinfang hsinfang force-pushed the tickets/DM-43712 branch 14 times, most recently from 319061d to 423db09 Compare October 17, 2024 18:44
Copy link
Member

@kfindeisen kfindeisen left a comment

Choose a reason for hiding this comment

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

Looks much better, thanks! But please make sure the code doesn't crash when there's no region.

python/activator/middleware_interface.py Outdated Show resolved Hide resolved
python/activator/middleware_interface.py Outdated Show resolved Hide resolved
def test_compute_region(self):
"""Test preload region computation."""
region = self.interface._compute_region()
self.assertTrue(isinstance(region, lsst.sphgeom.Region))
Copy link
Member

Choose a reason for hiding this comment

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

Since the tests don't include pointing/slew errors, the nextVisit boresight and exposure boresight are identical. Is it possible to test the values based on that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought of that, but was not sure how to get the "truth" that is not from the exactly same code as in _compute_region(). Do you mean a comparison with a directly instantiated polygon?

Copy link
Member

Choose a reason for hiding this comment

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

I was thinking of using the visit-detector records, with matched padding. That should give similar results, shouldn't it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm taking too long to make it work, so I decided to file a new ticket DM-47460 for it instead of delaying this PR.

I moved this test to MiddlewareInterfaceWriteableTest where visit-detector records are available (after ingesting raws and defining visits).

python/activator/middleware_interface.py Show resolved Hide resolved
python/activator/middleware_interface.py Show resolved Hide resolved
python/activator/middleware_interface.py Outdated Show resolved Hide resolved
python/activator/middleware_interface.py Outdated Show resolved Hide resolved
python/activator/middleware_interface.py Show resolved Hide resolved
python/activator/middleware_interface.py Outdated Show resolved Hide resolved
src_butler.query_datasets.assert_called_once_with(
"bias", instrument="LSSTComCamSim", explain=False)
existing_butler.query_datasets.assert_called_once_with(
"bias", instrument="LSSTComCamSim", explain=False)
Copy link
Member

@kfindeisen kfindeisen Oct 18, 2024

Choose a reason for hiding this comment

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

The explain=False is an implementation detail. Unfortunately, I don't know how to write a test without it other than inspecting Mock.call_args directly.

This should have been together with 674a4b1

Unlike the old DECam test dataset, the new test LSSTComCamSim dataset
does not have crosstalk. So, use another dataset type to test.

Also fix a time stamp missed in the previous commit.
The optimal value likely depends on the instrument and the
skymap choice.
Instead of determining the instrument's wcsFlipX here, it is more
robust to use its formatter, which knows its camera orientation
from its obs package.
This changes the APIs of _export_skymap_and_templates and
_export_refcats to take a lsst.sphgeom.Region directly.

Note that the centroid of the region is not the same of the
detector center, but it should not matter.

Because htm7 can be too coarse compared to the patch size, using
htm7 indices to search for templates may lead to preloading more
patches than necessary and wasting time. This feature of using
htm7 to search for overlapping templates is also about to be
deprecated and replaced by the arbitrary spatial region query in
Butler. The usage will be replaced when switching to the new
butler query system.
This reduces the number of calib dataset types to loop through.
Querying butler one dataset type at a time is not necessary with
the butler.registry.queryDatasets. But this is a preparation step
before switching to the new query system which can only queries
one dataset type at a time.

Currently we can preload more types of calibs/refcats/templates
than the actual pipelines really need. It's possible that some types
are not preloaded but it's okay.
The new Butler query systems supports spatial-constraint query
via lsst.sphgeom.Region directly. With this change, we use it
in template and refcat search. This needs stack w_2024_38 or newer.

make_export.py uses _filter_datasets so it needs to adjust to the
new underlying API too.
Some unit tests were temporarily marked expectedFailure in 674a4b1.

Now that we switch to the new query system, make them work again.

The test repo was put together using middleware tools, which
intrinsically uses butler repo's visit-detector regions with its
padding from defineVisits config.

That padding config is not the same as the preload region padding
in prompt processing.

This explains the patch differences in template selection.
@hsinfang hsinfang merged commit ba0cfd5 into main Nov 13, 2024
6 of 8 checks passed
@hsinfang hsinfang deleted the tickets/DM-43712 branch November 13, 2024 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants