Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions autofit/non_linear/paths/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import numpy as np

from autoconf import conf
from autoconf.test_mode import is_test_mode
from autofit.mapper.identifier import Identifier, IdentifierField
from autofit.non_linear.samples.summary import SamplesSummary

Expand All @@ -24,15 +25,15 @@

def _test_mode_segment() -> Optional[str]:
"""
Returns ``"test_mode"`` when ``PYAUTO_TEST_MODE`` is set in the
environment, else ``None``.
Returns ``"test_mode"`` when ``PYAUTO_TEST_MODE`` is active, else
``None``.
Comment on lines +28 to +29

Inserted into the output-path composition so that smoke runs land
under ``output/test_mode/...`` instead of sharing a directory with
real runs. Without this, a cached test-mode result short-circuits
a later real run at the same paths ("Fit Already Completed").
"""
return "test_mode" if os.environ.get("PYAUTO_TEST_MODE") else None
return "test_mode" if is_test_mode() else None


class AbstractPaths(ABC):
Expand Down Expand Up @@ -66,7 +67,7 @@ def __init__(

/path/to/output/folder_0/folder_1/name

If the ``PYAUTO_TEST_MODE`` environment variable is set, a
If the ``PYAUTO_TEST_MODE`` environment variable is active, a
``test_mode`` segment is inserted directly after the output
root:

Expand Down Expand Up @@ -497,4 +498,4 @@ def output_model_results(self, result_info):
filename = self.output_path / "model.results"

with open_(filename, "w") as f:
f.write(result_info)
f.write(result_info)
5 changes: 5 additions & 0 deletions test_autofit/non_linear/paths/test_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ def test_output_path_excludes_segment_when_env_unset(self, monkeypatch):
paths = af.DirectoryPaths(name="name", path_prefix="prefix")
assert "test_mode" not in paths.output_path.parts

def test_output_path_excludes_segment_when_env_zero(self, monkeypatch):
monkeypatch.setenv("PYAUTO_TEST_MODE", "0")
paths = af.DirectoryPaths(name="name", path_prefix="prefix")
assert "test_mode" not in paths.output_path.parts

def test_make_path_contains_segment_when_env_set(self, monkeypatch):
monkeypatch.setenv("PYAUTO_TEST_MODE", "2")
paths = af.DirectoryPaths(name="name", path_prefix="prefix")
Expand Down
Loading