Skip to content

fix: call analysis.save_results from the test-mode bypass - #1626

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/test-mode-bypass-save-results
Sep 14, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/test-mode-bypass-save-results

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Fixes #1624. AbstractSearch._fit_bypass_test_mode — the sampler bypass behind PYAUTO_TEST_MODE=2 and =3 — wrote samples, samples_summary and the .completed marker but never called analysis.save_results / analysis.save_results_combined, which the normal path (start_resume_fit) calls unconditionally. Its docstring promised "all expected output files so that downstream code sees a complete result folder", so any script that writes a file in save_results and reads it back after the fit failed under smoke.

That is the whole of Heart's autofit workspace-smoke failure (cloud run 34824535982): autofit_workspace overview/overview_2_scientific_workflow, both .py and .ipynb, ending in FileNotFoundError: .../files/science_summary.json at script line 279. The gap predates the recent PyAutoFit commits — it arrived with modes 2/3 in d41aa53e8.

The bypass now runs both hooks between make_result and paths.completed(), in the same position and with the same arguments as the normal path. They are deliberately not gated on skip_fit_output(): the normal path does not gate them either, and the smoke profile that exposed the bug sets PYAUTO_SKIP_FIT_OUTPUT=1, so gating them would reproduce the bug under exactly the conditions this fix targets.

API Changes

None — internal changes only. Analysis.save_results / save_results_combined are unchanged public hooks; the bypass simply stops skipping them, so a mode-2/3 fit now reaches the same hooks a normal fit always did.

Test Plan

  • New TestBypassCallsSaveResults, parametrised over PYAUTO_TEST_MODE "2" and "3", asserts both hooks run exactly once with the fit's own paths and result. Control: with the source change stashed it fails in both modes, so the test is a real falsifier rather than a passing bystander.
  • pytest test_autofit/non_linear/search/test_abstract_search.py -k bypass → 18 passed, 20 deselected.
  • Full suite pytest test_autofit → see the run summary in the PR thread.
  • Downstream witness, the script Heart fails on. Run from the canonical autofit_workspace root with this branch's autofit on PYTHONPATH (verified via autofit.__file__), output cleared between runs so the .completed marker could not shortcut the bypass:
    • PYAUTO_TEST_MODE=2 … python3 scripts/overview/overview_2_scientific_workflow.py → exit 0, and line 279's print(search.paths.load_json("science_summary")) prints the summary it wrote.
    • PYAUTO_TEST_MODE=3 … (same) → exit 0, same print.
    • Control first: the identical mode-2 command against canonical PyAutoFit (main) reproduces FileNotFoundError: .../files/science_summary.json at overview_2_scientific_workflow.py:279.

Downstream workspace impact

No API change and no workspace edit needed — this is option (iii), confirmed by the witness above rather than by inference.

  • Three workspace scripts define a custom save_results: autofit_workspace/scripts/overview/overview_2_scientific_workflow.py, scripts/cookbooks/analysis.py, scripts/cookbooks/result.py. Only overview_2 round-trips its own file, which is why it is the only smoke failure; the two cookbooks write and never read back, and gain the write they were always meant to get.
  • Expected Heart effect: autofit overview/overview_2_scientific_workflow.{py,ipynb} go green in workspace-smoke, clearing 2 of the 3 workspace-validation failures in the current YELLOW (the third is autolens notebooks/imaging/slam.ipynb, unrelated).
  • PyAutoHands/autohands/config/no_run.yaml no longer exists in the tree, so there is no disabled-integration hidden risk to check against.
  • Note for a separate workspace task: overview_2 is absent from autofit_workspace/smoke_tests.txt, so the list-driven local smoke does not cover it — only Heart's cloud run does.

Readiness

Heart readiness --json is YELLOW, the same reason set the human acknowledged when approving this task (recorded as heart-ack: on the active.md row): workspace validation not passing (3 failed, cloud#34824535982); manifest drift x2; profiling drift x6; release validation incomplete. No RED reasons. Two of those three workspace failures are what this PR repairs.

Full API Changes (for automation & release notes)

Changed Behaviour

  • autofit.non_linear.search.abstract_search.AbstractSearch — a fit bypassed by PYAUTO_TEST_MODE=2 or =3 now calls analysis.save_results(paths=…, result=…) and analysis.save_results_combined(paths=…, result=…) before marking the fit complete, matching the non-bypassed path. No signatures changed and no symbols added, removed or renamed.

Migration

  • None. Scripts that already override save_results need no change; they simply start being called under test modes 2 and 3, as they always were outside them.

Generated by the PyAutoLabs agent workflow.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RbJGue5FwUPbxvCFKwXNam

`_fit_bypass_test_mode` — the sampler bypass behind `PYAUTO_TEST_MODE=2` and
`=3` — wrote `samples`, `samples_summary` and the `.completed` marker but never
ran the analysis' own output hooks, which `start_resume_fit` calls
unconditionally. Its docstring promised "all expected output files so that
downstream code sees a complete result folder", so any script that writes a file
in `save_results` and reads it back after the fit failed under smoke:
autofit_workspace `overview/overview_2_scientific_workflow` (`.py` and `.ipynb`)
died on a missing `science_summary.json` in Heart workspace-smoke run
34824535982. The gap predates the recent commits — it arrived with modes 2/3 in
d41aa53.

The bypass now calls `analysis.save_results` and `analysis.save_results_combined`
between `make_result` and `paths.completed()`, in the same position and with the
same arguments as the normal path. They are deliberately not gated on
`skip_fit_output()`: the normal path does not gate them either, and the smoke
profile that exposed the bug sets `PYAUTO_SKIP_FIT_OUTPUT=1`, so gating would
reproduce the bug under exactly the conditions this fix targets.

Tested by a new `TestBypassCallsSaveResults`, parametrised over modes 2 and 3,
which asserts both hooks run once with the fit's own `paths` and `result`. It
fails in both modes without the source change.

Refs #1624

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RbJGue5FwUPbxvCFKwXNam
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Sep 14, 2026
@Jammy2211
Jammy2211 merged commit 559699f into main Sep 14, 2026
4 checks passed
@Jammy2211
Jammy2211 deleted the feature/test-mode-bypass-save-results branch September 14, 2026 20:25
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: test-mode bypass never calls analysis.save_results

1 participant