Skip to content

Commit

Permalink
Update error message for missing dev command
Browse files Browse the repository at this point in the history
hinthornw committed Jan 14, 2025
1 parent b989502 commit 2f47d98
Showing 3 changed files with 26 additions and 4 deletions.
12 changes: 11 additions & 1 deletion libs/cli/langgraph_cli/cli.py
Original file line number Diff line number Diff line change
@@ -575,23 +575,33 @@ def dev(
try:
from langgraph_api.cli import run_server
except ImportError:
py_version_msg = ""
if sys.version_info < (3, 11):
py_version_msg = (
"\n\nNote: The in-mem server requires Python 3.11 or higher to be installed."
f" You are currently using Python {sys.version_info.major}.{sys.version_info.minor}."
' Please upgrade your Python version before installing "langgraph-cli[inmem]".'
)
try:
from importlib import util

if not util.find_spec("langgraph_api"):
raise click.UsageError(
"Required package 'langgraph-api' is not installed.\n"
"Please install it with:\n\n"
' pip install -U "langgraph-cli[inmem]"\n\n'
' pip install -U "langgraph-cli[inmem]"'
f"{py_version_msg}"
) from None
except ImportError:
raise click.UsageError(
"Could not verify package installation. Please ensure Python is up to date and\n"
"langgraph-cli is installed with the 'inmem' extra: pip install -U \"langgraph-cli[inmem]\""
f"{py_version_msg}"
) from None
raise click.UsageError(
"Could not import run_server. This likely means your installation is incomplete.\n"
"Please ensure langgraph-cli is installed with the 'inmem' extra: pip install -U \"langgraph-cli[inmem]\""
f"{py_version_msg}"
) from None

config_json = langgraph_cli.config.validate_config_file(pathlib.Path(config))
2 changes: 1 addition & 1 deletion libs/cli/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langgraph-cli"
version = "0.1.66"
version = "0.1.67"
description = "CLI for interacting with LangGraph API"
authors = []
license = "MIT"
16 changes: 14 additions & 2 deletions libs/cli/tests/unit_tests/test_config.py
Original file line number Diff line number Diff line change
@@ -91,10 +91,22 @@ def test_validate_config():
validate_config({"python_version": "3.10"})
assert "Minimum required version" in str(exc_info.value)

config = validate_config({"python_version": "3.11-bullseye", "dependencies": ["."], "graphs": {"agent": "./agent.py:graph"}})
config = validate_config(
{
"python_version": "3.11-bullseye",
"dependencies": ["."],
"graphs": {"agent": "./agent.py:graph"},
}
)
assert config["python_version"] == "3.11-bullseye"

config = validate_config({"python_version": "3.12-slim", "dependencies": ["."], "graphs": {"agent": "./agent.py:graph"}})
config = validate_config(
{
"python_version": "3.12-slim",
"dependencies": ["."],
"graphs": {"agent": "./agent.py:graph"},
}
)
assert config["python_version"] == "3.12-slim"


0 comments on commit 2f47d98

Please sign in to comment.