Skip to content

Commit f0e1e69

Browse files
Jammy2211claude
authored andcommitted
refactor: separate PYAUTOFIT_TEST_MODE into distinct PYAUTO_* env vars
Split the catch-all PYAUTOFIT_TEST_MODE into purpose-specific variables: - PYAUTO_TEST_MODE (sampler speedup, levels 0-3) - PYAUTO_SKIP_FIT_OUTPUT (pre/post-fit I/O, VRAM, result text) - PYAUTO_SKIP_VISUALIZATION (fit visualization and plotting) - PYAUTO_SKIP_CHECKS (mesh validation, position resampling, weight thresholds) Also renames: - PYAUTOARRAY_OUTPUT_MODE -> PYAUTO_OUTPUT_MODE - PYAUTO_WORKSPACE_SMALL_DATASETS -> PYAUTO_SMALL_DATASETS Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent dae5a94 commit f0e1e69

9 files changed

Lines changed: 21 additions & 22 deletions

File tree

autofit/non_linear/analysis/analysis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,9 @@ def print_vram_use(self, model, batch_size : int) -> str:
328328
batch_size
329329
The batch size to profile, which is the number of model evaluations JAX will perform simultaneously.
330330
"""
331-
from autofit.non_linear.test_mode import test_mode_level
331+
from autofit.non_linear.test_mode import skip_fit_output
332332

333-
if test_mode_level() >= 2:
333+
if skip_fit_output():
334334
return
335335

336336
if not self._use_jax:

autofit/non_linear/analysis/visualize.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from autofit.mapper.prior_model.abstract import AbstractPriorModel
77
from autofit.non_linear.paths.database import DatabasePaths
88
from autofit.non_linear.paths.null import NullPaths
9-
from autofit.non_linear.test_mode import is_test_mode
9+
from autofit.non_linear.test_mode import skip_visualization
1010

1111
class Visualizer:
1212

@@ -41,7 +41,7 @@ def should_visualize(
4141
A bool determining whether visualization should be performed or not.
4242
"""
4343

44-
if is_test_mode():
44+
if skip_visualization():
4545
return False
4646

4747
if isinstance(paths, DatabasePaths) or isinstance(paths, NullPaths):

autofit/non_linear/fitness.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,8 @@ def check_log_likelihood(self, fitness):
456456
"""
457457
import numpy as np
458458

459-
from autofit.non_linear.test_mode import is_test_mode
460-
if is_test_mode():
459+
from autofit.non_linear.test_mode import skip_fit_output
460+
if skip_fit_output():
461461
return
462462

463463
if not conf.instance["general"]["test"]["check_likelihood_function"]:

autofit/non_linear/plot/plot_util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55

66
import numpy as np
77

8-
from autofit.non_linear.test_mode import is_test_mode
8+
from autofit.non_linear.test_mode import skip_visualization
99

1010
logger = logging.getLogger(__name__)
1111

1212

1313
def skip_in_test_mode(func):
1414
@wraps(func)
1515
def wrapper(*args, **kwargs):
16-
if is_test_mode():
16+
if skip_visualization():
1717
return
1818
return func(*args, **kwargs)
1919

autofit/non_linear/samples/samples.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from autoconf.class_path import get_class_path
1414
from autofit import exc
1515
from autofit.mapper.model import ModelInstance
16-
from autofit.non_linear.test_mode import is_test_mode
16+
from autofit.non_linear.test_mode import skip_checks
1717
from autofit.mapper.prior_model.abstract import AbstractPriorModel
1818
from autofit.non_linear.samples.sample import Sample
1919

@@ -379,7 +379,7 @@ def samples_above_weight_threshold_from(
379379
if weight_threshold is None:
380380
weight_threshold = conf.instance["output"]["samples_weight_threshold"]
381381

382-
if is_test_mode():
382+
if skip_checks():
383383
weight_threshold = None
384384

385385
if weight_threshold is None:

autofit/non_linear/search/abstract_search.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
from autofit.graphical.expectation_propagation import AbstractFactorOptimiser
5050

5151
from autofit.non_linear.fitness import get_timeout_seconds
52-
from autofit.non_linear.test_mode import is_test_mode, test_mode_level
52+
from autofit.non_linear.test_mode import is_test_mode, test_mode_level, skip_fit_output
5353

5454
logger = logging.getLogger(__name__)
5555

@@ -497,15 +497,14 @@ class represented by model M and gives a score for their fitness.
497497
analysis = analysis.modify_before_fit(paths=self.paths, model=model)
498498
model.unfreeze()
499499

500-
mode = test_mode_level()
501-
if mode < 2:
500+
if not skip_fit_output():
502501
self.pre_fit_output(
503502
analysis=analysis,
504503
model=model,
505504
info=info,
506505
)
507506
else:
508-
# Bypass mode still needs the metadata + identifier files written
507+
# Skip mode still needs the metadata + identifier files written
509508
# so downstream aggregator scraping can discover the search
510509
# directory. `save_all` is lightweight (a handful of JSON dumps)
511510
# and skips the expensive `analysis.save_attributes` /
@@ -527,7 +526,7 @@ class represented by model M and gives a score for their fitness.
527526
model=model,
528527
)
529528

530-
if mode < 2:
529+
if not skip_fit_output():
531530
analysis = analysis.modify_after_fit(
532531
paths=self.paths, model=model, result=result
533532
)

autofit/non_linear/test_mode.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from autoconf.test_mode import test_mode_level, is_test_mode
1+
from autoconf.test_mode import test_mode_level, is_test_mode, skip_fit_output, skip_visualization, skip_checks
22

3-
__all__ = ["test_mode_level", "is_test_mode"]
3+
__all__ = ["test_mode_level", "is_test_mode", "skip_fit_output", "skip_visualization", "skip_checks"]

autofit/text/text_util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ def result_info_from(samples) -> str:
5555
Output the full model.results file, which include the most-likely model, most-probable model at 1 and 3
5656
sigma confidence and information on the maximum log likelihood.
5757
"""
58-
from autofit.non_linear.test_mode import test_mode_level
58+
from autofit.non_linear.test_mode import skip_fit_output
5959

60-
if test_mode_level() >= 2:
61-
return "[test mode — result info skipped]"
60+
if skip_fit_output():
61+
return "[fit output skipped — PYAUTO_SKIP_FIT_OUTPUT=1]"
6262

6363
results = []
6464

test_autofit/non_linear/test_initializer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def test__priors__samples_from_model__raise_exception_if_all_likelihoods_identic
8080

8181

8282
def test__priors__samples_in_test_mode():
83-
os.environ["PYAUTOFIT_TEST_MODE"] = "1"
83+
os.environ["PYAUTO_TEST_MODE"] = "1"
8484

8585
model = af.Model(af.m.MockClassx4)
8686
model.one = af.UniformPrior(lower_limit=0.099, upper_limit=0.101)
@@ -121,7 +121,7 @@ def test__priors__samples_in_test_mode():
121121

122122
assert figure_of_merit_list == [-1.0e99, -1.0e100]
123123

124-
os.environ["PYAUTOFIT_TEST_MODE"] = "0"
124+
os.environ["PYAUTO_TEST_MODE"] = "0"
125125

126126

127127
def test__ball__samples_sample_centre_of_priors():

0 commit comments

Comments
 (0)