fix(viz): make _compute_critical_curve_lines failures loud, not silent#527
Merged
Conversation
The bare `except Exception: return None, None, None, None` in _compute_critical_curve_lines silently swallowed ZeroSolver failures during model fits, which is the root cause behind two recent viz default reverts: - PyAutoGalaxy abd7b717 (2026-04-19): zero_contour YAML default reverted because critical curves silently vanished on HPC. - PyAutoFit #1280 (2026-05-17): use_jax_for_visualization=True default reverted because Euclid source planes wrote all-zero. Both shared the same shape - a JAX-trace failure inside the viz path that the broad except masked. Tighten so: - ModuleNotFoundError (jax_zero_contour missing): silent (already warned upstream in plot_utils). - ValueError (no zero crossings in eigenvalue grid): silent (the curves genuinely do not exist for the model). - Anything else: WARNING log with exc_info=True so the next regression of this class fails loud. Closes PyAutoLabs/PyAutoGalaxy#433 alongside the PyAutoGalaxy companion PR. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
Workspace PR: PyAutoLabs/autolens_workspace_test#111 |
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
Tightens the broad
except Exception:in_compute_critical_curve_linesso future regressions of the "ZeroSolver raised, viz fell back to all-zero" failure mode fail loud, not silent.Two recent reverts share the same shape — a JAX-tracing failure inside the visualization path that the broad except masked into
(None, None, None, None):abd7b717reverted the YAML default flip tozero_contour. Critical curves silently vanished on HPC runs.use_jax_for_visualization=Truedefault. Source-plane FITS files wrote all-zero across every Euclid DR1 tile and Einstein-radius posteriors collapsed to the full prior.Both were invisible at run time. The next attempt to flip the default needs a loud failure if it regresses, so this PR:
ModuleNotFoundErrorsilent (thejax_zero_contourabsence is already warned upstream inplot_utils._critical_curves_method).ValueErrorsilent (no zero crossings in the eigenvalue grid — curves genuinely don't exist for the model).WARNINGwithexc_info=Truevia the module logger, then still returns the no-overlay tuple so plotting itself doesn't crash.Companion PR in PyAutoGalaxy (
Jammy2211/PyAutoGalaxy#434) fixes the underlying perf bug that madezero_contourunusable as a default.Closes PyAutoLabs/PyAutoGalaxy#433 (alongside the PyAutoGalaxy companion).
API Changes
_compute_critical_curve_linesis a private helper — no public API surface changes. Behavioural change: unexpected exceptions now emit aWARNINGlog with traceback before falling back to no-overlay rendering, instead of being silently swallowed.See full details below.
Test Plan
test__compute_critical_curve_lines__known_recoverable_exceptions__silent— confirmsModuleNotFoundErrorandValueErrorfall through with no log record emitted.test__compute_critical_curve_lines__unexpected_exception__logs_warning— confirms an unexpectedRuntimeErrorproduces exactly oneWARNINGrecord withexc_infoattached.pytest test_autolens/imaging/plot/— 15 passed locally.autolens_workspace_test/scripts/imaging/modeling_visualization_jit.pyPart 1 + Visualization Sanity block run cleanly under the new exception flow.Full API Changes (for automation & release notes)
Removed
Added
Changed Signature
Changed Behaviour
autolens.imaging.plot.fit_imaging_plots._compute_critical_curve_lines— replaces bareexcept Exception:with specific catches.ModuleNotFoundErrorandValueErrorstill fall through silently; anything else logsWARNINGwith traceback via the module logger before returning the no-overlay tuple.Migration
(None, None, None, None); they additionally see a WARNING log when an unexpected failure occurs.🤖 Generated with Claude Code