alibi_detect.utils.missing_optional_dependency
Functionality for optional importing This module provides a way to import optional dependencies. In the case that the user imports some functionality from alibi-detect that is not usable due to missing optional dependencies this code is used to allow the import but replace it with an object that throws an error on use. This way we avoid errors at import time that prevent the user using functionality independent of the missing dependency.
Constants
err_msg_template
err_msg_templateerr_msg_template: string.Template = <string.Template object at 0x10266e1f0>A string class for supporting $-substitutions.
ERROR_TYPES
ERROR_TYPESERROR_TYPES: dict = {'prophet': 'prophet', 'tensorflow_probability': 'tensorflow', 'tensorflow': ...MissingDependency
MissingDependencyMissing Dependency Class.
Used to replace any object that requires unmet optional dependencies. Attribute access or calling the call method on this object will raise an error.
Constructor
MissingDependency(self, object_name: str, err: Union[ModuleNotFoundError, ImportError], missing_dependency: str = 'all')object_name
str
Name of object we are replacing
err
Union[ModuleNotFoundError, ImportError]
Error to be raised when the class is initialized or used
missing_dependency
str
'all'
Name of missing dependency required for object
Properties
err_msg
str
Generate error message informing user to install missing dependencies.
Functions
import_optional
import_optionalimport_optional(module_name: str, names: Optional[List[str]] = None) -> typing.AnyImport a module that depends on optional dependencies
Note: This function is used to import modules that depend on optional dependencies. Because it mirrors the python import functionality its return type has to be Any. Using objects imported with this function can lead to misspecification of types as Any when the developer intended to be more restrictive.
module_name
str
The module to import
names
Optional[List[str]]
None
The names to import from the module. If None, all names are imported.
Returns
Type:
typing.Any
Last updated
Was this helpful?

