diff --git a/autolens/analysis/runtime_estimate.py b/autolens/analysis/runtime_estimate.py
index a9287f079..395ef85f2 100644
--- a/autolens/analysis/runtime_estimate.py
+++ b/autolens/analysis/runtime_estimate.py
@@ -149,57 +149,76 @@ class RuntimeEstimate:
def line(self) -> str:
"""
- The estimate as one log line, e.g.
+ The estimate as one log line, wall time first and the details in parentheses, e.g.
- `Estimate: ~1.9 ms/eval (hst cell) · Nautilus n_live=150 ≈ 2.1e5 evals (heuristic) · η=0.55 on
- 8 cores · ~7 min on this hardware`
+ `Estimate: ~6.4 min on this hardware (283 ms/eval, euclid cell · Nautilus n_live=50 ≈ 4.6e3
+ evals, heuristic · η=0.55)`
+
+ A band reads `Estimate: ~4–11 min (no size match; range across instruments) (...)`; a JAX
+ fit has `1 worker (JAX)` in place of `η`; an uncalibrated estimate ends its details with
+ `uncalibrated (held-out 0.2–0.5×)`; a search other than Nautilus reads
+ `Estimate: none for Emcee (the run-time model covers Nautilus only) (697 ms/eval, hst cell)`.
+ The worker count is not repeated (the fit's `Parallel:` line reports it).
"""
- parts = []
+ details = []
if self.ms_per_eval_band is not None:
low, high = self.ms_per_eval_band
- parts.append(f"~{_ms(low)}–{_ms(high)} ms/eval")
+ details.append(f"{_ms(low)}–{_ms(high)} ms/eval")
elif self.ms_per_eval is not None:
- parts.append(f"~{_ms(self.ms_per_eval)} ms/eval ({self.instrument} cell)")
+ details.append(f"{_ms(self.ms_per_eval)} ms/eval, {self.instrument} cell")
if not self.supported_search:
- parts.append(
- f"no estimate for {self.search_name} (run-time model covers Nautilus only)"
+ head = (
+ f"none for {self.search_name} (the run-time model covers Nautilus only)"
)
- return "Estimate: " + " · ".join(parts)
+ return _estimate_line(head, details)
if self.expected_evals_band is not None:
low, high = self.expected_evals_band
- parts.append(
- f"Nautilus n_live={self.n_live} ≈ {_evals(low)}–{_evals(high)} evals "
- f"(heuristic)"
+ details.append(
+ f"Nautilus n_live={self.n_live} ≈ {_evals(low)}–{_evals(high)} evals, "
+ f"heuristic"
)
elif self.expected_evals is not None:
- parts.append(
- f"Nautilus n_live={self.n_live} ≈ {_evals(self.expected_evals)} evals (heuristic)"
+ details.append(
+ f"Nautilus n_live={self.n_live} ≈ {_evals(self.expected_evals)} evals, heuristic"
)
if self.parallel_efficiency is not None:
- cores = "core" if self.number_of_cores == 1 else "cores"
- parts.append(
- f"η={self.parallel_efficiency:.2f} on {self.number_of_cores} {cores}"
- )
+ details.append(f"η={self.parallel_efficiency:.2f}")
elif self.backend == "jax":
- parts.append("1 worker (JAX)")
+ details.append("1 worker (JAX)")
+
+ if not self.calibrated:
+ details.append(self.note or UNCALIBRATED_NOTE)
if self.wall_seconds is not None:
- parts.append(f"~{_duration(self.wall_seconds)} on this hardware")
+ head = f"~{_duration(self.wall_seconds)} on this hardware"
elif self.wall_band is not None:
low, high = self.wall_band
- parts.append(
+ head = (
f"~{_duration_band(low, high)} (no size match; range across "
f"{self.band_across or 'instruments'})"
)
+ elif details:
+ # No wall time (the evaluation count is unknown): the per-evaluation cost leads.
+ head, details = details[0], details[1:]
+ else:
+ head = "none"
+
+ return _estimate_line(head, details)
- if not self.calibrated:
- parts.append(self.note or UNCALIBRATED_NOTE)
- return "Estimate: " + " · ".join(parts)
+def _estimate_line(head: str, details) -> str:
+ """
+ `Estimate:
( · ...)`, the label padded to the width of the fit's
+ `Setup:` / `Parallel:` labels; no parentheses when there are no details.
+ """
+ line = f"Estimate: {head}"
+ if details:
+ line += f" ({' · '.join(details)})"
+ return line
def _evals(value: int) -> str:
@@ -635,9 +654,9 @@ class AnalysisRuntimeEstimate:
wraps PyAutoGalaxy's `AnalysisSetupMixin.resolve_setup`.
"""
- def resolve_setup(self, model):
+ def resolve_setup(self, model, log_banner: bool = True):
self._runtime_estimate_model = model
- return super().resolve_setup(model=model)
+ return super().resolve_setup(model=model, log_banner=log_banner)
def _runtime_likelihood_from(self, model) -> Optional[str]:
"""
diff --git a/test_autolens/analysis/test_runtime_estimate.py b/test_autolens/analysis/test_runtime_estimate.py
index 00eed5afc..b5ab6ed47 100644
--- a/test_autolens/analysis/test_runtime_estimate.py
+++ b/test_autolens/analysis/test_runtime_estimate.py
@@ -6,6 +6,7 @@
"""
import logging
+import re
from types import SimpleNamespace
import pytest
@@ -169,7 +170,10 @@ def test__interferometer__matched_by_visibilities__uncalibrated(n_vis, instrumen
assert estimate.matched_by == "size"
assert estimate.instrument == instrument
assert estimate.calibrated is False
- assert estimate.line().endswith(" · uncalibrated (held-out 0.2–0.5×)")
+ line = estimate.line()
+ assert line.startswith("Estimate: ~")
+ assert " on this hardware (" in line
+ assert line.endswith(" · uncalibrated (held-out 0.2–0.5×))")
def test__interferometer__real_dataset__size_from_visibilities(interferometer_7):
@@ -190,7 +194,13 @@ def test__no_size__several_instruments__band():
assert estimate.wall_seconds is None
low, high = estimate.wall_band
assert low < high
- assert "(no size match; range across instruments)" in estimate.line()
+ line = estimate.line()
+ assert re.match(
+ r"Estimate: ~[0-9.]+–[0-9.]+ \w+ \(no size match; range across instruments\) "
+ r"\([0-9.]+–[0-9.]+ ms/eval · Nautilus n_live=\d+ ≈ [0-9.e–]+ evals, "
+ r"heuristic · η=[0-9.]+\)$",
+ line,
+ ), line
def test__point__unknown_positions_fit__band_across_likelihoods(point_dataset):
@@ -278,8 +288,8 @@ def test__non_nautilus__no_estimate_line():
assert estimate.wall_seconds is None
assert estimate.expected_evals is None
assert estimate.line() == (
- "Estimate: ~697 ms/eval (hst cell) · no estimate for Emcee "
- "(run-time model covers Nautilus only)"
+ "Estimate: none for Emcee (the run-time model covers Nautilus only) "
+ "(697 ms/eval, hst cell)"
)
@@ -316,7 +326,8 @@ def test__numba__efficiency_applied__wall_model():
assert estimate.parallel_efficiency == pytest.approx(0.55)
assert estimate.number_of_cores == 8
assert estimate.wall_seconds == pytest.approx(30 + evals * (0.014 + per_call))
- assert "η=0.55 on 8 cores" in estimate.line()
+ assert "· η=0.55)" in estimate.line()
+ assert "cores" not in estimate.line()
def test__numba__efficiency_between_sweep_points__next_lower():
@@ -348,7 +359,7 @@ def test__jax__per_call_as_is__one_worker():
assert estimate.parallel_efficiency is None
assert estimate.number_of_cores == 1
assert estimate.wall_seconds == pytest.approx(30 + evals * (0.014 + 0.0246826))
- assert "1 worker (JAX)" in estimate.line()
+ assert estimate.line().endswith(" · 1 worker (JAX))")
assert "η=" not in estimate.line()
@@ -363,9 +374,84 @@ def test__line__one_line_format():
).line()
assert "\n" not in line
- assert line.startswith("Estimate: ~697 ms/eval (hst cell) · Nautilus n_live=150 ≈ ")
- assert "evals (heuristic) · η=0.55 on 8 cores · ~" in line
- assert line.endswith(" on this hardware")
+ assert re.match(
+ r"Estimate: ~[0-9.]+ (s|min|h|d) on this hardware \(697 ms/eval, hst cell · "
+ r"Nautilus n_live=150 ≈ [0-9.]+e\d+ evals, heuristic · η=0\.55\)$",
+ line,
+ ), line
+
+
+def _estimate(**kwargs):
+ defaults = dict(
+ ms_per_eval=283.0,
+ record_id="r",
+ instrument="euclid",
+ matched_by="size",
+ expected_evals=4600,
+ evals_model="nautilus-heuristic",
+ parallel_efficiency=0.55,
+ number_of_cores=8,
+ wall_seconds=6.4 * 60,
+ wall_band=None,
+ calibrated=True,
+ n_live=50,
+ search_name="Nautilus",
+ )
+ defaults.update(kwargs)
+ return re_mod.RuntimeEstimate(**defaults)
+
+
+def test__line__variants():
+ assert _estimate().line() == (
+ "Estimate: ~6.4 min on this hardware (283 ms/eval, euclid cell · "
+ "Nautilus n_live=50 ≈ 4.6e3 evals, heuristic · η=0.55)"
+ )
+
+ assert _estimate(
+ ms_per_eval=0.065,
+ instrument="simple",
+ parallel_efficiency=None,
+ number_of_cores=1,
+ backend="jax",
+ wall_seconds=45.0,
+ ).line() == (
+ "Estimate: ~45 s on this hardware (0.065 ms/eval, simple cell · "
+ "Nautilus n_live=50 ≈ 4.6e3 evals, heuristic · 1 worker (JAX))"
+ )
+
+ assert _estimate(
+ ms_per_eval=231.0,
+ instrument="sma",
+ calibrated=False,
+ note="uncalibrated (held-out 0.2–0.5×)",
+ ).line() == (
+ "Estimate: ~6.4 min on this hardware (231 ms/eval, sma cell · "
+ "Nautilus n_live=50 ≈ 4.6e3 evals, heuristic · η=0.55 · "
+ "uncalibrated (held-out 0.2–0.5×))"
+ )
+
+ assert _estimate(
+ instrument=None,
+ matched_by="band",
+ wall_seconds=None,
+ wall_band=(4 * 60, 11 * 60),
+ ms_per_eval_band=(28.0, 697.0),
+ expected_evals=None,
+ expected_evals_band=(4600, 4600),
+ ).line() == (
+ "Estimate: ~4–11 min (no size match; range across instruments) "
+ "(28–697 ms/eval · Nautilus n_live=50 ≈ 4.6e3–4.6e3 evals, heuristic · η=0.55)"
+ )
+
+ assert _estimate(
+ supported_search=False,
+ search_name="Emcee",
+ expected_evals=None,
+ wall_seconds=None,
+ ).line() == (
+ "Estimate: none for Emcee (the run-time model covers Nautilus only) "
+ "(283 ms/eval, euclid cell)"
+ )
# Analysis hooks
@@ -440,9 +526,10 @@ def test__analysis__interferometer__estimate_line(interferometer_7):
search=Nautilus(), model=_rectangular_model(), number_of_cores=4
)
- assert line.startswith("Estimate: ~231 ms/eval (sma cell)")
- assert "η=0.62 on 4 cores" in line
- assert line.endswith("uncalibrated (held-out 0.2–0.5×)")
+ assert line.startswith("Estimate: ~")
+ assert " (231 ms/eval, sma cell · " in line
+ assert "· η=0.62 · " in line
+ assert line.endswith("uncalibrated (held-out 0.2–0.5×))")
def test__analysis__point__estimate_line_from_positions_fit(point_dataset):
@@ -457,8 +544,8 @@ def test__analysis__point__estimate_line_from_positions_fit(point_dataset):
search=Nautilus(), model=_rectangular_model(), number_of_cores=1
)
- assert line.startswith("Estimate: ~0.065 ms/eval (simple cell)")
- assert "1 worker (JAX)" in line
+ assert " on this hardware (0.065 ms/eval, simple cell · " in line
+ assert line.endswith(" · 1 worker (JAX))")
assert analysis.resources_per_eval()["peak_rss_gb"] == pytest.approx(0.5467)
@@ -482,8 +569,9 @@ def test__hook__resolve_fit_parallel_logs_estimate(masked_imaging_7x7, caplog):
assert resolution.number_of_cores == 8
estimates = [r.message for r in caplog.records if r.message.startswith("Estimate:")]
assert len(estimates) == 1
- assert estimates[0].startswith("Estimate: ~283 ms/eval (euclid cell)")
- assert "η=0.55 on 8 cores" in estimates[0]
+ assert estimates[0].startswith("Estimate: ~")
+ assert " on this hardware (283 ms/eval, euclid cell · " in estimates[0]
+ assert estimates[0].endswith(" · η=0.55)")
def test__hook__auto_cores_capped_by_peak_rss(masked_imaging_7x7, monkeypatch):
diff --git a/test_autolens/imaging/model/test_analysis_imaging_setup.py b/test_autolens/imaging/model/test_analysis_imaging_setup.py
index 4adb7bf39..8635a38fc 100644
--- a/test_autolens/imaging/model/test_analysis_imaging_setup.py
+++ b/test_autolens/imaging/model/test_analysis_imaging_setup.py
@@ -118,9 +118,10 @@ def test__setup_auto__cpu_many_core_rectangular__numba_sparse_operator__numpy_xp
assert analysis.dataset.setup == analysis.setup
assert isinstance(analysis.dataset.sparse_operator, SparseLinAlgImagingNumba)
- banners = [r.message for r in caplog.records if r.message.startswith("Setup: ")]
- assert len(banners) == 1
- assert banners[0].startswith("Setup: numba/cpu/sparse/fp64")
+ banners = [r.message for r in caplog.records if r.message.startswith("Setup:")]
+ assert banners == [
+ "Setup: numba · CPU · sparse operator · fp64 (rule imaging/rectangular)"
+ ]
def test__setup_auto__a100_rectangular__jax_dense__jax_xp(
@@ -150,9 +151,9 @@ def test__modify_before_fit__resolves_setup_once(masked_imaging_7x7, monkeypatch
original = al.AnalysisImaging.resolve_setup
- def counting(self, model):
+ def counting(self, model, **kwargs):
calls["n"] += 1
- return original(self, model=model)
+ return original(self, model=model, **kwargs)
monkeypatch.setattr(al.AnalysisImaging, "resolve_setup", counting)
@@ -201,10 +202,10 @@ def test__no_setup__dataset_and_backend_unchanged(
assert analysis._use_jax is False
assert analysis.setup is None
- lines = [r.message for r in caplog.records if r.message.startswith("Setup: ")]
+ lines = [r.message for r in caplog.records if "ompute setup" in r.message]
assert lines == [
- "Setup: auto would choose numba_cpu_sparse_fp64 (rule "
- 'imaging-rectangular-standard-cpu-many-core); pass setup="auto" to use it'
+ "Compute setup: not set (auto would choose numba · CPU · sparse operator · fp64; "
+ 'pass setup="auto")'
]
paths = af.DirectoryPaths(name="no_setup", path_prefix=str(tmp_path))
diff --git a/test_autolens/point/model/test_analysis_point_setup.py b/test_autolens/point/model/test_analysis_point_setup.py
index 46e320b01..0672a03a4 100644
--- a/test_autolens/point/model/test_analysis_point_setup.py
+++ b/test_autolens/point/model/test_analysis_point_setup.py
@@ -110,11 +110,9 @@ def test__setup_auto__image_plane__jax_na__banner_and_setup_json(
assert analysis._use_jax is True
assert analysis._xp is jnp
- banners = [r.message for r in caplog.records if r.message.startswith("Setup: ")]
+ banners = [r.message for r in caplog.records if r.message.startswith("Setup:")]
assert banners == [
- "Setup: jax/cpu/na/fp64 (64 CPU cores) · rule "
- "point-source-image-image-plane-standard-cpu-many-core · optimal (decision "
- "point-source-image-image-plane-standard-cpu-many-core) · override: PYAUTO_SETUP"
+ "Setup: JAX · CPU · no operator · fp64 (rule point_source_image/image_plane)"
]
paths = af.DirectoryPaths(name="point_setup", path_prefix=str(tmp_path))
@@ -187,10 +185,10 @@ def test__no_setup__unchanged__would_choose_logged(
assert analysis.setup is None
assert analysis._use_jax is False
- lines = [r.message for r in caplog.records if r.message.startswith("Setup: ")]
+ lines = [r.message for r in caplog.records if "ompute setup" in r.message]
assert lines == [
- "Setup: auto would choose jax_cpu_na_fp64 (rule "
- 'point-source-image-image-plane-standard-cpu-many-core); pass setup="auto" to use it'
+ "Compute setup: not set (auto would choose JAX · CPU · no operator · fp64; "
+ 'pass setup="auto")'
]
paths = af.DirectoryPaths(name="point_no_setup", path_prefix=str(tmp_path))
diff --git a/test_autolens/weak/test_analysis.py b/test_autolens/weak/test_analysis.py
index 806c9ef22..7306932df 100644
--- a/test_autolens/weak/test_analysis.py
+++ b/test_autolens/weak/test_analysis.py
@@ -170,9 +170,8 @@ def test__setup_auto__weak_isothermal__jax_dense__banner_and_setup_json(
assert analysis._use_jax is True
assert analysis._xp is jnp
- banners = [r.message for r in caplog.records if r.message.startswith("Setup: ")]
- assert len(banners) == 1
- assert banners[0].startswith("Setup: jax/cpu/dense/fp64 (64 CPU cores) · rule weak-isothermal")
+ banners = [r.message for r in caplog.records if r.message.startswith("Setup:")]
+ assert banners == ["Setup: JAX · CPU · dense · fp64 (rule weak/isothermal)"]
paths = af.DirectoryPaths(name="weak_setup", path_prefix=str(tmp_path))
analysis.save_attributes(paths=paths)
@@ -209,10 +208,9 @@ def test__no_setup__weak_unchanged(detect_many_core, caplog, tmp_path):
assert analysis._use_jax is False
assert analysis.dataset is dataset
- lines = [r.message for r in caplog.records if r.message.startswith("Setup: ")]
+ lines = [r.message for r in caplog.records if "ompute setup" in r.message]
assert lines == [
- "Setup: auto would choose jax_cpu_dense_fp64 (rule "
- 'weak-isothermal-standard-cpu-many-core); pass setup="auto" to use it'
+ 'Compute setup: not set (auto would choose JAX · CPU · dense · fp64; pass setup="auto")'
]
paths = af.DirectoryPaths(name="weak_no_setup", path_prefix=str(tmp_path))