mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-17 23:27:56 +02:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6ca4858b3 | ||
|
|
790a4a1a10 | ||
|
|
c39a3a7c87 | ||
|
|
c503e02bca | ||
|
|
64fe90cbdd | ||
|
|
6cd293481c |
@@ -66,14 +66,34 @@ def _get_pip_cleanup_lines(
|
|||||||
to_uninstall: tuple[str] | None,
|
to_uninstall: tuple[str] | None,
|
||||||
pip_installer: Literal["uv", "pip"],
|
pip_installer: Literal["uv", "pip"],
|
||||||
) -> str:
|
) -> str:
|
||||||
commands = [
|
commands = ["# -- Validate installed dependencies are internally consistent --"]
|
||||||
f"""# -- Ensure user deps didn't inadvertently overwrite langgraph-api
|
if pip_installer == "uv":
|
||||||
|
commands.append(
|
||||||
|
"""RUN uv pip check --system || ( \
|
||||||
|
echo "Dependency resolution check failed. One or more installed packages are incompatible."; \
|
||||||
|
echo "Pin compatible versions in your dependencies and try again."; \
|
||||||
|
exit 1 \
|
||||||
|
)"""
|
||||||
|
)
|
||||||
|
elif pip_installer == "pip":
|
||||||
|
commands.append(
|
||||||
|
"""RUN python -m pip check || ( \
|
||||||
|
echo "Dependency resolution check failed. One or more installed packages are incompatible."; \
|
||||||
|
echo "Pin compatible versions in your dependencies and try again."; \
|
||||||
|
exit 1 \
|
||||||
|
)"""
|
||||||
|
)
|
||||||
|
commands.append(
|
||||||
|
"""# -- End dependency validation --
|
||||||
|
# -- Ensure user deps didn't inadvertently overwrite langgraph-api
|
||||||
RUN mkdir -p /api/langgraph_api /api/langgraph_runtime /api/langgraph_license && \
|
RUN mkdir -p /api/langgraph_api /api/langgraph_runtime /api/langgraph_license && \
|
||||||
touch /api/langgraph_api/__init__.py /api/langgraph_runtime/__init__.py /api/langgraph_license/__init__.py
|
touch /api/langgraph_api/__init__.py /api/langgraph_runtime/__init__.py /api/langgraph_license/__init__.py
|
||||||
RUN PYTHONDONTWRITEBYTECODE=1 {install_cmd} --no-cache-dir --no-deps -e /api
|
RUN PYTHONDONTWRITEBYTECODE=1 """
|
||||||
|
+ install_cmd
|
||||||
|
+ """ --no-cache-dir --no-deps -e /api
|
||||||
# -- End of ensuring user deps didn't inadvertently overwrite langgraph-api --
|
# -- End of ensuring user deps didn't inadvertently overwrite langgraph-api --
|
||||||
# -- Removing build deps from the final image ~<:===~~~ --"""
|
# -- Removing build deps from the final image ~<:===~~~ --"""
|
||||||
]
|
)
|
||||||
if to_uninstall:
|
if to_uninstall:
|
||||||
for pack in to_uninstall:
|
for pack in to_uninstall:
|
||||||
if pack not in _BUILD_TOOLS:
|
if pack not in _BUILD_TOOLS:
|
||||||
|
|||||||
@@ -1330,6 +1330,8 @@ def test_config_to_docker_pip_installer():
|
|||||||
PATH_TO_CONFIG, config_auto, base_image="langchain/langgraph-api:0.2.47"
|
PATH_TO_CONFIG, config_auto, base_image="langchain/langgraph-api:0.2.47"
|
||||||
)
|
)
|
||||||
assert "uv pip install --system " in docker_auto
|
assert "uv pip install --system " in docker_auto
|
||||||
|
assert "RUN uv pip check --system" in docker_auto
|
||||||
|
assert "python -m pip check" not in docker_auto
|
||||||
assert "rm /usr/bin/uv /usr/bin/uvx" in docker_auto
|
assert "rm /usr/bin/uv /usr/bin/uvx" in docker_auto
|
||||||
|
|
||||||
# Test explicit pip setting
|
# Test explicit pip setting
|
||||||
@@ -1338,6 +1340,8 @@ def test_config_to_docker_pip_installer():
|
|||||||
PATH_TO_CONFIG, config_pip, base_image="langchain/langgraph-api:0.2.47"
|
PATH_TO_CONFIG, config_pip, base_image="langchain/langgraph-api:0.2.47"
|
||||||
)
|
)
|
||||||
assert "uv pip install --system " not in docker_pip
|
assert "uv pip install --system " not in docker_pip
|
||||||
|
assert "RUN uv pip check --system" not in docker_pip
|
||||||
|
assert "RUN python -m pip check" in docker_pip
|
||||||
assert "pip install" in docker_pip
|
assert "pip install" in docker_pip
|
||||||
assert "rm /usr/bin/uv" not in docker_pip
|
assert "rm /usr/bin/uv" not in docker_pip
|
||||||
|
|
||||||
@@ -1347,6 +1351,8 @@ def test_config_to_docker_pip_installer():
|
|||||||
PATH_TO_CONFIG, config_uv, base_image="langchain/langgraph-api:0.2.47"
|
PATH_TO_CONFIG, config_uv, base_image="langchain/langgraph-api:0.2.47"
|
||||||
)
|
)
|
||||||
assert "uv pip install --system " in docker_uv
|
assert "uv pip install --system " in docker_uv
|
||||||
|
assert "RUN uv pip check --system" in docker_uv
|
||||||
|
assert "python -m pip check" not in docker_uv
|
||||||
assert "rm /usr/bin/uv /usr/bin/uvx" in docker_uv
|
assert "rm /usr/bin/uv /usr/bin/uvx" in docker_uv
|
||||||
|
|
||||||
# Test auto behavior with older image (should use pip)
|
# Test auto behavior with older image (should use pip)
|
||||||
@@ -1357,6 +1363,8 @@ def test_config_to_docker_pip_installer():
|
|||||||
PATH_TO_CONFIG, config_auto_old, base_image="langchain/langgraph-api:0.2.46"
|
PATH_TO_CONFIG, config_auto_old, base_image="langchain/langgraph-api:0.2.46"
|
||||||
)
|
)
|
||||||
assert "uv pip install --system " not in docker_auto_old
|
assert "uv pip install --system " not in docker_auto_old
|
||||||
|
assert "RUN uv pip check --system" not in docker_auto_old
|
||||||
|
assert "RUN python -m pip check" in docker_auto_old
|
||||||
assert "pip install" in docker_auto_old
|
assert "pip install" in docker_auto_old
|
||||||
assert "rm /usr/bin/uv" not in docker_auto_old
|
assert "rm /usr/bin/uv" not in docker_auto_old
|
||||||
|
|
||||||
@@ -1366,6 +1374,32 @@ def test_config_to_docker_pip_installer():
|
|||||||
PATH_TO_CONFIG, config_default, base_image="langchain/langgraph-api:0.2.47"
|
PATH_TO_CONFIG, config_default, base_image="langchain/langgraph-api:0.2.47"
|
||||||
)
|
)
|
||||||
assert "uv pip install --system " in docker_default
|
assert "uv pip install --system " in docker_default
|
||||||
|
assert "RUN uv pip check --system" in docker_default
|
||||||
|
assert "python -m pip check" not in docker_default
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_pip_cleanup_lines_selects_check_command_by_installer():
|
||||||
|
cleanup_uv = _get_pip_cleanup_lines(
|
||||||
|
install_cmd="uv pip install --system",
|
||||||
|
to_uninstall=None,
|
||||||
|
pip_installer="uv",
|
||||||
|
)
|
||||||
|
assert "RUN uv pip check --system" in cleanup_uv
|
||||||
|
assert "python -m pip check" not in cleanup_uv
|
||||||
|
assert cleanup_uv.index("RUN uv pip check --system") < cleanup_uv.index(
|
||||||
|
"RUN mkdir -p /api/langgraph_api"
|
||||||
|
)
|
||||||
|
|
||||||
|
cleanup_pip = _get_pip_cleanup_lines(
|
||||||
|
install_cmd="pip install",
|
||||||
|
to_uninstall=None,
|
||||||
|
pip_installer="pip",
|
||||||
|
)
|
||||||
|
assert "RUN python -m pip check" in cleanup_pip
|
||||||
|
assert "uv pip check --system" not in cleanup_pip
|
||||||
|
assert cleanup_pip.index("RUN python -m pip check") < cleanup_pip.index(
|
||||||
|
"RUN mkdir -p /api/langgraph_api"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_config_to_docker_uv_lock():
|
def test_config_to_docker_uv_lock():
|
||||||
@@ -2490,7 +2524,7 @@ def test_config_to_compose_simple_config():
|
|||||||
def test_config_to_compose_env_vars():
|
def test_config_to_compose_env_vars():
|
||||||
graphs = {"agent": "./agent.py:graph"}
|
graphs = {"agent": "./agent.py:graph"}
|
||||||
expected_compose_stdin = f""" OPENAI_API_KEY: "key"
|
expected_compose_stdin = f""" OPENAI_API_KEY: "key"
|
||||||
|
|
||||||
pull_policy: build
|
pull_policy: build
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
@@ -2573,7 +2607,7 @@ def test_config_to_compose_env_file():
|
|||||||
def test_config_to_compose_watch():
|
def test_config_to_compose_watch():
|
||||||
graphs = {"agent": "./agent.py:graph"}
|
graphs = {"agent": "./agent.py:graph"}
|
||||||
expected_compose_stdin = f"""\
|
expected_compose_stdin = f"""\
|
||||||
|
|
||||||
pull_policy: build
|
pull_policy: build
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
@@ -2599,7 +2633,7 @@ def test_config_to_compose_watch():
|
|||||||
ENV LANGSERVE_GRAPHS='{{"agent": "/deps/outer-unit_tests/unit_tests/agent.py:graph"}}'
|
ENV LANGSERVE_GRAPHS='{{"agent": "/deps/outer-unit_tests/unit_tests/agent.py:graph"}}'
|
||||||
{textwrap.indent(textwrap.dedent(FORMATTED_CLEANUP_LINES), " ")}
|
{textwrap.indent(textwrap.dedent(FORMATTED_CLEANUP_LINES), " ")}
|
||||||
WORKDIR /deps/outer-unit_tests/unit_tests
|
WORKDIR /deps/outer-unit_tests/unit_tests
|
||||||
|
|
||||||
develop:
|
develop:
|
||||||
watch:
|
watch:
|
||||||
- path: test_config.json
|
- path: test_config.json
|
||||||
@@ -2646,7 +2680,7 @@ def test_config_to_compose_end_to_end():
|
|||||||
ENV LANGSERVE_GRAPHS='{{"agent": "/deps/outer-unit_tests/unit_tests/agent.py:graph"}}'
|
ENV LANGSERVE_GRAPHS='{{"agent": "/deps/outer-unit_tests/unit_tests/agent.py:graph"}}'
|
||||||
{textwrap.indent(textwrap.dedent(FORMATTED_CLEANUP_LINES), " ")}
|
{textwrap.indent(textwrap.dedent(FORMATTED_CLEANUP_LINES), " ")}
|
||||||
WORKDIR /deps/outer-unit_tests/unit_tests
|
WORKDIR /deps/outer-unit_tests/unit_tests
|
||||||
|
|
||||||
develop:
|
develop:
|
||||||
watch:
|
watch:
|
||||||
- path: test_config.json
|
- path: test_config.json
|
||||||
|
|||||||
Reference in New Issue
Block a user