Skip to content

Commit

Permalink
core[patch]: Update sys info information (langchain-ai#16297)
Browse files Browse the repository at this point in the history
Update information collected in sys info.

python -m langchain_core.sys_info     

System Information
------------------
> OS:  Linux
> OS Version: #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30
UTC 2
> Python Version:  3.11.4 (main, Sep 25 2023, 10:06:23) [GCC 11.4.0]

Package Information
-------------------
> langchain_core: 0.1.10
> langchain: 0.1.0
> langchain_community: 0.0.11
> langchain_cli: 0.0.20
> langchain_experimental: 0.0.36
> langchain_openai: 0.0.2
> langchainhub: 0.1.14
> langserve: 0.0.19

Packages not installed (Not Necessarily a Problem)
--------------------------------------------------
The following packages were not found:

> langgraph
  • Loading branch information
eyurtsev authored Jan 22, 2024
1 parent 5396604 commit 89372fc
Showing 1 changed file with 35 additions and 8 deletions.
43 changes: 35 additions & 8 deletions libs/core/langchain_core/sys_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,32 @@

def print_sys_info(*, additional_pkgs: Sequence[str] = tuple()) -> None:
"""Print information about the environment for debugging purposes."""
import pkgutil
import platform
import sys
from importlib import metadata, util

packages = [
"langchain_core",
"langchain",
"langchain_community",
# Packages that do not start with "langchain" prefix.
other_langchain_packages = [
"langserve",
] + list(additional_pkgs)
"langgraph",
]

langchain_pkgs = [
name for _, name, _ in pkgutil.iter_modules() if name.startswith("langchain")
]

all_packages = sorted(
set(langchain_pkgs + other_langchain_packages + list(additional_pkgs))
)

# Always surface these packages to the top
order_by = ["langchain_core", "langchain", "langchain_community"]

for pkg in reversed(order_by):
if pkg in all_packages:
all_packages.remove(pkg)
all_packages = [pkg] + list(all_packages)

system_info = {
"OS": platform.system(),
Expand All @@ -32,13 +48,15 @@ def print_sys_info(*, additional_pkgs: Sequence[str] = tuple()) -> None:
print("Package Information")
print("-------------------")

for pkg in packages:
not_installed = []

for pkg in all_packages:
try:
found_package = util.find_spec(pkg)
except Exception:
found_package = None
if found_package is None:
print(f"> {pkg}: Not Found")
not_installed.append(pkg)
continue

# Package version
Expand All @@ -51,7 +69,16 @@ def print_sys_info(*, additional_pkgs: Sequence[str] = tuple()) -> None:
if package_version is not None:
print(f"> {pkg}: {package_version}")
else:
print(f"> {pkg}: Found")
print(f"> {pkg}: Installed. No version info available.")

if not_installed:
print()
print("Packages not installed (Not Necessarily a Problem)")
print("--------------------------------------------------")
print("The following packages were not found:")
print()
for pkg in not_installed:
print(f"> {pkg}")


if __name__ == "__main__":
Expand Down

0 comments on commit 89372fc

Please sign in to comment.