Skip to content

refactor: lazy astropy + workspace version-warning dedupe - #151

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/lazy-heavy-imports
Aug 19, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/lazy-heavy-imports

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Part of the cross-repo import-time task (PyAutoFit#1505): defers the astropy import in fitsable.py to its three fits-touching functions (~0.17s off every library import), and dedupes the workspace version-check warning — every library init (autofit → autogalaxy → autolens) calls check_version, so one stale workspace printed the identical warning three times per process.

API Changes

None — internal changes only. fitsable functions behave identically (astropy loads on first fits I/O); check_version warns once per unique message per process.
See full details below.

Test Plan

  • Full suite: 157 passed (clean env — PYAUTO_SKIP_WORKSPACE_VERSION_CHECK must be unset, it bypasses the very check the raise-tests assert)
  • import autolens from a stale workspace CWD prints the warning exactly once
  • fits round-trip via autoarray suite (1062 passed downstream)
Full API Changes (for automation & release notes)

Changed Behaviour

  • autonerves.fitsable — astropy imports on first hdu_list_for_output_from / ndarray_via_fits_from / header_obj_from call; a missing astropy now raises ModuleNotFoundError at use (previously a NameError).
  • autonerves.workspace.check_version — byte-identical warnings are emitted once per process (_warn_once); distinct messages (different roots/versions) are unaffected.

Migration

  • None required.

Generated by the PyAutoLabs agent workflow.

…(PyAutoFit#1505)

astropy imports at the three fits-touching functions; check_version warns
once per unique message per process instead of once per library init.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Aug 19, 2026
@Jammy2211
Jammy2211 merged commit e91584d into main Aug 19, 2026
3 checks passed
@Jammy2211
Jammy2211 deleted the feature/lazy-heavy-imports branch August 19, 2026 22:01
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Sep 4, 2026
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