File size: 1,410 Bytes
02412f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""Methods package — registry-driven re-exports.

Each family module's ``@register``-decorated classes self-register at import
time. Importing this package eagerly imports every family module so
``ALL_METHODS`` is fully populated and ``ml.methods.<ClassName>`` resolves
without a per-call lazy fallback.
"""

from __future__ import annotations

from ._registry import ALL_METHODS, get, list_methods, register

# Eagerly import every family module so every @register decorator fires.
# Order is alphabetical for determinism. Any ImportError here is a real
# bug — let it propagate (do not silence).
from . import (  # noqa: E402,F401
    classical,
    llm,
    llm_finetune,
    llm_ts_reason,
    naive,
    sequence,
    tsfm,
)


def __getattr__(name: str):
    """Resolve ``methods.<ClassName>`` lookups via the registry.

    The registry stores classes by their lowercase ``name`` attr; the public
    re-export uses the class's actual Python name (e.g. ``Persistence``,
    ``LightGBMRegressor``). Search every registered class for a Python-name
    match, then fall back to the lowercase registry id.
    """
    for cls in ALL_METHODS.values():
        if cls.__name__ == name:
            return cls
    if name in ALL_METHODS:
        return ALL_METHODS[name]
    raise AttributeError(f"module 'methods' has no attribute {name!r}")


__all__ = ["ALL_METHODS", "get", "list_methods", "register"]