Skip to content

fix: invalidate stale factor-graph subsample instances #1467

Description

@Jammy2211

Release-blocking regression

Stage 3 rehearsal 31517075410 uses PyAutoFit b499d4367cfdf344af32d686246ded234f1ad74b (#1466), PyAutoGalaxy be61b8d0546c5d933ff9ef4bf9d445ba4595e03b (#568), TestPyPI 2026.8.11.1.dev71002, and the release profile (PYAUTO_TEST_MODE=1).

Valid factor-graph scripts still fail with child results missing per-analysis attributes such as .centre and .galaxies.

Root cause

start_resume_fit reads samples_summary.instance during test-mode validation, caching the global factor-graph instance in _instance. SamplesSummary.subsamples and Samples.subsamples shallow-copy the object and rebind it to a factor model, but retain that cached global instance. Child results therefore expose the global factor-index structure rather than the per-analysis model.

#1466's regression covered rejected final samples. Recovery creates a fresh summary, so it missed this valid-sample cache-warming path.

Plan

High level

  • Invalidate cached instances whenever samples are rebound to a different model.
  • Add direct cache-invalidation tests for summary and full samples.
  • Add an end-to-end valid factor-graph regression in test mode.
  • Preserve the PyAutoGalaxy parameter guards and the narrow FitException rejection contract.
  • Run focused tests, the complete PyAutoFit suite, CI, and the complete Stage 3 rehearsal.

Detailed

  • Update SamplesSummary.subsamples and Samples.subsamples in the samples interface implementation to clear _instance after copying and before/while rebinding the model/path metadata.
  • Audit the adjacent with_paths/without_paths rebinding helpers for the same stale-cache invariant and cover/fix them if applicable.
  • Add unit tests that first warm the global .instance, then derive a child samples object and assert its instance is reconstructed using the child model and is not the global cached object.
  • Extend the existing fix: preserve guarded sample lifecycle #1466 factor-graph test area with a valid final-sample PYAUTO_TEST_MODE=1 case whose child results expose their expected per-analysis structure.
  • Retain existing tests proving non-FitException programming errors propagate.

Suggested branch: fix/factor-graph-subsamples-cache.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions