MacroLens / code /macrolens /methods.py
itouchz's picture
Duplicate from macrolens/MacroLens
ff4becd
Raw
History Blame Contribute Delete
1.42 kB
"""Public method namespace for the MacroLens unified API.
``import macrolens as ml; ml.methods.<ClassName>(task=...)`` resolves to
the registered concrete method class via the registry-driven
``methods/__init__.py`` package. This module is a re-export shim — every
attribute lookup is delegated to the underlying ``methods`` package's own
``__getattr__``, which performs the class-name → registered class lookup.
This file is intentionally lightweight; we avoid eagerly importing every
family module here (the underlying ``methods/__init__.py`` has already done
the eager import on first import of the package, so all classes are
discoverable through the registry).
"""
from __future__ import annotations
from typing import Any
from .. import methods as _methods
# Re-export the registry helpers at module scope so callers can do
# ``ml.methods.list_methods(...)`` / ``ml.methods.ALL_METHODS`` without
# walking through the underscore module.
ALL_METHODS = _methods.ALL_METHODS
list_methods = _methods.list_methods
get = _methods.get
register = _methods.register
def __getattr__(name: str) -> Any:
"""Delegate attribute access to ``methods/__init__.py:__getattr__``.
Resolves ``ml.methods.Persistence``, ``ml.methods.LightGBMRegressor``,
etc., via the underlying registry-driven lookup.
"""
return getattr(_methods, name)
__all__ = ["ALL_METHODS", "list_methods", "get", "register"]