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. |
|
Save a prepare_inputs function to a specified path. |
|
Load a prepare_inputs function from a specified path. |
|
Save a to_tensor function to a specified path. |
|
Load a to_tensor function from a specified path. |
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.
- update_registry(registry: dict, name: str, class_type: type)[source]#
Add a class to a given registry dictionary.
- Parameters:
registry (dict) – The registry to update.
name (str) – The name of the class.
class_type (type) – The class type to be instantiated.
- save_prepare_inputs(prepare_inputs_fn, save_path: pathlib.Path)[source]#
Save a prepare_inputs function to a specified path.
- Parameters:
prepare_inputs_fn (collections.abc.Callable) – The prepare_inputs function to save.
save_path (pathlib.Path) – The path to save the prepare_inputs function to.
- load_prepare_inputs(load_path: pathlib.Path)[source]#
Load a prepare_inputs function from a specified path.
- Parameters:
load_path (pathlib.Path) – The directory containing the prepare_inputs.py module to load.
- Returns:
The loaded prepare_inputs function.
- Return type:
collections.abc.Callable or None