Fix optional dependency handling for Redis and MinIO adapters.
Lazy-load adapters at package boundaries and fail fast with install hints when extras are missing. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
co-authored by
Cursor
parent
9e4b1e2c5e
commit
c6eed43d70
@@ -3,7 +3,6 @@
|
||||
from __future__ import annotations
|
||||
import os
|
||||
from io import BytesIO
|
||||
from importlib.util import find_spec
|
||||
from typing import Self
|
||||
import structlog
|
||||
from python_utils import check_env
|
||||
@@ -14,9 +13,13 @@ from python_repositories.interfaces import (
|
||||
ObjectRepositoryInterface,
|
||||
)
|
||||
|
||||
# Handle optional dependencies
|
||||
if find_spec("minio") is not None:
|
||||
try:
|
||||
import minio
|
||||
except ImportError as exc:
|
||||
raise ImportError(
|
||||
"MinIO support requires the minio extra. "
|
||||
"Install with: pip install python-repositories[minio]"
|
||||
) from exc
|
||||
|
||||
|
||||
class MinioAdapter(
|
||||
@@ -112,7 +115,7 @@ class MinioAdapter(
|
||||
@property
|
||||
def is_connected(self) -> bool:
|
||||
"""Check if connected to Minio server."""
|
||||
res = bool(isinstance(self._client, minio.Minio))
|
||||
res = self._client is not None
|
||||
self.logger.debug(res)
|
||||
return res
|
||||
|
||||
|
||||
Reference in New Issue
Block a user