nirs4all.utils.lazy module
Lazy module proxy for deferring heavy imports to first use.
Some modules (e.g. chart controllers) must be importable eagerly — the controller
registry imports them at import nirs4all so routing knows about them — but only
need a heavy dependency (matplotlib) when they actually render. Binding the
dependency to a module-level LazyModule keeps the familiar
plt = lazy_module("matplotlib.pyplot") name while deferring the real import
until an attribute is first accessed, so importing the package stays cheap.
A module-level __getattr__ (PEP 562) cannot serve this purpose: it is only
consulted for external attribute access on the package, not for internal global
name lookups like plt.subplots(...) inside the module’s own functions. The proxy
object is bound as a real global, so internal usage resolves normally and triggers
the lazy import on the first attribute access.