nemoguardrails.imports
Utilities for handling optional dependencies.
Module Contents
Functions
Data
API
Check if an optional dependency is available.
Parameters:
The module name to check.
The package name for installation messages (defaults to module_name).
The name of the extra dependency group.
Returns: bool
True if the module is available, False otherwise.
Get an optional dependency using predefined settings.
Parameters:
The module name (should be in OPTIONAL_DEPENDENCIES).
What to do when a dependency is not found. One of ‘raise’, ‘warn’, ‘ignore’.
Returns: Any
The imported module or None.
Import an optional dependency, inspired by pandas implementation.
Parameters:
The module name.
The name of the extra dependency group.
What to do when a dependency is not found or its version is too old. One of ‘raise’, ‘warn’, ‘ignore’.
Specify a minimum version that is different from the global version.
Returns: Any
The imported module or None.
Import an optional dependency.
Parameters:
The module name to import.
The package name for installation messages (defaults to module_name).
What to do when dependency is not found. One of “raise”, “warn”, “ignore”.
The name of the extra dependency group.
Returns: Any
The imported module, or None if not available and error=“ignore”.
Raises:
ImportError: If the module is not available and error=“raise”.