Skip to content

Fix ephemeris selection priority for OD solutions - #1780

Open
bryan-harter wants to merge 5 commits into
devfrom
fix/1743-ephemeris-od-priority
Open

bryan-harter wants to merge 5 commits into
devfrom
fix/1743-ephemeris-od-priority

Conversation

@bryan-harter

Copy link
Copy Markdown
Member

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:

  1. Rename the old files to remove the OD#, and redeliver
  2. Sort by OD number except in the case of final ephemeris
  3. Alter the upload times in the actual database by a couple seconds so they are loaded in the appropriate order

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!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

These unit tests are just changing because I got rid of the attitude_predict files

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