refactor: lazy astropy + workspace version-warning dedupe - #151
Merged
Conversation
…(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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part of the cross-repo import-time task (PyAutoFit#1505): defers the astropy import in
fitsable.pyto its three fits-touching functions (~0.17s off every library import), and dedupes the workspace version-check warning — every library init (autofit → autogalaxy → autolens) callscheck_version, so one stale workspace printed the identical warning three times per process.API Changes
None — internal changes only.
fitsablefunctions behave identically (astropy loads on first fits I/O);check_versionwarns once per unique message per process.See full details below.
Test Plan
PYAUTO_SKIP_WORKSPACE_VERSION_CHECKmust be unset, it bypasses the very check the raise-tests assert)import autolensfrom a stale workspace CWD prints the warning exactly onceFull API Changes (for automation & release notes)
Changed Behaviour
autonerves.fitsable— astropy imports on firsthdu_list_for_output_from/ndarray_via_fits_from/header_obj_fromcall; a missing astropy now raisesModuleNotFoundErrorat use (previously aNameError).autonerves.workspace.check_version— byte-identical warnings are emitted once per process (_warn_once); distinct messages (different roots/versions) are unaffected.Migration
Generated by the PyAutoLabs agent workflow.