From 2932a627bbc674d0a4929b7be82b0e150ec8df50 Mon Sep 17 00:00:00 2001 From: Andrej Milicevic Date: Thu, 9 Oct 2025 09:45:26 +0200 Subject: [PATCH 1/9] test: Potential fix for soft deletion test --- .github/workflows/test_different_operating_systems.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/test_different_operating_systems.yml b/.github/workflows/test_different_operating_systems.yml index 6eb5744f3..e784c9ca3 100644 --- a/.github/workflows/test_different_operating_systems.yml +++ b/.github/workflows/test_different_operating_systems.yml @@ -193,6 +193,13 @@ jobs: with: python-version: ${{ matrix.python-version }} + - name: Path setup + if: ${{ matrix.os }} == 'windows-latest' + shell: bash + run: | + PATH=$(printf '%s\n' "$PATH" | grep -vi '/git/usr/bin' | paste -sd: -) + export PATH + - name: Run Soft Deletion Tests env: ENV: 'dev' From d1d8e334716d81fe6e8b1f1b185743197f27d79e Mon Sep 17 00:00:00 2001 From: Andrej Milicevic Date: Thu, 9 Oct 2025 10:48:21 +0200 Subject: [PATCH 2/9] test: Fix windows tests. First try of potential fixes. --- cognee/tests/test_library.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cognee/tests/test_library.py b/cognee/tests/test_library.py index c5e6cc64b..fe1a0bdfa 100755 --- a/cognee/tests/test_library.py +++ b/cognee/tests/test_library.py @@ -82,6 +82,11 @@ async def main(): data_root_directory = get_storage_config()["data_root_directory"] assert not os.path.isdir(data_root_directory), "Local data files are not deleted" + from cognee.infrastructure.databases.relational import get_relational_engine + + get_relational_engine().get_session().close() + await get_relational_engine().engine.dispose() + # Assert relational, vector and graph databases have been cleaned properly await cognee.prune.prune_system(metadata=True) @@ -89,7 +94,7 @@ async def main(): collection_names = await connection.table_names() assert len(collection_names) == 0, "LanceDB vector database is not empty" - from cognee.infrastructure.databases.relational import get_relational_engine + db_path = get_relational_engine().db_path dir_path = os.path.dirname(db_path) From ee96d8f940f7248dbc9a6b6cecbccd4c6f7fc24b Mon Sep 17 00:00:00 2001 From: Andrej Milicevic Date: Thu, 9 Oct 2025 11:00:54 +0200 Subject: [PATCH 3/9] chore: fix formatting --- cognee/tests/test_library.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/cognee/tests/test_library.py b/cognee/tests/test_library.py index fe1a0bdfa..2933c77ba 100755 --- a/cognee/tests/test_library.py +++ b/cognee/tests/test_library.py @@ -94,8 +94,6 @@ async def main(): collection_names = await connection.table_names() assert len(collection_names) == 0, "LanceDB vector database is not empty" - - db_path = get_relational_engine().db_path dir_path = os.path.dirname(db_path) file_path = os.path.basename(db_path) From a44ab88519a784ef22ca9d133200124373db8dc7 Mon Sep 17 00:00:00 2001 From: Andrej Milicevic Date: Thu, 9 Oct 2025 17:31:27 +0200 Subject: [PATCH 4/9] test: try calling gc to fix windows issue --- .../databases/relational/sqlalchemy/SqlAlchemyAdapter.py | 4 +++- cognee/tests/test_library.py | 7 ++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py b/cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py index 88d2abc7e..4908295ca 100644 --- a/cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py +++ b/cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py @@ -507,7 +507,9 @@ class SQLAlchemyAdapter: if self.engine.dialect.name == "sqlite": await self.engine.dispose(close=True) # Wait for the database connections to close and release the file (Windows) - await asyncio.sleep(2) + import gc + gc.collect() + # await asyncio.sleep(2) db_directory = path.dirname(self.db_path) file_name = path.basename(self.db_path) file_storage = get_file_storage(db_directory) diff --git a/cognee/tests/test_library.py b/cognee/tests/test_library.py index 2933c77ba..c5e6cc64b 100755 --- a/cognee/tests/test_library.py +++ b/cognee/tests/test_library.py @@ -82,11 +82,6 @@ async def main(): data_root_directory = get_storage_config()["data_root_directory"] assert not os.path.isdir(data_root_directory), "Local data files are not deleted" - from cognee.infrastructure.databases.relational import get_relational_engine - - get_relational_engine().get_session().close() - await get_relational_engine().engine.dispose() - # Assert relational, vector and graph databases have been cleaned properly await cognee.prune.prune_system(metadata=True) @@ -94,6 +89,8 @@ async def main(): collection_names = await connection.table_names() assert len(collection_names) == 0, "LanceDB vector database is not empty" + from cognee.infrastructure.databases.relational import get_relational_engine + db_path = get_relational_engine().db_path dir_path = os.path.dirname(db_path) file_path = os.path.basename(db_path) From a7a2631d53ba274511072e312745ecdabf9f8765 Mon Sep 17 00:00:00 2001 From: Andrej Milicevic Date: Thu, 9 Oct 2025 17:50:20 +0200 Subject: [PATCH 5/9] chore: format --- .../databases/relational/sqlalchemy/SqlAlchemyAdapter.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py b/cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py index 4908295ca..36ba90db5 100644 --- a/cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py +++ b/cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py @@ -508,6 +508,7 @@ class SQLAlchemyAdapter: await self.engine.dispose(close=True) # Wait for the database connections to close and release the file (Windows) import gc + gc.collect() # await asyncio.sleep(2) db_directory = path.dirname(self.db_path) From ef5965224ac49df72a21e56d9b0537df73ef6a37 Mon Sep 17 00:00:00 2001 From: Andrej Milicevic Date: Mon, 13 Oct 2025 12:44:55 +0200 Subject: [PATCH 6/9] fix: Revert changes made to sql alchemy adapter for lib test --- .../databases/relational/sqlalchemy/SqlAlchemyAdapter.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py b/cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py index 36ba90db5..88d2abc7e 100644 --- a/cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py +++ b/cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py @@ -507,10 +507,7 @@ class SQLAlchemyAdapter: if self.engine.dialect.name == "sqlite": await self.engine.dispose(close=True) # Wait for the database connections to close and release the file (Windows) - import gc - - gc.collect() - # await asyncio.sleep(2) + await asyncio.sleep(2) db_directory = path.dirname(self.db_path) file_name = path.basename(self.db_path) file_storage = get_file_storage(db_directory) From f81aeff0096664a7556d451056f813e4994ab2d2 Mon Sep 17 00:00:00 2001 From: Andrej Milicevic Date: Mon, 13 Oct 2025 12:50:26 +0200 Subject: [PATCH 7/9] Revert "fix: Revert changes made to sql alchemy adapter for lib test" This reverts commit ef5965224ac49df72a21e56d9b0537df73ef6a37. --- .../databases/relational/sqlalchemy/SqlAlchemyAdapter.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py b/cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py index 88d2abc7e..36ba90db5 100644 --- a/cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py +++ b/cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py @@ -507,7 +507,10 @@ class SQLAlchemyAdapter: if self.engine.dialect.name == "sqlite": await self.engine.dispose(close=True) # Wait for the database connections to close and release the file (Windows) - await asyncio.sleep(2) + import gc + + gc.collect() + # await asyncio.sleep(2) db_directory = path.dirname(self.db_path) file_name = path.basename(self.db_path) file_storage = get_file_storage(db_directory) From 74ce78ddfe1542b470bade83c75828a70efdf4d4 Mon Sep 17 00:00:00 2001 From: Andrej Milicevic Date: Mon, 13 Oct 2025 12:52:05 +0200 Subject: [PATCH 8/9] fix: Revert changes to sql alchemy for lib test --- .../databases/relational/sqlalchemy/SqlAlchemyAdapter.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py b/cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py index 93252ab6e..380ce9917 100644 --- a/cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py +++ b/cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py @@ -507,10 +507,7 @@ class SQLAlchemyAdapter: if self.engine.dialect.name == "sqlite": await self.engine.dispose(close=True) # Wait for the database connections to close and release the file (Windows) - import gc - - gc.collect() - # await asyncio.sleep(2) + await asyncio.sleep(2) db_directory = path.dirname(self.db_path) file_name = path.basename(self.db_path) file_storage = get_file_storage(db_directory) From 832243034f291d63c70eeeb43828ccdbc69d7bc0 Mon Sep 17 00:00:00 2001 From: Andrej Milicevic Date: Mon, 13 Oct 2025 16:21:19 +0200 Subject: [PATCH 9/9] test: small change in soft delete test --- .github/workflows/test_different_operating_systems.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_different_operating_systems.yml b/.github/workflows/test_different_operating_systems.yml index e784c9ca3..00e387ac4 100644 --- a/.github/workflows/test_different_operating_systems.yml +++ b/.github/workflows/test_different_operating_systems.yml @@ -197,7 +197,7 @@ jobs: if: ${{ matrix.os }} == 'windows-latest' shell: bash run: | - PATH=$(printf '%s\n' "$PATH" | grep -vi '/git/usr/bin' | paste -sd: -) + PATH=$(printf '%s' "$PATH" | tr ':' $'\n' | grep -vi '/git/usr/bin' | paste -sd: -) export PATH - name: Run Soft Deletion Tests