mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-27 14:26:48 +00:00
x
This commit is contained in:
@@ -45,6 +45,12 @@ def import_all_modules(package_name: str) -> dict:
|
|||||||
for importer, modname, ispkg in pkgutil.walk_packages(
|
for importer, modname, ispkg in pkgutil.walk_packages(
|
||||||
package.__path__, package.__name__ + "."
|
package.__path__, package.__name__ + "."
|
||||||
):
|
):
|
||||||
|
if modname.startswith("langchain_core.pydantic_v1") or modname.startswith(
|
||||||
|
"langchain.pydantic_v1"
|
||||||
|
):
|
||||||
|
# These are deprecated and should not be imported as they
|
||||||
|
# intentionally raise an import error
|
||||||
|
continue
|
||||||
try:
|
try:
|
||||||
module = importlib.import_module(modname)
|
module = importlib.import_module(modname)
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
@@ -138,8 +144,15 @@ def test_serializable_mapping() -> None:
|
|||||||
|
|
||||||
for k, import_path in serializable_modules.items():
|
for k, import_path in serializable_modules.items():
|
||||||
import_dir, import_obj = import_path[:-1], import_path[-1]
|
import_dir, import_obj = import_path[:-1], import_path[-1]
|
||||||
|
module = ".".join(import_dir)
|
||||||
|
if module.startswith("langchain_core.pydantic_v1") or module.startswith(
|
||||||
|
"langchain.pydantic_v1"
|
||||||
|
):
|
||||||
|
# These are deprecated and should not be imported as they
|
||||||
|
# intentionally raise an import error
|
||||||
|
continue
|
||||||
# Import module
|
# Import module
|
||||||
mod = importlib.import_module(".".join(import_dir))
|
mod = importlib.import_module(module)
|
||||||
# Import class
|
# Import class
|
||||||
cls = getattr(mod, import_obj)
|
cls = getattr(mod, import_obj)
|
||||||
assert list(k) == cls.lc_id()
|
assert list(k) == cls.lc_id()
|
||||||
|
Reference in New Issue
Block a user