Skip to content

Start every job from the Lambda's own mission - #32

Merged
Alrobbertz merged 1 commit into
mainfrom
jamesray/reset-mission-per-job
Sep 9, 2026
Merged

Alrobbertz merged 1 commit into
mainfrom
jamesray/reset-mission-per-job

Conversation

@jamesray

@jamesray jamesray commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Problem

Since the image built on 2026-09-09 (20260909192833), every import_GOES_data_to_timestream run fails:

Failed to write to Timestream: ResourceNotFoundException: The table swxsoc_pipeline_measures_table does not exist.

Until 18:54Z the same job wrote to swxsoc_sdc_aws_logs/swxsoc_measures_table as it always has.

Cause

swxsoc/swxsoc_reach#58 and PADRESat/padre_craft#28 (both merged 2026-08-24, after the previous executor image was built) force SWXSOC_MISSION and call swxsoc.reconfigure() when the package is imported. The executor imported swxsoc_reach.net.udl at module load, so every cold start now runs as swxsoc_pipeline, and swxsoc.db.timeseries.record_timeseries derives the Timestream table from that mission. The Lambda's environment was not changed; the base Terraform plan touched only the image and tags.

Fix

  • swxsoc_reach is imported inside the REACH job through a wrapper that keeps the download_UDL_reach_window name the tests patch.
  • DEFAULT_MISSION captures the Lambda's own SWXSOC_MISSION at module load, and Executor.execute() restores it before every job. A warm container that just ran the REACH or PADRE orbit job can no longer leak swxsoc_pipeline or padre into GOES or STIX.
  • Two tests: a leaked mission is cleared and the library reconfigured; a mission configured on the Lambda is restored rather than removed.

Deferring the import also trims the cold start, which hit the 10 s init timeout on the new image.

Verification

  • ruff check and ruff format --check clean.
  • 8 of 9 tests pass locally; test_get_padre_orbit_data needs padre_craft's full dependency tree, which the local environment could not build, so CI covers it.

🤖 Generated with Claude Code

Importing swxsoc_reach or padre_craft now forces SWXSOC_MISSION to
swxsoc_pipeline or padre and reconfigures swxsoc for the whole process.
The executor imported swxsoc_reach at module load, so the image built on
2026-09-09 ran GOES and STIX imports as swxsoc_pipeline and tried to
write to swxsoc_pipeline_measures_table, which does not exist.

Defer the swxsoc_reach import to the REACH job and restore the mission
the Lambda environment configured before every job, so nothing left in a
warm container by the REACH or PADRE orbit jobs reaches the next one.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 9, 2026 20:12
@Alrobbertz
Alrobbertz merged commit ebf1d0f into main Sep 9, 2026
8 checks passed
@Alrobbertz
Alrobbertz deleted the jamesray/reset-mission-per-job branch September 9, 2026 20:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Repeated PADRE invocations can use the wrong mission and write to the wrong Timestream table; focused deferred-import coverage is also needed.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR isolates mission configuration between warm Lambda invocations and defers the REACH import to reduce cold-start risk.

Changes:

  • Restores the Lambda mission before each job.
  • Adds a deferred REACH import wrapper.
  • Adds mission-reset tests.
File summaries
File Summary
lambda_function/tests/test_executor.py Adds tests for mission restoration behavior.
lambda_function/src/executor/executor.py Implements deferred imports and mission resetting. Critical finding (2 votes): repeated PADRE runs need explicit reconfiguration after package caching. Nit (1 vote): add focused coverage for the deferred-import wrapper.
Review details

Suppressed comments (1)

lambda_function/src/executor/executor.py:42

  • The REACH test replaces src.executor.executor.download_UDL_reach_window before invoking the job, so this deferred import is never executed by the suite. A focused test should patch swxsoc_reach.net.udl.download_UDL_reach_window and call the wrapper (or the job without replacing the wrapper) to verify the import path and keyword forwarding; otherwise the change that prevents the cold-start import regression can silently be broken while all current tests pass.
    from swxsoc_reach.net.udl import download_UDL_reach_window as download
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

if self.function_name not in self.function_mapping:
raise ValueError(f"Function '{self.function_name}' is not recognized.")
log.info(f"Executing function: {self.function_name}")
self.reset_mission()
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.

3 participants