Repository navigation
Description
Overview
fix: preserve fixed model components in JSON round trips
Plan
Inspect ModelObject.dict and from_dict: zero-prior Models currently emit type instance. Preserve Model identity for explicit Model objects while retaining legacy instance deserialization. Add GraphSpec equality tests for all-fixed and parameterless nested models and existing serialization coverage; run full suite. The lens cookbook release-dependent wording update remains pending the library release, as specified in the prompt.
Tier: glance — merge mode: human /prm.
Detailed implementation plan
Primary repository: PyAutoFit. Current branch: main, clean; no existing open PR or active Mind claim at selection. Suggested branch: feature/fixed-model-json. Each task uses an isolated branch and is handled sequentially within the four-task request. Tests must pass before shipping; report blockers honestly. User authorized implementation of four linked dashboard tasks; no merge or release authorization. Heart: STALE locally, published feed unreachable.
Original Prompt
Starting prompt
af.Model.from_json writes zero-free-parameter components back as instances
Type: bug
Target: PyAutoFit
Repos:
- PyAutoFit
Themes: - serialization
- visualization
Difficulty: small
Autonomy: supervised
Priority: normal
Status: draft
Consequence: glance
Witness: Dumping and reloading (output_to_json/af.Model.from_json) aCollectionholding an all-fixedModeland a parameter-lessModelgivesGraphSpec.from_model(reloaded).to_dict()equal to the original's (test intest_autofit/graph_spec), and the lens cookbook's "reloaded figure differs" sentence is removed once released.
Review-minutes: 3
Filed: 2026-09-11
Found by the model figure while adding it to autolens_workspace/scripts/guides/modeling/cookbook.py
(model-figures epic phase 3, PyAutoLens#736). The cookbook's __JSon Outputs__ stage dumps a model
with model.output_to_json and reloads it with af.Model.from_json. model.info looks unchanged,
but the reloaded model is not the same model: every component with zero free parameters comes
back as a plain instance instead of an af.Model — in the Solved Parameters model the Delaunay
mesh (all-fixed pixels/zeroed_pixels/areas_factor) and the whole point_source galaxy
(PointSolved has no parameters) collapse to single fixed pills. af.ModelPlotter shows it
directly: fixed leaf slots drop 6 → 4 and solved rows 3 → 2 across the round trip, and
GraphSpec.from_model(...).to_dict() differs. The galaxy cookbook's model (every component has a
free parameter) round-trips byte-identically, so the trigger is the zero-free-parameter case.
Ask
- Reproduce with
test_autofit/graph_specstyle: dump/reload aCollectionholding an all-fixed
Modeland a parameter-lessModel; assertGraphSpec.from_model(reloaded).to_dict()equals the
original's. - Decide whether
from_jsonshould preserveModel-ness for such components (likely: the JSON
already recordstype: model? checkautofit/mapper/prior_model/abstract.pyfrom_dict) and fix. - Until fixed the lens cookbook says the reloaded figure differs; revert that sentence when it no
longer does.
Activity
Jammy2211 commentedon Oct 17, 2026
Shipped
Merged #1708 at 48f1c31 on 2026-10-17, following the user's /prm authorization. fix: preserve explicitly fixed models across JSON round trips
All exact-head GitHub test legs passed (Python 3.12, 3.13, no-JAX); applicable docs checks passed. Model/search unique identifiers and exact output-folder paths were checked against unmodified main and remain unchanged. Pending release; merging does not publish a release. Remove the lens cookbook reload warning after the library fix is released; semantic GraphSpec fields and persistent identifiers are preserved, excluding pre-existing process-local counters.