Home / Function/ test_import_all_using_dir() — langchain Function Reference

test_import_all_using_dir() — langchain Function Reference

Architecture documentation for the test_import_all_using_dir() function in test_imports.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  81ee66f1_5106_fc63_3ec5_ee1d7eb86f5d["test_import_all_using_dir()"]
  1a4ae21b_d553_aa88_bac6_fd6971a4e02d["test_imports.py"]
  81ee66f1_5106_fc63_3ec5_ee1d7eb86f5d -->|defined in| 1a4ae21b_d553_aa88_bac6_fd6971a4e02d
  style 81ee66f1_5106_fc63_3ec5_ee1d7eb86f5d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/tests/unit_tests/test_imports.py lines 49–75

def test_import_all_using_dir() -> None:
    """Generate the public API for this package."""
    library_code = PKG_ROOT / "langchain_classic"
    for path in library_code.rglob("*.py"):
        # Calculate the relative path to the module
        module_name = (
            path.relative_to(PKG_ROOT).with_suffix("").as_posix().replace("/", ".")
        )
        if module_name.endswith("__init__"):
            # Without init
            module_name = module_name.rsplit(".", 1)[0]

        if module_name.startswith("langchain_community.") and COMMUNITY_NOT_INSTALLED:
            continue

        try:
            mod = importlib.import_module(module_name)
        except ModuleNotFoundError as e:
            msg = f"Could not import {module_name}"
            raise ModuleNotFoundError(msg) from e
        attributes = dir(mod)

        for name in attributes:
            if name.strip().startswith("_"):
                continue
            # Attempt to import the name from the module
            getattr(mod, name)

Domain

Subdomains

Frequently Asked Questions

What does test_import_all_using_dir() do?
test_import_all_using_dir() is a function in the langchain codebase, defined in libs/langchain/tests/unit_tests/test_imports.py.
Where is test_import_all_using_dir() defined?
test_import_all_using_dir() is defined in libs/langchain/tests/unit_tests/test_imports.py at line 49.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free