langchain-ai / langgraph

Build resilient language agents as graphs.
https://langchain-ai.github.io/langgraph/
MIT License
6.51k stars 1.04k forks source link

No such file error on `langgraph up` within devcontainer (`.../app_dir/-`) #2222

Open TimChild opened 1 week ago

TimChild commented 1 week ago

Checked other resources

Example Code

langgraph.json

{
  "dependencies": [
    "."
  ],
  "graphs": {
    "example_graph": "./example_graph.py:example_graph"

  },
  "env": "./.env",
  "dockerfile_lines": [
  ],
  "python_version": "3.12"
}

example_graph.py

from typing import Annotated, Any, NotRequired, Sequence, TypedDict

from langchain_core.messages import AIMessage, BaseMessage
from langgraph.graph import StateGraph, add_messages
from langgraph.graph.graph import CompiledGraph

class AgentState(TypedDict):
    messages: Annotated[Sequence[BaseMessage], add_messages]

def node1(state: AgentState) -> AgentState:
    return {"messages": [AIMessage("Hello 1")]}

async def node2(state: AgentState) -> AgentState:
    return {"messages": [AIMessage("Hello 2")]}

def make_graph() -> CompiledGraph:
    state_graph = StateGraph(state_schema=AgentState)
    state_graph.add_node("node1", node1)
    state_graph.add_node("node2", node2)

    state_graph.set_entry_point("node1")
    state_graph.add_edge("node1", "node2")
    state_graph.set_finish_point("node2")

    return state_graph.compile()

example_graph = make_graph()

devcontainer.json

{
    "name": "file_not_found_issue",
    "image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye",
    "features": {
        "ghcr.io/devcontainers/features/docker-in-docker:2": {
            "moby": true,
            "azureDnsAutoDetection": true,
            "installDockerBuildx": true,
            "installDockerComposeSwitch": true,
            "version": "27.0"
        }
    },
    "postCreateCommand": "pip install langgraph-cli && langgraph up"
}

Error Message and Stack Trace (if applicable)

`langgraph up`

Starting LangGraph API server...
For local dev, requires env var LANGSMITH_API_KEY with access to LangGraph Cloud closed beta.
For production use, requires a license key in env var LANGGRAPH_CLOUD_LICENSE_KEY.
\ Building...open /workspaces/temp_no_such_file_issue/-: no such file or directory

Description

I don't know where the issue lies between langgraph, docker, devcontainer... I don't see issues raised in the docker or devcontainer repos related to this yet, which makes me think it could be some strange interaction with langgraph. Feel free to close if this is not relevant enough. Just wanted to post in case others have noticed the same issue.

This issue just started happening today, and I cannot understand where it comes from.

Using the extremely minimal example of a langgraph app provided (also with a .env file that contains a valid api key), I am able to run langgraph up no problem from wsl2. But trying to do the same from within a devcontainer, I keeep getting the error, no such file or directory with directory name ending with a -.

Things I have tried:

So, it's not due to a very new release of langgraph, langgraph-cli, or docker engines.

Also, my external (wsl2) docker version is 27.2

I first noticed this issue in my CI workflow today. Re-running a successful one from yesterday still works (but I think my devcontainer build is cached). I don't usually use the devcontainer locally, but once my CI failed, I tried locally and it failed the same way. However, even going back to the same git commit from yesterday does not work locally.

Mostly wanted to post this in case anyone else comes across the same issue.

Also, deploying to langgraph-cloud still works.

System Info

pip freeze output

click==8.1.7
gitdb==4.0.11
GitPython==3.1.41
langgraph-cli==0.1.52
setuptools==69.0.3
smmap==5.0.1

docker version output (from in the devcontainer)

