labthings_fastapi.utilities.object_reference_to_object

Load objects from object references.

Functions

object_reference_to_object(→ Any)

Convert a string reference to an object.

Module Contents

labthings_fastapi.utilities.object_reference_to_object.object_reference_to_object(object_reference: str) Any

Convert a string reference to an object.

This is taken from: https://packaging.python.org/en/latest/specifications/entry-points/

The format of the string is module_name:qualname where qualname is the fully qualified name of the object within the module. This is the same format used by entrypoints` in setup.py files.

Parameters:

object_reference – a string referencing a Python object to import.

Returns:

the Python object.

Raises:

ImportError – if the referenced object cannot be found or imported.