maxent_grpo.utils.imports¶
Shared helpers for optional and required dependency imports.
Functions
|
Import a module with caching to avoid repeated lookups. |
|
Import a module if available without bubbling up ImportError. |
|
Import a dependency or raise a helpful error when it is missing. |
- maxent_grpo.utils.imports.cached_import(module_name)[source]¶
Import a module with caching to avoid repeated lookups.
- Parameters:
module_name (str) – Fully qualified module path to import.
- Returns:
Imported module object, cached for subsequent calls.
- Raises:
ImportError – Propagated if the module cannot be imported.
- Return type:
- maxent_grpo.utils.imports.optional_import(module_name)[source]¶
Import a module if available without bubbling up ImportError.
This deliberately skips the cached importer so tests and call sites that monkeypatch
sys.modulessee their changes reflected immediately.- Parameters:
module_name (str) – Fully qualified module path to import.
- Returns:
Imported module, or
Nonewhen the module is missing.- Return type:
ModuleType | None
- maxent_grpo.utils.imports.require_dependency(module_name, context_hint)[source]¶
Import a dependency or raise a helpful error when it is missing.
- Parameters:
- Returns:
Imported module, if available.
- Raises:
ImportError – Wrapped with
context_hintwhen the dependency is absent.- Return type: