Skip to content

fix: PYAUTO_TEST_MODE should write to a separate output dir - #1292

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/test-mode-output-path
May 22, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/test-mode-output-path

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

When a script is smoke-tested under PYAUTO_TEST_MODE and then run for real, AutoFit silently returns the cached test-mode result ("Fit Already Completed: skipping non-linear search") because the output path is identical between the two runs. The proper run never happens — symptom is every recovered σ on the supposedly-real run being exactly 0.

This PR namespaces the test-mode output path so smoke and prod outputs are physically co-resident under output/test_mode/... and cannot collide. The previous workaround — rm -rf output/<path-prefix>/ before the first proper run — is no longer required.

API Changes

No public symbol additions, removals, or signature changes.

Behaviour change: when the PYAUTO_TEST_MODE environment variable is set (any truthy value), AutoFit search output paths get a test_mode/ segment inserted directly after conf.instance.output_path. This affects every search-output path including SQLite database files opened via open_database() with a relative filename.

See full details below.

Test Plan

  • New regression tests in test_autofit/non_linear/paths/test_paths.py cover both output_path and _make_path with PYAUTO_TEST_MODE set vs unset (4 tests, all pass)
  • Full PyAutoFit unit suite: 1408 passed / 1 skipped / 0 failed
  • Validation sweep across workspaces (/health_check + per-workspace /smoke_test on autofit/autogalaxy/autolens workspaces + ic50_workspace) — see linked issue. Risk being checked: any script that secretly relied on smoke and prod sharing an output path

Closes #1291

Full API Changes (for automation & release notes)

Removed

None.

Added

  • autofit.non_linear.paths.abstract._test_mode_segment() — private module-level helper returning "test_mode" when PYAUTO_TEST_MODE env var is set, else None.

Renamed

None.

Changed Signature

None.

Changed Behaviour

  • AbstractPaths.output_path property — when PYAUTO_TEST_MODE is set, the returned path includes a test_mode/ segment right after the configured output root.
  • DirectoryPaths._make_path() — same test_mode/ segment injection when env var is set.
  • autofit.database.open_database(filename) — when called with a relative filename ending in .sqlite, the resolved path is prefixed with test_mode/ under the output root when env var is set. Absolute filenames are unchanged.

Migration

No code changes required for callers. After this lands, you can stop running rm -rf output/<path-prefix>/ between a smoke run and a real run at the same paths.

🤖 Generated with Claude Code

When PYAUTO_TEST_MODE is set, AutoFit now writes search output to
output/test_mode/... instead of output/.... Without this, a smoke-test
run cached its result at the same path as a later real run, and the
real run silently short-circuited with "Fit Already Completed".

Adds a private _test_mode_segment() helper in
autofit.non_linear.paths.abstract and threads it through the three
sites that compose paths from conf.instance.output_path:

- AbstractPaths.output_path (paths/abstract.py)
- DirectoryPaths._make_path (paths/directory.py)
- open_database with a relative filename (database/__init__.py)

SubDirectoryPaths inherits the fix via self.parent.output_path.

Regression tests added covering output_path and _make_path
with/without the env var.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Jammy2211

Copy link
Copy Markdown
Collaborator Author

@Jammy2211
Jammy2211 merged commit f6fec6f into main May 22, 2026
7 checks passed
@Jammy2211
Jammy2211 deleted the feature/test-mode-output-path branch May 22, 2026 17:57
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Sep 4, 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: PYAUTO_TEST_MODE should write to a separate output dir

1 participant