Skip to content

Commit ca254af

Browse files
committed
fix: guard optional MySQL/Postgres imports in _check_versioned_read_support
Unconditional imports of pymysql and psycopg broke online reads for users on other stores (Redis, DynamoDB, etc.) that don't have these optional dependencies installed. Signed-off-by: yassinnouh21 <yassinnouh21@gmail.com>
1 parent 78dea93 commit ca254af

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

sdk/python/feast/infra/online_stores/online_store.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -255,17 +255,27 @@ def get_online_features(
255255

256256
def _check_versioned_read_support(self, grouped_refs):
257257
"""Raise an error if versioned reads are attempted on unsupported stores."""
258-
from feast.infra.online_stores.mysql_online_store.mysql import (
259-
MySQLOnlineStore,
260-
)
261-
from feast.infra.online_stores.postgres_online_store.postgres import (
262-
PostgreSQLOnlineStore,
263-
)
264258
from feast.infra.online_stores.sqlite import SqliteOnlineStore
265259

266-
if isinstance(
267-
self, (SqliteOnlineStore, PostgreSQLOnlineStore, MySQLOnlineStore)
268-
):
260+
supported_types: list[type] = [SqliteOnlineStore]
261+
try:
262+
from feast.infra.online_stores.mysql_online_store.mysql import (
263+
MySQLOnlineStore,
264+
)
265+
266+
supported_types.append(MySQLOnlineStore)
267+
except ImportError:
268+
pass
269+
try:
270+
from feast.infra.online_stores.postgres_online_store.postgres import (
271+
PostgreSQLOnlineStore,
272+
)
273+
274+
supported_types.append(PostgreSQLOnlineStore)
275+
except ImportError:
276+
pass
277+
278+
if isinstance(self, tuple(supported_types)):
269279
return
270280
for table, _ in grouped_refs:
271281
version_tag = getattr(table.projection, "version_tag", None)

0 commit comments

Comments
 (0)