Skip to content

Commit cb6f151

Browse files
committed
fix: revert llamaindex tests
1 parent f158c4c commit cb6f151

2 files changed

Lines changed: 2 additions & 68 deletions

File tree

packages/uipath-llamaindex/src/uipath_llamaindex/runtime/_sqlite.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,25 +57,7 @@ async def connect(self) -> None:
5757
async def close(self) -> None:
5858
"""Close database connection."""
5959
if self.conn:
60-
try:
61-
# Commit any pending transactions before closing
62-
await self.conn.commit()
63-
except Exception:
64-
pass # Best effort
65-
66-
try:
67-
# Force WAL checkpoint to release shared memory files
68-
# This is especially important on Windows
69-
await self.conn.execute("PRAGMA wal_checkpoint(TRUNCATE)")
70-
await self.conn.commit()
71-
except Exception:
72-
pass # Best effort
73-
74-
try:
75-
await self.conn.close()
76-
except Exception:
77-
pass # Best effort cleanup
78-
60+
await self.conn.close()
7961
self.conn = None
8062
self.is_setup = False
8163

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import gc
2-
import os
3-
import platform
4-
import shutil
5-
import sqlite3
61
import tempfile
7-
import time
82
from typing import Generator
93

104
import pytest
@@ -20,47 +14,5 @@ def runner() -> CliRunner:
2014
@pytest.fixture
2115
def temp_dir() -> Generator[str, None, None]:
2216
"""Provide a temporary directory for test files."""
23-
tmp_dir = tempfile.mkdtemp()
24-
try:
17+
with tempfile.TemporaryDirectory() as tmp_dir:
2518
yield tmp_dir
26-
finally:
27-
# Force garbage collection to close any open file handles
28-
gc.collect()
29-
30-
# On Windows, SQLite files may remain locked even after closing connections
31-
# Try to close any remaining SQLite connections to the state.db file
32-
if platform.system() == "Windows":
33-
state_db_path = os.path.join(tmp_dir, "__uipath", "state.db")
34-
if os.path.exists(state_db_path):
35-
# Try to force close SQLite connections
36-
try:
37-
# Connect and immediately close to ensure WAL checkpoint
38-
conn = sqlite3.connect(state_db_path, timeout=1.0)
39-
conn.execute("PRAGMA wal_checkpoint(TRUNCATE)")
40-
conn.close()
41-
except Exception:
42-
pass # Best effort
43-
44-
# Give Windows time to release file handles
45-
time.sleep(0.1)
46-
47-
# Attempt cleanup with retries on Windows
48-
max_retries = 3
49-
for attempt in range(max_retries):
50-
try:
51-
shutil.rmtree(tmp_dir)
52-
break
53-
except (PermissionError, OSError) as e:
54-
if attempt < max_retries - 1:
55-
# Wait briefly and try again
56-
time.sleep(0.2)
57-
gc.collect()
58-
else:
59-
# On final attempt, log warning but don't fail the test
60-
import warnings
61-
62-
warnings.warn(
63-
f"Failed to clean up temporary directory {tmp_dir}: {e}",
64-
ResourceWarning,
65-
stacklevel=2,
66-
)

0 commit comments

Comments
 (0)