feat: add durable reconnect-safe experiment runs (#184)

This commit is contained in:
Joseph Magly
2026-08-28 23:50:45 -04:00
parent b36a5f7d3d
commit e8a36d796c
9 changed files with 1204 additions and 45 deletions
+37
View File
@@ -66,6 +66,43 @@ def test_disabled_publisher_is_noop():
assert publisher.release() is None
def test_allocation_phase_can_heartbeat_before_ready(tmp_path):
publisher = GpuLifecyclePublisher(tmp_path, run_id="loading-run")
def acknowledge():
while not (tmp_path / "current.json").exists():
time.sleep(0.001)
request = json.loads((tmp_path / "current.json").read_text())
(tmp_path / "ack.json").write_text(json.dumps({
"schema_version": 1,
"run_id": "loading-run",
"request_event_id": request["event_id"],
"decision": "grant",
"lease_id": "lease-loading",
"granted_vram_bytes": 100,
}))
thread = threading.Thread(target=acknowledge)
thread.start()
publisher.loading("org/model")
event = publisher.heartbeat()
publisher.release(reason="test_complete")
thread.join()
assert event is not None
assert event["event"] == "heartbeat"
assert event["run_id"] == "loading-run"
def test_environment_uses_stable_experiment_run_id(tmp_path, monkeypatch):
from obliteratus.gpu_lifecycle import from_environment
monkeypatch.setenv("OBLITERATUS_GPU_LIFECYCLE_DIR", str(tmp_path))
monkeypatch.setenv("OBLITERATUS_RUN_ID", "run-stable")
publisher = from_environment()
assert publisher._run_id == "run-stable"
def test_runtime_directory_must_exist(tmp_path):
with pytest.raises(ValueError, match="must already exist"):
GpuLifecyclePublisher(tmp_path / "missing")