calpit._optional
Imports of optional dependencies with errors that name the extra to install.
Functions
|
Imports an optional dependency. |
Module Contents
- import_optional(module_name: str, extra: str, feature: str) types.ModuleType[source]
Imports an optional dependency.
- Parameters:
module_name – The module to import, such as “torch”.
extra – The calpit extra that installs it, such as “torch”.
feature – What needs the module, for the error message.
- Returns:
The imported module.
- Raises:
ImportError – If the module is not installed.