feat(test_mode): add with_test_mode_segment helper for path composition#110
Merged
Conversation
Workspace scripts that compose their own output paths manually (e.g.
autolens_workspace and autogalaxy_workspace `guides/results/aggregator/`
tutorials) need to agree with PyAutoFit's internal `_test_mode_segment`
(`autofit/non_linear/paths/abstract.py`), which inserts
`output/test_mode/...` whenever PYAUTO_TEST_MODE is set.
The internal helper is private; expose the same rule as a public
autoconf helper so workspace scripts can compose
results_path = with_test_mode_segment(Path("output")) / "results_folder"
…and land in the same directory the search wrote to. For end-users
running with no env vars set, the path stays `output/results_folder/`
unchanged.
Name avoids the `test_` prefix so pytest doesn't try to collect
workspace-script callsites as test functions.
7 unit tests added covering env unset / "0" / "1"/"2"/"3" / chaining
with `/`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Adds
autoconf.test_mode.with_test_mode_segment(base) -> Path— a public helper that returnsbase / "test_mode"whenPYAUTO_TEST_MODEis set, elsebaseunchanged. Mirrors the namespacing rule PyAutoFit already applies internally via_test_mode_segmentinautofit/non_linear/paths/abstract.py:25.Why
autolens_workspaceandautogalaxy_workspaceshipguides/results/aggregator/tutorials that share an output directory across two processes — a_quick_fit.pyhelper (writes via a Nautilus search) anddata_fitting.py/samples.py/etc. (read viaAggregator.from_directory). The tutorials currently hard-code:Under
PYAUTO_TEST_MODE=2(smoke), the search lands atoutput/test_mode/results_folder/...while the readers look atoutput/results_folder/→NoneTypefrommask_header_fromandFigure of merit sanity check failed(triage clusters C15 + C2, 6 scripts).Workspace PRs (linked below once opened) thread this helper through.
Naming choice
with_test_mode_segment— leading word iswith_, nottest_. This matters because pytest collects everytest_*function in test modules as a test (we hit this on the first attempt — pytest tried to runtest_mode_output_pathwith a missingbasefixture). The chosen name reads naturally at the callsite:Test plan
pytest test_autoconf/test_test_mode.py -v— 7/7 pass (env unset, env"0", env"1"/"2"/"3", pathlib chaining).pytest test_autoconf— 102/102 pass, no regressions.Related PRs
with_test_mode_segmentthrough_quick_fit.py+ 7 aggregator tutorials.🤖 Generated with Claude Code