From ca244974f6f5cb221bba28213425cd6ac8c19747 Mon Sep 17 00:00:00 2001 From: Kai Schuyler Gonzalez <43561307+kaischuygon@users.noreply.github.com> Date: Thu, 30 Nov 2023 12:47:04 -0700 Subject: [PATCH] Fix typo in main.yml and update test instructions in test_pgvector.py --- .github/workflows/main.yml | 2 +- test/embedding/test_pgvector.py | 52 ++++----------------------------- 2 files changed, 6 insertions(+), 48 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e2b3f26..67bfbfb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,7 +16,7 @@ jobs: POSTGRES_USER: mock_user POSTGRES_PASSWORD: mock_password POSTGRES_DB: mock_db - ports: # give multiple ports for each python versionto avoid conflicts + ports: # give multiple ports for each python version to avoid conflicts - 5433:5432 - 5432:5432 diff --git a/test/embedding/test_pgvector.py b/test/embedding/test_pgvector.py index 5198cf2..0e0572d 100644 --- a/test/embedding/test_pgvector.py +++ b/test/embedding/test_pgvector.py @@ -1,4 +1,9 @@ ''' +Set up a mock Postgres instance with the following commands (make sure you don't have anything running on port 0.0.0.0:5432))): +- docker pull ankane/pgvector +- docker run --name mock-postgres -p 5432:5432 -e POSTGRES_USER=mock_user -e POSTGRES_PASSWORD=mock_password -e POSTGRES_DB=mock_db -d ankane/pgvector + +Then run the tests with: pytest test or @@ -84,50 +89,3 @@ async def test_PGv_embed_pacer(): assert sim_search is not None, Exception("No results returned from perfect search") await vDB.drop_table() - -# @pytest.mark.asyncio -# async def test_PGv_embed_many_pacer(): -# dummy_model = SentenceTransformer('mock_transformer') -# dummy_model.encode.return_value = np.array([1, 2, 3]) -# print(f'EMODEL: {dummy_model}') -# TABLE_NAME = 'embedding_test' -# try: -# vDB = await DocDB.from_conn_params( -# embedding_model=dummy_model, -# table_name=TABLE_NAME, -# db_name=DB_NAME, -# host=HOST, -# port=int(PORT), -# user=USER, -# password=PASSWORD) -# except ConnectionRefusedError: -# pytest.skip("No Postgres instance made available for test. Skipping.", allow_module_level=True) - -# assert vDB is not None, ConnectionError("Postgres docker instance not available for testing PG code") - -# # Create tables -# await vDB.drop_table() -# assert await vDB.table_exists() is False, Exception("Table exists before creation") -# await vDB.create_table() -# assert await vDB.table_exists() is True, Exception("Table does not exist after creation") - -# # Insert data using insert_many() -# documents = [ -# { -# 'content': text, -# 'title': f'Pacer Copypasta line {index}', -# 'page_numbers': [1, 2, 3], -# 'tags': ['fitness', 'pacer', 'copypasta'] -# } -# for index, text in enumerate(pacer_copypasta) -# ] -# await vDB.insert_many(documents) - -# assert await vDB.count_items() == len(pacer_copypasta), Exception("Not all documents inserted") - -# # Search table with perfect match -# search_string = '[beep] A single lap should be completed each time you hear this sound.' -# sim_search = await vDB.search(query_string=search_string, limit=3) -# assert sim_search is not None, Exception("No results returned from perfect search") - -# await vDB.drop_table() \ No newline at end of file