import_object#

composer.utils.import_object(name)[source]#

Dynamically import a Python object (e.g. class, function, โ€ฆ).

Note

To dynamically import a module, use importlib.import_module().

Parameters

name (str) โ€“

The path to the Python object to import.

Separate the module name and class name with a ':' (e.g. 'path.to.module:function_name').

Example

>>> from composer.utils import import_object
>>> import_object('functools:partial')
<class 'functools.partial'>

Note

The module name must be discoverale with the Python path, as determined by sys.path.

Returns

Any โ€“ The imported object.