Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/art/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@
"""

import os
from typing import Any, TYPE_CHECKING

from dotenv import load_dotenv

if TYPE_CHECKING:
from .local import LocalBackend

load_dotenv()

if os.getenv("SUPPRESS_LITELLM_SERIALIZATION_WARNINGS", "1") == "1":
Expand Down Expand Up @@ -88,6 +92,17 @@ def __init__(self, **kwargs):
from .utils import retry
from .yield_trajectory import capture_yielded_trajectory, yield_trajectory


def __getattr__(name: str) -> Any:
if name == "LocalBackend":
# Keep backend-only dependencies optional until the symbol is requested.
from .local import LocalBackend

globals()[name] = LocalBackend
return LocalBackend
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")


__all__ = [
"dev",
"auto_trajectory",
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/test_package_exports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import art


def test_art_localbackend_top_level_export():
from art.local import LocalBackend

assert art.LocalBackend is LocalBackend