hyrax.plugin_utils
Attributes
Functions
|
Given a configuration dictionary and a registry dictionary, attempt to return |
|
Dynamically import a module from a string. |
|
Add a class to a given registry dictionary. |
Module Contents
- get_or_load_class(class_name: str, registry: dict[str, T] | None = None) T | Any[source]
Given a configuration dictionary and a registry dictionary, attempt to return the requested class either from the registry or by dynamically importing it.
- Parameters:
class_name (str) – The name of the class to load.
registry (dict) – The registry dictionary of <class name> : <class type> pairs.
- Returns:
The returned class to be instantiated
- Return type:
type
- import_module_from_string(module_path: str) Any[source]
Dynamically import a module from a string.
- Parameters:
module_path (str) – The import spec for the requested class. Should be of the form: “module.submodule.ClassName”
- Returns:
returned_cls – The class type that was loaded.
- Return type:
type
- Raises:
AttributeError – If the class is not found in the module that is loaded.
ModuleNotFoundError – If the module is not found using the provided import spec.