Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
DGaffney committed Aug 19, 2024
1 parent 970aa77 commit bc0ee30
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions lib/model/generic_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,4 @@ def vectorize(self, texts: List[str]) -> List[List[float]]:
Vectorize the text! Run as batch.
"""
return self.model.encode(texts).tolist()

13 changes: 6 additions & 7 deletions test/lib/model/test_generic.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import traceback
import os
import unittest
from unittest.mock import MagicMock, patch
Expand Down Expand Up @@ -108,13 +109,11 @@ def test_separate_cached_docs(self):
self.assertEqual(texts_to_vectorize[0], "Hello")
self.assertEqual(docs[1].body.result, [4, 5, 6])

@patch('lib.model.generic_transformer.logger')
def test_handle_fingerprinting_error(self, mock_logger):
with self.assertRaises(Exception) as context:
self.model.handle_fingerprinting_error(ValueError("An error occurred"))

mock_logger.error.assert_called_once_with("Error during vectorization: An error occurred")
self.assertTrue(isinstance(context.exception, ValueError))
@patch('lib.sentry.capture_custom_message')
def test_handle_fingerprinting_error(self, mock_capture_custom_message):
error = ValueError("An error occurred")
response = self.model.handle_fingerprinting_error(error)
self.assertIsInstance(response, schemas.ErrorResponse)

if __name__ == '__main__':
unittest.main()

0 comments on commit bc0ee30

Please sign in to comment.