From 0ea4d56c9d35a2776e46057db43e05d21eab8bc1 Mon Sep 17 00:00:00 2001 From: Dmitry Dementiev Date: Mon, 31 Aug 2026 15:16:10 +0300 Subject: [PATCH] =?UTF-8?q?fix(diarization):=20=D1=83=D1=87=D1=82=D1=91?= =?UTF-8?q?=D0=BD=20=D1=81=D0=B8=D1=81=D1=82=D0=B5=D0=BC=D0=BD=D1=8B=D0=B9?= =?UTF-8?q?=20power=20profile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Зачем: - часть Intel-стендов не публикует ACPI platform_profile - balanced-режим на таком стенде доступен через power-profiles-daemon Что: - добавлен fallback на powerprofilesctl get - поведение закреплено тестом Проверка: - uv run pytest -q tests/test_benchmark_experiment.py - uv run ruff check для изменённых файлов --- src/local_transcriber/benchmark_experiment.py | 20 ++++++++++++++++++- tests/test_benchmark_experiment.py | 13 ++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/local_transcriber/benchmark_experiment.py b/src/local_transcriber/benchmark_experiment.py index 1e5008e..8c8ac91 100644 --- a/src/local_transcriber/benchmark_experiment.py +++ b/src/local_transcriber/benchmark_experiment.py @@ -931,6 +931,24 @@ def _runtime_supply() -> str | None: return None +def _runtime_profile() -> str | None: + profile = _read_optional_text(Path("/sys/firmware/acpi/platform_profile")) + if profile is not None: + return profile + try: + completed = subprocess.run( + ["powerprofilesctl", "get"], + capture_output=True, + text=True, + check=False, + timeout=5, + ) + except (OSError, subprocess.TimeoutExpired): + return None + value = completed.stdout.strip() + return value or None if completed.returncode == 0 else None + + def _runtime_governor() -> str | None: values = { value @@ -1006,7 +1024,7 @@ def runtime_guard_snapshot() -> dict[str, Any]: swap = psutil.swap_memory() return { "supply": _runtime_supply(), - "profile": _read_optional_text(Path("/sys/firmware/acpi/platform_profile")), + "profile": _runtime_profile(), "governor": _runtime_governor(), "turbo": _runtime_turbo(), "power_limits": _runtime_power_limits(), diff --git a/tests/test_benchmark_experiment.py b/tests/test_benchmark_experiment.py index 0a02f34..fb1ed26 100644 --- a/tests/test_benchmark_experiment.py +++ b/tests/test_benchmark_experiment.py @@ -593,6 +593,19 @@ def test_schedule_preserves_raw_repeats_and_resumes_only_success(tmp_path): assert all(item["guard"]["attempts"][0]["valid"] for item in second["cells"]) +def test_runtime_profile_falls_back_to_powerprofilesctl(monkeypatch): + monkeypatch.setattr(experiment, "_read_optional_text", lambda _path: None) + monkeypatch.setattr( + experiment.subprocess, + "run", + lambda *args, **kwargs: experiment.subprocess.CompletedProcess( + args[0], 0, stdout="balanced\n", stderr="" + ), + ) + + assert experiment._runtime_profile() == "balanced" + + def test_runtime_guard_retries_once_and_persists_transition_evidence(tmp_path): manifest = _manifest(tmp_path) manifest["cells"][1]["enabled"] = False