From 9f0abf014d12c8dfee357e3d4e445d4a93bf1ccd Mon Sep 17 00:00:00 2001 From: David Asamu Date: Sat, 19 Jul 2025 03:06:17 +0100 Subject: [PATCH] format changed files --- libs/cli/langgraph_cli/cli.py | 10 ++++- libs/cli/tests/unit_tests/cli/test_cli.py | 48 ++++++++++++++--------- libs/cli/tests/unit_tests/test_config.py | 26 ++++++------ libs/cli/tests/unit_tests/test_docker.py | 40 +++++++++---------- 4 files changed, 71 insertions(+), 53 deletions(-) diff --git a/libs/cli/langgraph_cli/cli.py b/libs/cli/langgraph_cli/cli.py index 8ca1594a6..960c7a545 100644 --- a/libs/cli/langgraph_cli/cli.py +++ b/libs/cli/langgraph_cli/cli.py @@ -388,7 +388,15 @@ def build( config_json = langgraph_cli.config.validate_config_file(config) warn_non_wolfi_distro(config_json) _build( - runner, set, config, config_json, base_image, api_version, pull, tag, docker_build_args + runner, + set, + config, + config_json, + base_image, + api_version, + pull, + tag, + docker_build_args, ) diff --git a/libs/cli/tests/unit_tests/cli/test_cli.py b/libs/cli/tests/unit_tests/cli/test_cli.py index 854e99304..137fd3248 100644 --- a/libs/cli/tests/unit_tests/cli/test_cli.py +++ b/libs/cli/tests/unit_tests/cli/test_cli.py @@ -592,10 +592,12 @@ def test_dockerfile_command_with_api_version() -> None: result = runner.invoke( cli, [ - "dockerfile", - str(save_path), - "--config", str(temp_dir / "config.json"), - "--api-version", "0.2.74" + "dockerfile", + str(save_path), + "--config", + str(temp_dir / "config.json"), + "--api-version", + "0.2.74", ], ) @@ -628,11 +630,14 @@ def test_dockerfile_command_with_api_version_and_base_image() -> None: result = runner.invoke( cli, [ - "dockerfile", - str(save_path), - "--config", str(temp_dir / "config.json"), - "--api-version", "1.0.0", - "--base-image", "my-registry/custom-api" + "dockerfile", + str(save_path), + "--config", + str(temp_dir / "config.json"), + "--api-version", + "1.0.0", + "--base-image", + "my-registry/custom-api", ], ) @@ -663,10 +668,12 @@ def test_dockerfile_command_with_api_version_nodejs() -> None: result = runner.invoke( cli, [ - "dockerfile", - str(save_path), - "--config", str(temp_dir / "config.json"), - "--api-version", "0.2.74" + "dockerfile", + str(save_path), + "--config", + str(temp_dir / "config.json"), + "--api-version", + "0.2.74", ], ) @@ -705,8 +712,9 @@ def test_build_command_with_api_version() -> None: "test-image", "--config", str(temp_dir / "config.json"), - "--api-version", "0.2.74", - "--no-pull" # Avoid pulling non-existent images + "--api-version", + "0.2.74", + "--no-pull", # Avoid pulling non-existent images ], catch_exceptions=True, ) @@ -740,9 +748,11 @@ def test_build_command_with_api_version_and_base_image() -> None: "test-image", "--config", str(temp_dir / "config.json"), - "--api-version", "1.0.0", - "--base-image", "my-registry/custom-api", - "--no-pull" # Avoid pulling non-existent images + "--api-version", + "1.0.0", + "--base-image", + "my-registry/custom-api", + "--no-pull", # Avoid pulling non-existent images ], catch_exceptions=True, ) @@ -779,7 +789,7 @@ def test_prepare_args_and_stdin_with_api_version() -> None: # Check that the args are correct assert actual_args == expected_args - + # Check that the stdin contains the correct FROM line with api_version assert f"FROM langchain/langgraph-api:0.2.74-py3.11" in actual_stdin diff --git a/libs/cli/tests/unit_tests/test_config.py b/libs/cli/tests/unit_tests/test_config.py index f4cf64643..b27fc38ef 100644 --- a/libs/cli/tests/unit_tests/test_config.py +++ b/libs/cli/tests/unit_tests/test_config.py @@ -1290,7 +1290,7 @@ def test_docker_tag_different_node_versions_with_distro(): def test_docker_tag_with_api_version(): """Test docker_tag function with api_version parameter.""" - + # Test 1: Python config with api_version and default distro config = validate_config( { @@ -1402,13 +1402,15 @@ def test_docker_tag_with_api_version(): "graphs": {"agent": "./agent.py:graph"}, } ) - tag = docker_tag(config, base_image="langchain/langgraph-server:0.2", api_version="0.2.74") + tag = docker_tag( + config, base_image="langchain/langgraph-server:0.2", api_version="0.2.74" + ) assert tag == "langchain/langgraph-server:0.2-py3.11" def test_config_to_docker_with_api_version(): """Test config_to_docker function with api_version parameter.""" - + # Test Python config with api_version graphs = {"agent": "./agent.py:graph"} actual_docker_stdin, additional_contexts = config_to_docker( @@ -1417,9 +1419,9 @@ def test_config_to_docker_with_api_version(): "langchain/langgraph-api", api_version="0.2.74", ) - + # Check that the FROM line uses the api_version - lines = actual_docker_stdin.split('\n') + lines = actual_docker_stdin.split("\n") from_line = lines[0] assert from_line == "FROM langchain/langgraph-api:0.2.74-py3.11" @@ -1431,16 +1433,16 @@ def test_config_to_docker_with_api_version(): "langchain/langgraphjs-api", api_version="0.2.74", ) - + # Check that the FROM line uses the api_version - lines = actual_docker_stdin.split('\n') + lines = actual_docker_stdin.split("\n") from_line = lines[0] assert from_line == "FROM langchain/langgraphjs-api:0.2.74-node20" def test_config_to_compose_with_api_version(): """Test config_to_compose function with api_version parameter.""" - + # Test Python config with api_version config = validate_config( { @@ -1448,14 +1450,14 @@ def test_config_to_compose_with_api_version(): "graphs": {"agent": "./agent.py:graph"}, } ) - + actual_compose_str = config_to_compose( PATH_TO_CONFIG, config, "langchain/langgraph-api", api_version="0.2.74", ) - + # Check that the compose file includes the correct FROM line with api_version assert "FROM langchain/langgraph-api:0.2.74-py3.11" in actual_compose_str @@ -1466,13 +1468,13 @@ def test_config_to_compose_with_api_version(): "graphs": {"agent": "./agent.js:graph"}, } ) - + actual_compose_str = config_to_compose( PATH_TO_CONFIG, config, "langchain/langgraphjs-api", api_version="0.2.74", ) - + # Check that the compose file includes the correct FROM line with api_version assert "FROM langchain/langgraphjs-api:0.2.74-node20" in actual_compose_str diff --git a/libs/cli/tests/unit_tests/test_docker.py b/libs/cli/tests/unit_tests/test_docker.py index 0ca2c2a61..b29118a26 100644 --- a/libs/cli/tests/unit_tests/test_docker.py +++ b/libs/cli/tests/unit_tests/test_docker.py @@ -152,14 +152,12 @@ def test_compose_with_api_version(): """Test compose function with api_version parameter.""" port = 8123 api_version = "0.2.74" - + actual_compose_str = compose( - DEFAULT_DOCKER_CAPABILITIES, - port=port, - api_version=api_version + DEFAULT_DOCKER_CAPABILITIES, port=port, api_version=api_version ) - - # The compose function should generate a compose file that doesn't directly + + # The compose function should generate a compose file that doesn't directly # reference the api_version, since it's handled in the docker tag creation # when building the image. The compose function mainly sets up services. expected_compose_str = f"""volumes: @@ -212,14 +210,14 @@ def test_compose_with_api_version_and_base_image(): port = 8123 api_version = "1.0.0" base_image = "my-registry/custom-api" - + actual_compose_str = compose( - DEFAULT_DOCKER_CAPABILITIES, - port=port, + DEFAULT_DOCKER_CAPABILITIES, + port=port, api_version=api_version, - base_image=base_image + base_image=base_image, ) - + # Similar to the previous test - the compose function doesn't directly embed # the api_version or base_image into the compose file since those are handled # during the docker build process @@ -273,14 +271,14 @@ def test_compose_with_api_version_and_custom_postgres(): port = 8123 api_version = "0.2.74" custom_postgres_uri = "postgresql://user:pass@external-db:5432/mydb" - + actual_compose_str = compose( - DEFAULT_DOCKER_CAPABILITIES, - port=port, + DEFAULT_DOCKER_CAPABILITIES, + port=port, api_version=api_version, - postgres_uri=custom_postgres_uri + postgres_uri=custom_postgres_uri, ) - + expected_compose_str = f"""services: langgraph-redis: image: redis:6 @@ -306,14 +304,14 @@ def test_compose_with_api_version_and_debugger(): port = 8123 debugger_port = 8001 api_version = "0.2.74" - + actual_compose_str = compose( - DEFAULT_DOCKER_CAPABILITIES, - port=port, + DEFAULT_DOCKER_CAPABILITIES, + port=port, api_version=api_version, - debugger_port=debugger_port + debugger_port=debugger_port, ) - + expected_compose_str = f"""volumes: langgraph-data: driver: local