Skip to content

Fall back to a bundled obscodes file when the MPC download fails#337

Open
matthewholman wants to merge 1 commit into
mainfrom
issue/network/obscode-fallback
Open

Fall back to a bundled obscodes file when the MPC download fails#337
matthewholman wants to merge 1 commit into
mainfrom
issue/network/obscode-fallback

Conversation

@matthewholman

Copy link
Copy Markdown
Collaborator

Summary

LayupObservatory downloads the MPC observatory-codes file (obscodes_extended.json.gz) from minorplanetcenter.net on first use. When that server is unreachable the whole run fails — this recently took down a CI leg where every obscode-dependent test errored with requests.exceptions.ConnectTimeout (23 failures on one ubuntu runner).

Observatory codes change rarely, so this ships a fallback copy in the package and uses it when the live download fails.

Changes

  • Bundle layup/data/ObsCodes.json.gz (77 KB, 2708 codes).
  • write_fallback_obscodes(): decompress the bundled file to a plain JSON path.
  • LayupObservatory.__init__: try the normal MPC download; on a requests.exceptions.RequestException, log a warning and re-initialize via sorcha's Observatory(..., oc_file=...) argument, which reads the decompressed JSON directly and bypasses the download.

A slightly stale fallback is far better than a hard failure on a transient outage.

Verification (fresh build)

  • test_write_fallback_obscodes — the bundled file decompresses to valid JSON (X05/500 present).
  • test_layup_observatory_falls_back_on_mpc_failure — a simulated ConnectTimeout falls back to the bundled copy and populates ObservatoryXYZ.
  • Full tests/layup/test_data_processing_utilities.py: 41 passed, no regressions.

Notes

  • This fixes the failure mode; it does not shorten the download timeout, so an outage still costs the (one-time per worker) pooch retry/timeout before falling back. A follow-up could shorten that timeout or have the fallback also seed the on-disk cache.
  • Independent of the spawn fix in Fix Linux fork+JAX worker deadlock by using the 'spawn' start method (#256) #336 (network resilience vs. the fork/JAX deadlock); both touch data_processing_utilities.py but in non-overlapping regions, so they rebase cleanly in either order.

🤖 Generated with Claude Code

LayupObservatory downloads the MPC observatory-codes file
(obscodes_extended.json.gz) from minorplanetcenter.net on first use. When
that server is unreachable the whole run fails -- this took down a CI leg
where every obscode-dependent test errored with requests ConnectTimeout.

Observatory codes change rarely, so ship a copy in layup/data/ObsCodes.json.gz
and, when the live download raises a requests exception, decompress the
bundled copy and hand it to sorcha's Observatory via its oc_file argument
(which bypasses the download). A slightly stale fallback is far better than a
hard failure on a transient network outage.

- write_fallback_obscodes(): decompress the bundled file to a JSON path.
- LayupObservatory.__init__: try the normal download, fall back on
  requests.exceptions.RequestException.
- Tests: the bundled file decompresses to valid JSON, and a simulated MPC
  outage falls back to it instead of raising.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant