Skip to content

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]"
is_availableCheck if a package is available for import.
get_extra_for_packageGet the extra name for a package.
require_extraImport a package, raising helpful error if missing.
require_anyImport the first available package from a list.
detect_ai_frameworksDetect which AI frameworks are available.
get_available_ai_frameworksGet list of available AI frameworks.
is_connector_availableCheck if a connector’s dependencies are available.
get_available_connectorsGet list of connectors with available dependencies.
require_connectorEnsure a connector’s dependencies are available.
PACKAGE_TO_EXTRA
_import_cache
CONNECTOR_REQUIREMENTS

None

None

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

Get the extra name for a package.

Args: package: Package name

Returns: Extra name or None if not mapped

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

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

Detect which AI frameworks are available.

Returns: Dict mapping framework name to availability

Get list of available AI frameworks.

Returns: List of framework names that are installed

None

Check if a connector’s dependencies are available.

Args: connector: Connector name (e.g., “aws”, “meshy”)

Returns: True if all required packages are available

Get list of connectors with available dependencies.

Returns: List of connector names that can be used

Ensure a connector’s dependencies are available.

Args: connector: Connector name

Raises: ImportError: With helpful message if dependencies missing