- Updated CLI documentation to reflect the new handling of `CIVITAI_API_TOKEN`, which is now automatically passed to SwarmUI user settings during startup. - Improved the `render_access_panel` function to include additional warnings for idle-killer failures and stack errors, enhancing user feedback. - Introduced a new function `seed_swarmui_api_keys` to manage API key injection into SwarmUI, ensuring seamless integration with the Model Downloader. - Enhanced GPU environment verification logic to include fail-fast checks for critical components like CUDA, improving error handling and user notifications. - Updated tests to validate the new API key handling and access panel behavior, ensuring robustness in the integration process.
34 lines
990 B
Python
34 lines
990 B
Python
from gpu_rent.timing import PhaseTimes, WaitLog, format_duration
|
|
|
|
|
|
def test_format_duration():
|
|
assert format_duration(5) == "5s"
|
|
assert format_duration(65) == "1m 5s"
|
|
assert format_duration(60) == "1m"
|
|
assert format_duration(3661) == "1h 1m"
|
|
|
|
|
|
def test_phase_times_summary(monkeypatch):
|
|
times = iter([100.0, 110.0, 130.0, 190.0])
|
|
monkeypatch.setattr("gpu_rent.timing.time.monotonic", lambda: next(times))
|
|
clock = PhaseTimes()
|
|
clock.mark("SSH")
|
|
clock.mark("bootstrap")
|
|
line = clock.summary_line()
|
|
assert "SSH 10s" in line
|
|
assert "bootstrap 20s" in line
|
|
assert "всего" in line
|
|
|
|
|
|
def test_wait_log_throttles(monkeypatch):
|
|
logs: list[str] = []
|
|
t = {"now": 0.0}
|
|
monkeypatch.setattr("gpu_rent.timing.time.monotonic", lambda: t["now"])
|
|
w = WaitLog(logs.append, every=30.0)
|
|
w.tick("a")
|
|
t["now"] = 10.0
|
|
w.tick("b")
|
|
t["now"] = 31.0
|
|
w.tick("c")
|
|
assert logs == ["a", "c"]
|