Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: replace models with lfs pointer files, and fix testing #166

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -e ".[dev]"
```

```bash
# Download models
git lfs install
git lfs pull
```

### Testing
```bash
pytest
Expand Down
3 changes: 3 additions & 0 deletions models/all-minilm-L6-v2-q5_k_m.gguf
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/qwen2.5-coder-1.5b-instruct-q5_k_m.gguf
Git LFS file not shown
5 changes: 0 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,3 @@ def parse_json_log(log_line: str) -> dict[str, Any]:
return json.loads(log_line)
except json.JSONDecodeError as e:
pytest.fail(f"Invalid JSON log line: {e}")


@pytest.fixture
def inference_engine() -> LlamaCppInferenceEngine:
return LlamaCppInferenceEngine()
64 changes: 0 additions & 64 deletions tests/test_inference.py

This file was deleted.

38 changes: 18 additions & 20 deletions tests/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,21 @@ def mock_inference_engine():

@pytest.mark.asyncio
async def test_search(mock_weaviate_client, mock_inference_engine):
# Patch the WeaviateClient and LlamaCppInferenceEngine inside the test function
with (
patch("weaviate.WeaviateClient", return_value=mock_weaviate_client),
patch(
"codegate.inference.inference_engine.LlamaCppInferenceEngine",
return_value=mock_inference_engine,
),
):

# Initialize StorageEngine
storage_engine = StorageEngine(data_path="./weaviate_data")

# Invoke the search method
results = await storage_engine.search("test query", 5, 0.3)

# Assertions to validate the expected behavior
assert len(results) == 1 # Assert that one result is returned
assert results[0]["properties"]["name"] == "test"
mock_weaviate_client.connect.assert_called()
mock_weaviate_client.close.assert_called()
# Patch the LlamaCppInferenceEngine.embed method (not the entire class)
with patch("codegate.inference.inference_engine.LlamaCppInferenceEngine.embed",
mock_inference_engine.embed):

# Mock the WeaviateClient as before
with patch("weaviate.WeaviateClient", return_value=mock_weaviate_client):

# Initialize StorageEngine
storage_engine = StorageEngine(data_path="./weaviate_data")

# Invoke the search method
results = await storage_engine.search("test query", 5, 0.3)

# Assertions to validate the expected behavior
assert len(results) == 1 # Assert that one result is returned
assert results[0]["properties"]["name"] == "test"
mock_weaviate_client.connect.assert_called()
mock_weaviate_client.close.assert_called()
Loading