Server:
 Engine:
  Version:          26.1.5-1
  API version:      1.45 (minimum version 1.24)
  Go version:       go1.21.12
  Git commit:       411e817ddf710ff8e08fa193da80cb78af708191
  Built:            Tue Jul 23 19:36:28 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.36-1
  GitCommit:        88c3d9bc5b5a193f40b7c14fa996d23532d6f956
 runc:
  Version:          1.1.15-1
  GitCommit:        bc20cb4497af9af01bea4a8044f1678ffca2745c
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker version (from wsl2)

 Server: Docker Desktop  ()
 Engine:
  Version:          27.2.0
  API version:      1.47 (minimum version 1.24)
  Go version:       go1.21.13
  Git commit:       3ab5c7d
  Built:            Tue Aug 27 14:15:15 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.20
  GitCommit:        8fc6bcff51318944179630522a095cc9dbf9f353
 runc:
  Version:          1.1.13
  GitCommit:        v1.1.13-0-g58aa920
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
dqbd commented 1 week ago

Hello @TimChild!

Would it be possible to run the langgraph up command with --verbose CLI arg?

TimChild commented 1 week ago

@dqbd, Full output from running with verbose:

langgraph up --verbose
Starting LangGraph API server...
For local dev, requires env var LANGSMITH_API_KEY with access to LangGraph Cloud closed beta.
For production use, requires a license key in env var LANGGRAPH_CLOUD_LICENSE_KEY.
| Pulling...+ docker pull langchain/langgraph-api:3.12
/ Pulling...3.12: Pulling from langchain/langgraph-api
Digest: sha256:c3f28a01d9173737839654b5bacd9c862cc3c1641c77bae7024f7f60783b1729
Status: Image is up to date for langchain/langgraph-api:3.12
docker.io/langchain/langgraph-api:3.12
+ docker compose --project-directory /workspaces/temp_no_such_file_issue -f - up --remove-orphans --abort-on-container-exit <
volumes:
    langgraph-data:
        driver: local
services:
    langgraph-redis:
        image: redis:6
        healthcheck:
            test: redis-cli ping
            interval: 5s
            timeout: 1s
            retries: 5
    langgraph-postgres:
        image: postgres:16
        ports:
            - "5433:5432"
        environment:
            POSTGRES_DB: postgres
            POSTGRES_USER: postgres
            POSTGRES_PASSWORD: postgres
        volumes:
            - langgraph-data:/var/lib/postgresql/data
        healthcheck:
            test: pg_isready -U postgres
            start_period: 10s
            timeout: 1s
            retries: 5
            interval: 60s
            start_interval: 1s
    langgraph-api:
        ports:
            - "8123:8000"
        depends_on:
            langgraph-redis:
                condition: service_healthy
            langgraph-postgres:
                condition: service_healthy
        environment:
            REDIS_URI: redis://langgraph-redis:6379
            POSTGRES_URI: postgres://postgres:postgres@langgraph-postgres:5432/postgres?sslmode=disable
        healthcheck:
            test: python /api/healthcheck.py
            interval: 60s
            start_interval: 1s
            start_period: 10s
        env_file: ./.env
        pull_policy: build
        build:
            context: .
            dockerfile_inline: |
                FROM langchain/langgraph-api:3.12
                ADD . /deps/__outer_temp_no_such_file_issue/src
                RUN set -ex && \
                    for line in '[project]' \
                                'name = "temp_no_such_file_issue"' \
                                'version = "0.1"' \
                                '[tool.setuptools.package-data]' \
                                '"*" = ["**/*"]'; do \
                        echo "$line" >> /deps/__outer_temp_no_such_file_issue/pyproject.toml; \
                    done
                RUN PYTHONDONTWRITEBYTECODE=1 pip install --no-cache-dir -c /api/constraints.txt -e /deps/*
                ENV LANGSERVE_GRAPHS='{"example_graph": "/deps/__outer_temp_no_such_file_issue/src/example_graph.py:example_graph"}'
                WORKDIR /deps/__outer_temp_no_such_file_issue/src

- Building...open /workspaces/temp_no_such_file_issue/-: no such file or directory
open /workspaces/temp_no_such_file_issue/-: no such file or directory

Not too enlightening to me unfortunately.