sparknlp_jsl.utils.imports#

Module Contents#

Functions#

is_module_importable(→ bool)

Tests whether a given module can be imported in the current environment.

is_module_importable(lib: str, raise_exception: bool = False, pip_name: bool | None = None, message_type='function') bool#

Tests whether a given module can be imported in the current environment.

Return True if Lib can be imported, False if not when raise_exception is False, otherwise raises Exception when not importable.

Parameters:
  • lib (str) – import name of module to test

  • raise_exception (bool) – Whether to raise exception when module cannot be imported or not.

  • pip_name (bool) – If raise exception this is required. Part of the error message for install instruction.

  • message_type (str) – Either ‘function’ or ‘module’ which will change the style of error message.

Returns:

True if importable, False if not when raise_exception is False, otherwise raises Exception when not importable.

Return type:

bool