vendor_connectors._compat
Compatibility and graceful degradation utilities.
This module provides utilities for checking optional dependencies and providing helpful error messages when they’re missing.
Usage: from vendor_connectors._compat import require_extra, is_available
# Check if available (returns bool)if is_available("boto3"): import boto3
# Require with helpful error (raises ImportError)require_extra("boto3", "aws") # -> "Install with: pip install vendor-connectors[aws]"Module Contents
Section titled “Module Contents”Functions
Section titled “Functions”is_available | Check if a package is available for import. |
|---|---|
get_extra_for_package | Get the extra name for a package. |
require_extra | Import a package, raising helpful error if missing. |
require_any | Import the first available package from a list. |
detect_ai_frameworks | Detect which AI frameworks are available. |
get_available_ai_frameworks | Get list of available AI frameworks. |
is_connector_available | Check if a connector’s dependencies are available. |
get_available_connectors | Get list of connectors with available dependencies. |
require_connector | Ensure a connector’s dependencies are available. |
PACKAGE_TO_EXTRA | |
|---|---|
_import_cache | |
CONNECTOR_REQUIREMENTS |
vendor_connectors._compat.PACKAGE_TO_EXTRA : dict[str, str]
Section titled “vendor_connectors._compat.PACKAGE_TO_EXTRA : dict[str, str]”None
vendor_connectors._compat._import_cache : dict[str, bool]
Section titled “vendor_connectors._compat._import_cache : dict[str, bool]”None
vendor_connectors._compat.is_available(package: str) → bool
Section titled “vendor_connectors._compat.is_available(package: str) → bool”Check if a package is available for import.
Args: package: Package name to check (e.g., “boto3”, “langchain_core”)
Returns: True if package can be imported, False otherwise
vendor_connectors._compat.get_extra_for_package(package: str) → str | None
Section titled “vendor_connectors._compat.get_extra_for_package(package: str) → str | None”Get the extra name for a package.
Args: package: Package name
Returns: Extra name or None if not mapped
vendor_connectors._compat.require_extra(package: str, extra: str | None = None) → Any
Section titled “vendor_connectors._compat.require_extra(package: str, extra: str | None = None) → Any”Import a package, raising helpful error if missing.
Args: package: Package name to import extra: Optional extra name override (auto-detected if not provided)
Returns: The imported module
Raises: ImportError: With helpful install instructions if package is missing
vendor_connectors._compat.require_any(*packages: str, extra: str) → Any
Section titled “vendor_connectors._compat.require_any(*packages: str, extra: str) → Any”Import the first available package from a list.
Args: *packages: Package names to try (in order) extra: Extra name for error message
Returns: The first successfully imported module
Raises: ImportError: If none of the packages are available
vendor_connectors._compat.detect_ai_frameworks() → dict[str, bool]
Section titled “vendor_connectors._compat.detect_ai_frameworks() → dict[str, bool]”Detect which AI frameworks are available.
Returns: Dict mapping framework name to availability
vendor_connectors._compat.get_available_ai_frameworks() → list[str]
Section titled “vendor_connectors._compat.get_available_ai_frameworks() → list[str]”Get list of available AI frameworks.
Returns: List of framework names that are installed
vendor_connectors._compat.CONNECTOR_REQUIREMENTS : dict[str, list[str]]
Section titled “vendor_connectors._compat.CONNECTOR_REQUIREMENTS : dict[str, list[str]]”None
vendor_connectors._compat.is_connector_available(connector: str) → bool
Section titled “vendor_connectors._compat.is_connector_available(connector: str) → bool”Check if a connector’s dependencies are available.
Args: connector: Connector name (e.g., “aws”, “meshy”)
Returns: True if all required packages are available
vendor_connectors._compat.get_available_connectors() → list[str]
Section titled “vendor_connectors._compat.get_available_connectors() → list[str]”Get list of connectors with available dependencies.
Returns: List of connector names that can be used
vendor_connectors._compat.require_connector(connector: str) → None
Section titled “vendor_connectors._compat.require_connector(connector: str) → None”Ensure a connector’s dependencies are available.
Args: connector: Connector name
Raises: ImportError: With helpful message if dependencies missing