Repository navigation
Fix ephemeris selection priority for OD solutions - #1780
bryan-harter wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Kernel selection remains dependent on database row order when ingestion timestamps and coverage bounds tie, requiring a deterministic file-name tie-breaker and regression tests for both insertion orders.
1 open issue
What changed in this PR
This PR adjusts SPICE metakernel selection in the IMAP Science Data System to handle deliveries with missing OD numbers and shared ingestion timestamps.
Changes:
- Adds multi-field ranking by ingestion time, then coverage start and end.
- Prioritizes predicted ephemeris over nominal and removes legacy kernel types and event entries.
- Adds selection regression tests and documents priority rules and recovery considerations.
| File | Description |
|---|---|
| tests/lambda_endpoints/test_spice_metakernel_api.py | Tests batch ties, ingestion priority, and ephemeris subtype precedence. |
| tests/lambda_endpoints/test_spice_indexer_lambda.py | Updates event-filter tests for predicted ephemeris. |
| sds_data_manager/orchestration/spice.py | Simplifies non-triggering kernel types. |
| sds_data_manager/lambda_code/SDSCode/spice_utilities.py | Defines multi-field priority and revises supported subtype ordering. |
| sds_data_manager/lambda_code/SDSCode/pipeline_lambdas/spice_indexer.py | Removes legacy predicted-kernel event entries. |
| sds_data_manager/lambda_code/SDSCode/api_lambdas/metakernel.py | Supports sorting kernels by multiple priority fields. |
| docs/imap-architecture.md | Explains selection priorities and ingestion-time recovery constraints. |
Review effort: Balanced
| @@ -704,11 +704,10 @@ def send_spice_event(spice_obj: SPICEFilePath, s3_key: str): | |||
| # If these kernels, send event to EventBridge | |||
| spice_events = [ | |||
| "attitude_history", | |||
There was a problem hiding this comment.
I took this opportunity to fix something else in SPICE, we have never received an attitude_predict file. We only get attitude history.
In addition, ephemeris_predicted seemed to be mislabeled as "attitude_predict" in a couple places.
|
|
||
|
|
||
| def _insert_test_file(session, filename, intervals, upload_time=0): | ||
| def _insert_test_file(session, filename, intervals, upload_time=0, ingestion_date=None): |
There was a problem hiding this comment.
These unit tests are just changing because I got rid of the attitude_predict files

Fixes #1777
So unfortunately, the recommended approach doesn't quite work because the initial few deliveries of the reconstructed ephemeris files contain an OD number, but most do not. So the handful of old files with OD numbers in the file name would shoot to the top of the priority list, even though we should be using other ones.
Some ideas I batted around:
Instead what I chose was to just slightly expand the functionality of metakernel.py to sort by multiple fields. Sorting with these new categories fixes the (hopefully) one-off issues at the beginning of the mission without doing anything too weird in the code. And then I just added a bit of documentation on OD numbers.
And then of course, claude units tests!