File size: 1,506 Bytes
31dc8dc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
45
46
47
48
49
50
51
52
53
54
55
"""Diffulex package root.

Keep this module lightweight so that importing does not eagerly
import the full engine/kernel.
"""

from __future__ import annotations

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    # These are available for type checkers; runtime import is lazy via __getattr__.
    from diffulex.diffulex import Diffulex as Diffulex  # noqa: F401
    from diffulex.sampling_params import SamplingParams as SamplingParams  # noqa: F401
    from diffulex.logger import (
        get_logger as get_logger,
        setup_logger as setup_logger,
        LoggerMixin as LoggerMixin,
    )  # noqa: F401


def __getattr__(name: str):
    if name == "Diffulex":
        # Only trigger heavy side-effect imports when users actually construct the engine.
        # Keeps import lightweight.
        from diffulex import strategy as _strategy  # noqa: F401
        from diffulex.diffulex import Diffulex

        return Diffulex

    if name == "SamplingParams":
        from diffulex.sampling_params import SamplingParams

        return SamplingParams

    if name == "get_logger":
        from diffulex.logger import get_logger

        return get_logger

    if name == "setup_logger":
        from diffulex.logger import setup_logger

        return setup_logger

    if name == "LoggerMixin":
        from diffulex.logger import LoggerMixin

        return LoggerMixin

    raise AttributeError(name)


__all__ = ["Diffulex", "SamplingParams", "get_logger", "setup_logger", "LoggerMixin"]