Update configuration and documentation for LLM support and local watchdog
- Added `ollama-models.yaml` to .gitignore and implemented logic to copy it in gpu-rent.ps1 and gpu-rent.sh. - Enhanced env.example to include new variables for LLM runtime options and local watchdog configuration. - Updated CLI commands to support LLM options during setup and execution, including new flags for Ollama and llama.cpp. - Improved documentation in cli.md and README.md to reflect changes in LLM integration and local watchdog functionality. - Adjusted architecture and decisions documentation to clarify the role of LLMs and local watchdog in the system.
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
from gpu_rent.local_watchdog import LocalLease, decide_local_tick
|
||||
|
||||
|
||||
def _now() -> datetime:
|
||||
return datetime(2026, 8, 21, 12, 0, tzinfo=timezone.utc)
|
||||
|
||||
|
||||
def test_noop_when_not_installed():
|
||||
d = decide_local_tick(
|
||||
installed=False,
|
||||
has_server=True,
|
||||
lease=LocalLease(armed=True, heartbeat_at=_now().isoformat()),
|
||||
now=_now(),
|
||||
process_alive=False,
|
||||
grace_sec=600,
|
||||
)
|
||||
assert d.kind == "noop"
|
||||
|
||||
|
||||
def test_noop_when_detached():
|
||||
d = decide_local_tick(
|
||||
installed=True,
|
||||
has_server=True,
|
||||
lease=LocalLease(armed=False, detached=True, heartbeat_at=_now().isoformat()),
|
||||
now=_now(),
|
||||
process_alive=False,
|
||||
grace_sec=600,
|
||||
)
|
||||
assert d.kind == "noop"
|
||||
assert "detached" in d.detail
|
||||
|
||||
|
||||
def test_noop_while_pid_alive():
|
||||
d = decide_local_tick(
|
||||
installed=True,
|
||||
has_server=True,
|
||||
lease=LocalLease(
|
||||
armed=True,
|
||||
pid=1,
|
||||
heartbeat_at=(_now() - timedelta(hours=1)).isoformat(),
|
||||
),
|
||||
now=_now(),
|
||||
process_alive=True,
|
||||
grace_sec=600,
|
||||
)
|
||||
assert d.kind == "noop"
|
||||
|
||||
|
||||
def test_noop_inside_grace():
|
||||
hb = _now() - timedelta(minutes=5)
|
||||
d = decide_local_tick(
|
||||
installed=True,
|
||||
has_server=True,
|
||||
lease=LocalLease(armed=True, pid=999, heartbeat_at=hb.isoformat()),
|
||||
now=_now(),
|
||||
process_alive=False,
|
||||
grace_sec=600,
|
||||
)
|
||||
assert d.kind == "noop"
|
||||
assert "grace" in d.detail
|
||||
|
||||
|
||||
def test_stop_when_stale():
|
||||
hb = _now() - timedelta(minutes=20)
|
||||
d = decide_local_tick(
|
||||
installed=True,
|
||||
has_server=True,
|
||||
lease=LocalLease(armed=True, pid=999, heartbeat_at=hb.isoformat()),
|
||||
now=_now(),
|
||||
process_alive=False,
|
||||
grace_sec=600,
|
||||
)
|
||||
assert d.kind == "stop"
|
||||
|
||||
|
||||
def test_noop_without_lease():
|
||||
d = decide_local_tick(
|
||||
installed=True,
|
||||
has_server=True,
|
||||
lease=None,
|
||||
now=_now(),
|
||||
process_alive=False,
|
||||
grace_sec=600,
|
||||
)
|
||||
assert d.kind == "noop"
|
||||
Reference in New Issue
Block a user