Update error message for missing dev command

This commit is contained in:
William Fu-Hinthorn
2025-01-14 11:28:51 -08:00
parent b989502c24
commit 2f47d98b34
3 changed files with 26 additions and 4 deletions
+11 -1
View File
@@ -575,6 +575,13 @@ 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
@@ -582,16 +589,19 @@ def dev(
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))
+1 -1
View File
@@ -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"
+14 -2
View File
@@ -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"