diff --git a/llama_stack/testing/inference_recorder.py b/llama_stack/testing/inference_recorder.py index 4a6958399..8fa5f5f2e 100644 --- a/llama_stack/testing/inference_recorder.py +++ b/llama_stack/testing/inference_recorder.py @@ -9,7 +9,6 @@ from __future__ import annotations # for forward references import hashlib import json import os -import sqlite3 from collections.abc import Generator from contextlib import contextmanager from enum import StrEnum @@ -125,28 +124,13 @@ class ResponseStorage: def __init__(self, test_dir: Path): self.test_dir = test_dir self.responses_dir = self.test_dir / "responses" - self.db_path = self.test_dir / "index.sqlite" self._ensure_directories() - self._init_database() def _ensure_directories(self): self.test_dir.mkdir(parents=True, exist_ok=True) self.responses_dir.mkdir(exist_ok=True) - def _init_database(self): - with sqlite3.connect(self.db_path) as conn: - conn.execute(""" - CREATE TABLE IF NOT EXISTS recordings ( - request_hash TEXT PRIMARY KEY, - response_file TEXT, - endpoint TEXT, - model TEXT, - timestamp TEXT, - is_streaming BOOLEAN - ) - """) - def store_recording(self, request_hash: str, request: dict[str, Any], response: dict[str, Any]): """Store a request/response pair.""" # Generate unique response filename @@ -169,34 +153,9 @@ class ResponseStorage: f.write("\n") f.flush() - # Update SQLite index - with sqlite3.connect(self.db_path) as conn: - conn.execute( - """ - INSERT OR REPLACE INTO recordings - (request_hash, response_file, endpoint, model, timestamp, is_streaming) - VALUES (?, ?, ?, ?, datetime('now'), ?) - """, - ( - request_hash, - response_file, - request.get("endpoint", ""), - request.get("model", ""), - response.get("is_streaming", False), - ), - ) - def find_recording(self, request_hash: str) -> dict[str, Any] | None: """Find a recorded response by request hash.""" - with sqlite3.connect(self.db_path) as conn: - result = conn.execute( - "SELECT response_file FROM recordings WHERE request_hash = ?", (request_hash,) - ).fetchone() - - if not result: - return None - - response_file = result[0] + response_file = f"{request_hash[:12]}.json" response_path = self.responses_dir / response_file if not response_path.exists(): diff --git a/tests/integration/recordings/index.sqlite b/tests/integration/recordings/index.sqlite deleted file mode 100644 index 0c88416f1..000000000 Binary files a/tests/integration/recordings/index.sqlite and /dev/null differ diff --git a/tests/unit/distribution/test_inference_recordings.py b/tests/unit/distribution/test_inference_recordings.py index 1dbd14540..dd80b0caf 100644 --- a/tests/unit/distribution/test_inference_recordings.py +++ b/tests/unit/distribution/test_inference_recordings.py @@ -4,7 +4,6 @@ # This source code is licensed under the terms described in the LICENSE file in # the root directory of this source tree. -import sqlite3 import tempfile from pathlib import Path from unittest.mock import patch @@ -133,7 +132,6 @@ class TestInferenceRecording: # Test directory creation assert storage.test_dir.exists() assert storage.responses_dir.exists() - assert storage.db_path.exists() # Test storing and retrieving a recording request_hash = "test_hash_123" @@ -147,15 +145,6 @@ class TestInferenceRecording: storage.store_recording(request_hash, request_data, response_data) - # Verify SQLite record - with sqlite3.connect(storage.db_path) as conn: - result = conn.execute("SELECT * FROM recordings WHERE request_hash = ?", (request_hash,)).fetchone() - - assert result is not None - assert result[0] == request_hash # request_hash - assert result[2] == "/v1/chat/completions" # endpoint - assert result[3] == "llama3.2:3b" # model - # Verify file storage and retrieval retrieved = storage.find_recording(request_hash) assert retrieved is not None @@ -185,10 +174,7 @@ class TestInferenceRecording: # Verify recording was stored storage = ResponseStorage(temp_storage_dir) - with sqlite3.connect(storage.db_path) as conn: - recordings = conn.execute("SELECT COUNT(*) FROM recordings").fetchone()[0] - - assert recordings == 1 + assert storage.responses_dir.exists() async def test_replay_mode(self, temp_storage_dir, real_openai_chat_response): """Test that replay mode returns stored responses without making real calls."""