Add PYAUTOFIT_TEST_MODE levels 2 and 3 to bypass sampler#1180
Merged
Jammy2211 merged 1 commit intomain_buildfrom Apr 6, 2026
Merged
Add PYAUTOFIT_TEST_MODE levels 2 and 3 to bypass sampler#1180Jammy2211 merged 1 commit intomain_buildfrom
Jammy2211 merged 1 commit intomain_buildfrom
Conversation
Level 2 skips the sampler but calls the likelihood function once to verify it works. Level 3 skips both sampler and likelihood for maximum speed. Both produce the full output folder structure for downstream compatibility. Also centralizes scattered os.environ test mode checks into a shared test_mode.py module with is_test_mode() and test_mode_level() helpers, and improves log messages to describe each level's behavior. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Apr 6, 2026
Collaborator
Author
|
Workspace PRs: |
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 two new test mode levels that bypass the sampler entirely, enabling much faster integration/smoke testing. Level 2 calls the likelihood function once (to verify it works), level 3 skips everything for maximum speed. Both produce the full output folder structure so downstream code works unchanged.
Also centralizes all scattered
os.environ.get("PYAUTOFIT_TEST_MODE")checks into a sharedtest_mode.pymodule and improves log messages to describe each level's behavior.Timing on
model_fit.py: mode 1 ~71s → mode 2 ~37s → mode 3 ~32s.Closes #1179
API Changes
Added
autofit.non_linear.test_modemodule withis_test_mode()andtest_mode_level()public helpers. ExistingPYAUTOFIT_TEST_MODE=1behavior is unchanged. New levels 2 and 3 are opt-in via the same environment variable.See full details below.
Test Plan
Full API Changes (for automation & release notes)
Added
autofit.non_linear.test_mode.test_mode_level()— returns current test mode level (0-3)autofit.non_linear.test_mode.is_test_mode()— returns True if any test mode is activeAbstractSearch._fit_bypass_test_mode(model, analysis, call_likelihood)— internal method to bypass sampler in modes 2/3AbstractSearch._build_fake_samples(model, parameter_vector, log_likelihood)— internal method to build minimal Sample objects for bypass modePYAUTOFIT_TEST_MODE=2— bypass sampler, call likelihood oncePYAUTOFIT_TEST_MODE=3— bypass sampler and likelihood entirelyChanged Behaviour
os.environ.get("PYAUTOFIT_TEST_MODE") == "1"checks replaced withis_test_mode()which returns True for levels 1, 2, and 3Migration
PYAUTOFIT_TEST_MODE=1behavior is unchangedfrom autofit.non_linear.test_mode import is_test_modeinstead of checking the env var directly🤖 Generated with Claude Code