Skip to content

Commit beeb5f0

Browse files
committed
fix: Complete DBAPI import fix - replace Connection type hints with Any
Completes the iris.dbapi import migration by fixing type hints in connection_pool.py. The iris.dbapi module doesn't export a Connection class, so we use Any for type hints instead. Changes: - iris_vector_rag/common/connection_pool.py: * Replace 7 Connection type hints with Any (lines 98, 133, 156, 174, 196, 272, 296) * Remove invalid `from iris.dbapi import Connection` import * Verified: connection_pool module now imports successfully Test Results: - Feature 058 contract tests: 20/22 passing (91%) - 2 integration tests with real IRIS database: PASSING - Vector dimension validation working correctly - Namespace validation working correctly Closes fix for: iris.dbapi doesn't export Connection class Related: iris-vector-rag import migration from intersystems_iris to iris
1 parent 45513a2 commit beeb5f0

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

iris-test-config.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# IRIS test container configuration for Feature 058 integration tests
2+
edition: community
3+
image: containers.intersystems.com/intersystems/iris-community-arm64:latest-em
4+
container_name: iris-feature-058-test
5+
ports:
6+
superserver: 11972
7+
management: 15277
8+
credentials:
9+
username: _SYSTEM
10+
password: SYS
11+
namespace: USER
12+
healthcheck:
13+
enabled: true
14+
timeout: 120
15+
volumes:
16+
- /tmp/iris-feature-058-test:/dur

iris_vector_rag/common/connection_pool.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from typing import Any, Dict, Generator, Optional
1818

1919
import iris.dbapi as iris_dbapi
20-
from iris.dbapi import Connection
2120

2221
logger = logging.getLogger(__name__)
2322

@@ -76,9 +75,9 @@ def __init__(
7675
self.pool_timeout = pool_timeout
7776

7877
# Connection tracking
79-
self._available_connections: list[Connection] = []
80-
self._in_use_connections: set[Connection] = set()
81-
self._connection_timestamps: Dict[Connection, float] = {}
78+
self._available_connections: list[Any] = []
79+
self._in_use_connections: set[Any] = set()
80+
self._connection_timestamps: Dict[Any, float] = {}
8281

8382
# Thread safety
8483
import threading
@@ -96,7 +95,7 @@ def __init__(
9695
f"recycle={pool_recycle}s, pre_ping={pool_pre_ping}"
9796
)
9897

99-
def _create_connection(self) -> Connection:
98+
def _create_connection(self) -> Any:
10099
"""
101100
Create a new IRIS database connection.
102101
@@ -131,7 +130,7 @@ def _create_connection(self) -> Connection:
131130
logger.error(f"Failed to create IRIS connection: {e}")
132131
raise
133132

134-
def _validate_connection(self, connection: Connection) -> bool:
133+
def _validate_connection(self, connection: Any) -> bool:
135134
"""
136135
Validate that a connection is still alive.
137136
@@ -154,7 +153,7 @@ def _validate_connection(self, connection: Connection) -> bool:
154153
logger.warning(f"Connection validation failed: {e}")
155154
return False
156155

157-
def _should_recycle_connection(self, connection: Connection) -> bool:
156+
def _should_recycle_connection(self, connection: Any) -> bool:
158157
"""
159158
Check if connection should be recycled based on age.
160159
@@ -172,7 +171,7 @@ def _should_recycle_connection(self, connection: Connection) -> bool:
172171
age = time.time() - self._connection_timestamps[connection]
173172
return age >= self.pool_recycle
174173

175-
def _recycle_connection(self, connection: Connection) -> None:
174+
def _recycle_connection(self, connection: Any) -> None:
176175
"""
177176
Close and remove a connection from the pool.
178177
@@ -194,7 +193,7 @@ def _recycle_connection(self, connection: Connection) -> None:
194193
except Exception as e:
195194
logger.warning(f"Error recycling connection: {e}")
196195

197-
def acquire(self) -> Connection:
196+
def acquire(self) -> Any:
198197
"""
199198
Acquire a connection from the pool.
200199
@@ -270,7 +269,7 @@ def acquire(self) -> Connection:
270269
f"in_use: {len(self._in_use_connections)})"
271270
)
272271

273-
def release(self, connection: Connection) -> None:
272+
def release(self, connection: Any) -> None:
274273
"""
275274
Release a connection back to the pool.
276275
@@ -294,7 +293,7 @@ def release(self, connection: Connection) -> None:
294293
)
295294

296295
@contextmanager
297-
def get_connection(self) -> Generator[Connection, None, None]:
296+
def get_connection(self) -> Generator[Any, None, None]:
298297
"""
299298
Context manager for acquiring and releasing connections.
300299

0 commit comments

Comments
 (0)