From 5eefc1d55dd8ebfc4e4bbae9114fbf93bf211468 Mon Sep 17 00:00:00 2001 From: Tat Dat Duong Date: Fri, 11 Apr 2025 16:38:26 +0200 Subject: [PATCH] fix(cli): invert assumed python_version / js_version check --- libs/cli/langgraph_cli/config.py | 20 +++++++++++++------- libs/cli/pyproject.toml | 2 +- libs/cli/tests/unit_tests/test_config.py | 11 +++++++++++ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/libs/cli/langgraph_cli/config.py b/libs/cli/langgraph_cli/config.py index d26065011..f11850016 100644 --- a/libs/cli/langgraph_cli/config.py +++ b/libs/cli/langgraph_cli/config.py @@ -443,16 +443,22 @@ def _parse_node_version(version_str: str) -> int: ) from None -def _is_python_graph(spec: Union[str, dict]) -> bool: - """Check if a graph is a Python graph based on the file extension.""" - - # handle new style config +def _is_node_graph(spec: Union[str, dict]) -> bool: + """Check if a graph is a Node.js graph based on the file extension.""" if isinstance(spec, dict): spec = spec.get("path") file_path = spec.split(":")[0] file_ext = os.path.splitext(file_path)[1] - return file_ext in [".py", ".pyx", ".pyd", ".pyi"] + + return file_ext in [ + ".ts", + ".mts", + ".cts", + ".js", + ".mjs", + ".cjs", + ] def validate_config(config: Config) -> Config: @@ -460,8 +466,8 @@ def validate_config(config: Config) -> Config: graphs = config.get("graphs", {}) - some_python = any(_is_python_graph(spec) for spec in graphs.values()) - some_node = any(not _is_python_graph(spec) for spec in graphs.values()) + some_node = any(_is_node_graph(spec) for spec in graphs.values()) + some_python = any(not _is_node_graph(spec) for spec in graphs.values()) node_version = config.get( "node_version", DEFAULT_NODE_VERSION if some_node else None diff --git a/libs/cli/pyproject.toml b/libs/cli/pyproject.toml index 79a7e6340..a17a8dbc3 100644 --- a/libs/cli/pyproject.toml +++ b/libs/cli/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langgraph-cli" -version = "0.2.2" +version = "0.2.3" description = "CLI for interacting with LangGraph API" authors = [] license = "MIT" diff --git a/libs/cli/tests/unit_tests/test_config.py b/libs/cli/tests/unit_tests/test_config.py index a70960a7b..0249510ab 100644 --- a/libs/cli/tests/unit_tests/test_config.py +++ b/libs/cli/tests/unit_tests/test_config.py @@ -234,6 +234,17 @@ def test_validate_config_multiplatform(): assert config["node_version"] == "20" assert config["python_version"] == "3.12" + # no known extension (assumes python) + config = validate_config( + { + "dependencies": ["./local", "./shared_utils"], + "graphs": {"agent": "local.workflow:graph"}, + "env": ".env", + } + ) + assert config["node_version"] is None + assert config["python_version"] == "3.11" + # config_to_docker def test_config_to_docker_simple():