caikit.interfaces.ts.data_model.toolkit.optional_dependencies

This module encapsulates the core optional dependencies using lazy imports.

Attributes

log

pd

pyspark

HAVE_NUMPY

HAVE_PANDAS

HAVE_PYSPARK

Classes

LazyModule

A LazyModule is a module subclass that wraps another module but imports

Functions

have_module(→ bool)

This method can be used to check whether a given optional dependency is

Module Contents

caikit.interfaces.ts.data_model.toolkit.optional_dependencies.log[source]
class caikit.interfaces.ts.data_model.toolkit.optional_dependencies.LazyModule(name: str, package: str | None = None)[source]

Bases: types.ModuleType

A LazyModule is a module subclass that wraps another module but imports it lazily and then aliases __getattr__ to the lazily imported module.

__name
__package = None
__wrapped_module = None
__getattr__(name: str) any[source]

When asked for an attribute, make sure the wrapped module is imported and then delegate

caikit.interfaces.ts.data_model.toolkit.optional_dependencies.have_module(name: str, package: str | None = None) bool[source]

This method can be used to check whether a given optional dependency is available and should primarily be used for assertions when coding defensively.

NOTE: Nested modules WILL force the import of parent modules

TODO: Move this to import_tracker

Args:
name: str

The name of the module

package: Optional[str]

The qualifying package for the module under investigation

Returns:
have_module: bool

True if the module can be imported, False otherwise

caikit.interfaces.ts.data_model.toolkit.optional_dependencies.pd
caikit.interfaces.ts.data_model.toolkit.optional_dependencies.pyspark
caikit.interfaces.ts.data_model.toolkit.optional_dependencies.HAVE_NUMPY
caikit.interfaces.ts.data_model.toolkit.optional_dependencies.HAVE_PANDAS
caikit.interfaces.ts.data_model.toolkit.optional_dependencies.HAVE_PYSPARK