Repository navigation
fix: call analysis.save_results from the test-mode bypass - #1626
Merged
Merged
Conversation
`_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
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
Fixes #1624.
AbstractSearch._fit_bypass_test_mode— the sampler bypass behindPYAUTO_TEST_MODE=2and=3— wrotesamples,samples_summaryand the.completedmarker but never calledanalysis.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 insave_resultsand reads it back after the fit failed under smoke.That is the whole of Heart's
autofitworkspace-smoke failure (cloud run 34824535982):autofit_workspaceoverview/overview_2_scientific_workflow, both.pyand.ipynb, ending inFileNotFoundError: .../files/science_summary.jsonat script line 279. The gap predates the recent PyAutoFit commits — it arrived with modes 2/3 ind41aa53e8.The bypass now runs both hooks between
make_resultandpaths.completed(), in the same position and with the same arguments as the normal path. They are deliberately not gated onskip_fit_output(): the normal path does not gate them either, and the smoke profile that exposed the bug setsPYAUTO_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_combinedare 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
TestBypassCallsSaveResults, parametrised overPYAUTO_TEST_MODE"2"and"3", asserts both hooks run exactly once with the fit's ownpathsandresult. 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.pytest test_autofit→ see the run summary in the PR thread.autofit_workspaceroot with this branch'sautofitonPYTHONPATH(verified viaautofit.__file__), output cleared between runs so the.completedmarker could not shortcut the bypass:PYAUTO_TEST_MODE=2 … python3 scripts/overview/overview_2_scientific_workflow.py→ exit 0, and line 279'sprint(search.paths.load_json("science_summary"))prints the summary it wrote.PYAUTO_TEST_MODE=3 …(same) → exit 0, same print.PyAutoFit(main) reproducesFileNotFoundError: .../files/science_summary.jsonatoverview_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.
save_results:autofit_workspace/scripts/overview/overview_2_scientific_workflow.py,scripts/cookbooks/analysis.py,scripts/cookbooks/result.py. Onlyoverview_2round-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.autofitoverview/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 isautolens notebooks/imaging/slam.ipynb, unrelated).PyAutoHands/autohands/config/no_run.yamlno longer exists in the tree, so there is no disabled-integration hidden risk to check against.overview_2is absent fromautofit_workspace/smoke_tests.txt, so the list-driven local smoke does not cover it — only Heart's cloud run does.Readiness
Heart
readiness --jsonis YELLOW, the same reason set the human acknowledged when approving this task (recorded asheart-ack:on theactive.mdrow): 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 byPYAUTO_TEST_MODE=2or=3now callsanalysis.save_results(paths=…, result=…)andanalysis.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
save_resultsneed 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