Repository navigation
feat: setup= on the lens analyses, point/weak setups and a factor-graph guard (5C-2) - #882
Merged
Merged
Conversation
…factor-graph guard (5C-2) AnalysisImaging / AnalysisInterferometer pass setup= to the PyAutoGalaxy base (resolved at modify_before_fit). AnalysisPoint and AnalysisWeak resolve it through a new AnalysisSetupNoOperator mixin (point_source_* / weak/isothermal rule keys): backend, threads, banner and setup.json. A setup that was never resolved (factor graphs) raises SetupException from the likelihood, outside the FitException wrapper. Part of #881 (likelihood-lifecycle phase 5C-2). Co-Authored-By: Claude Opus 5.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
Likelihood-lifecycle phase 5C-2, the second of two PRs under #881. 5C-1 was PyAutoGalaxy#752. The PyAutoLens analyses take
setup=None | "auto" | aa.Setup | "<setup_id>":AnalysisImaging/AnalysisInterferometerpass it to the PyAutoGalaxy base, which resolves it atmodify_before_fit.AnalysisPointandAnalysisWeakresolve it themselves through a new mixin. They have no dataset operator; the setup sets the backend and threads, logs the banner and writessetup.json.Factor graphs, which never call
modify_before_fit, now raise a clearSetupExceptionfrom the likelihood instead of silently ignoring the setup. It stays opt-in (R6): withoutsetup=, nothing changes beyond the "auto would choose …" log line.API Changes
setup=onal.AnalysisImaging,al.AnalysisInterferometer,al.AnalysisPointandal.AnalysisWeak(and lensAnalysisDataset).point_source_source/source_planewhenfit_positions_clsis aFitPositionsSourcesubclass, otherwisepoint_source_image/image_plane. Weak:weak/isothermal.al.exc.SetupException. It is raised at the top oflog_likelihood_function, outside theraise_fit_exceptionwrapper, when an analysis was givensetup=but it was never resolved (factor graphs; calling the likelihood directly withoutmodify_before_fit).fit_fromis not guarded.autolens.analysis.analysis.setup(AnalysisSetupNoOperatormixin,raise_if_setup_unresolved).See full details below.
Test Plan
pytest test_autolens: 1086 passed, 1 xfailedpyauto-heart readiness --dev --repos PyAutoLens): GREEN. Non-blocking shown reasons: manifest drift (1 workspace checkout mismatch vs repos.yaml); release validation has no rehearsal for current source.pyauto-heart smoke --affected-by PyAutoLens --jobs 3: 4/4 workspaces PASS (autolens, autolens_test, euclid, howtolens), run against this branch via PYAUTO_ROOTFull API Changes (for automation & release notes)
Added
setupkeyword onAnalysisDataset(lens),AnalysisImaging,AnalysisInterferometer,AnalysisPointandAnalysisWeak. On imaging and interferometer it comes aftershared_preloads, so existing positional calls still work.AnalysisPoint.setup_key_from(model)andAnalysisWeak.setup_key_from(model).AnalysisPoint.modify_before_fitandAnalysisWeak.modify_before_fitresolve the setup, then call super. Theirsave_attributeswritesfiles/setup.json.autolens.analysis.analysis.setup:AnalysisSetupNoOperator(_init_setup,resolve_setup,save_setup),raise_if_setup_unresolvedandsetup_environment.autolens.exc.SetupException(AnalysisException). It is deliberately not aFitException, so it is never resampled.Changed
log_likelihood_functionof imaging, interferometer, point and weak first checks that a given setup was resolved, and raisesSetupExceptionotherwise.Migration
setup=now raises. Apply the setup to each dataset (dataset.apply_setup(...)) and passuse_jax=instead, until PyAutoFit phase 5D adds factor-graph setups.Notes:
_xpis a property derived from_use_jaxin bothaf.AnalysisandAnalysisLens, so a resolved setup switches it with no extra code. Tests check numpy vsjax.numpyfor all four analyses.start_resume_fit, aftermodify_before_fit, so the guard never fires on a normal search.cluster/*rules are unused for now.setup.json, and one shared resolution helper replaces the small overlap between this mixin and PyAutoGalaxy'sAnalysisDataset(including the duplicatedsetup_environment).Generated by the PyAutoLabs agent workflow.
🤖 Generated with Claude Code