langchain-ai / langgraph-studio

Desktop app for prototyping and debugging LangGraph applications locally.
https://studio.langchain.com
1.88k stars 121 forks source link

local postgres #120

Open magaton opened 1 month ago

magaton commented 1 month ago

I see postgres is started in docker. How can I disable that and use my local Postgres, running as Postgres.app?

Anyway, with postgres started in Docker (regular setup) I am getting the following exception: ModuleNotFoundError: No module named 'sqlmodel'

I have sqlmodel declared as dependency in pyproject.toml. I am running the same langgraph from command line without a problem,

Any idea? Thanks

Here is the stacktrace:

Running "docker pull langchain/langgraph-api:3.11"
Running "docker image prune -f --filter label=com.docker.compose.project=poc-4377c3b8ea1eead8da33ad2db93d0792a5dc14acd0c2646133abca46c7cb0e54"
Running "docker image prune -f --filter label=com.docker.compose.project=poc-4377c3b8ea1eead8da33ad2db93d0792a5dc14acd0c2646133abca46c7cb0e54"
3.11: Pulling from langchain/langgraph-api
Digest: sha256:3eaf5fd29845e57481ab17083045021296bf11fed0fa7aecc229bf6efd7f16e2
Status: Image is up to date for langchain/langgraph-api:3.11
docker.io/langchain/langgraph-api:3.11
Total reclaimed space: 0B
Running "docker compose --project-directory /Users/magaton/Projects/guts/poc/poc --project-name poc-4377c3b8ea1eead8da33ad2db93d0792a5dc14acd0c2646133abca46c7cb0e54 -f - up --remove-orphans --watch"
Total reclaimed space: 0B
time="2024-09-17T19:43:46+02:00" level=warning msg="The \"DB_PASSWORDd\" variable is not set. Defaulting to a blank string."
time="2024-09-17T19:43:46+02:00" level=warning msg="The \"DB_PASSWORDd\" variable is not set. Defaulting to a blank string."
time="2024-09-17T19:43:46+02:00" level=warning msg="The \"DB_PASSWORDd\" variable is not set. Defaulting to a blank string."
time="2024-09-17T19:43:46+02:00" level=warning msg="The \"DB_PASSWORDd\" variable is not set. Defaulting to a blank string."
time="2024-09-17T19:43:46+02:00" level=warning msg="The \"DB_PASSWORDd\" variable is not set. Defaulting to a blank string."
#0 building with "desktop-linux" instance using docker driver

#1 [langgraph-api internal] load build definition from Dockerfile
#1 transferring dockerfile: 787B done
#1 WARN: JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals (line 14)
#1 DONE 0.0s

#2 [langgraph-api internal] load metadata for docker.io/langchain/langgraph-api:3.11
#2 DONE 0.0s

#3 [langgraph-api internal] load .dockerignore
#3 transferring context: 2B done
#3 DONE 0.0s

#4 [langgraph-api stage-0 1/5] FROM docker.io/langchain/langgraph-api:3.11
#4 DONE 0.0s

#5 [langgraph-api internal] load build context
#5 transferring context: 5.62kB 0.0s done
#5 DONE 0.0s

#6 [langgraph-api stage-0 4/5] RUN --mount=type=cache,target=/root/.cache/pip PYTHONDONTWRITEBYTECODE=1 pip install -c /api/constraints.txt -e /deps/*
#6 CACHED

#7 [langgraph-api stage-0 2/5] ADD . /Users/magaton/Projects/guts/poc/poc
#7 CACHED

#8 [langgraph-api stage-0 3/5] RUN set -ex &&     for line in '[project]'                 'name = "poc"'                 'version = "0.1"'                 '[tool.setuptools.package-data]'                 '"*" = ["**/*"]'; do         echo "$line" >> /deps/__outer_poc/pyproject.toml;     done
#8 CACHED

#9 [langgraph-api stage-0 5/5] WORKDIR /Users/magaton/Projects/guts/poc/poc
#9 CACHED

#10 [langgraph-api] exporting to image
#10 exporting layers done
#10 writing image sha256:88a81afae13766f6748fb4c47b3edbd584344bffd08d28523ce89d97e952c8f2 done
#10 naming to docker.io/library/poc-4377c3b8ea1eead8da33ad2db93d0792a5dc14acd0c2646133abca46c7cb0e54-langgraph-api done
#10 DONE 0.0s

#11 [langgraph-api] resolving provenance for metadata file
#11 DONE 0.0s
 Container poc-4377c3b8ea1eead8da33ad2db93d0792a5dc14acd0c2646133abca46c7cb0e54-langgraph-redis-1  Running
 Container poc-4377c3b8ea1eead8da33ad2db93d0792a5dc14acd0c2646133abca46c7cb0e54-langgraph-postgres-1  Running
 Container poc-4377c3b8ea1eead8da33ad2db93d0792a5dc14acd0c2646133abca46c7cb0e54-langgraph-api-1  Recreate
langgraph-api-1       | info | Stopping reloader process [1]

langgraph-api-1 exited with code 0

langgraph-api-1 has been recreated
 Container poc-4377c3b8ea1eead8da33ad2db93d0792a5dc14acd0c2646133abca46c7cb0e54-langgraph-api-1  Recreated
        ⦿ Watch enabled
Attaching to langgraph-api-1, langgraph-postgres-1, langgraph-redis-1
langgraph-api-1       | info | Will watch for changes in these directories: ['/Users/magaton/Projects/guts/poc/poc']
langgraph-api-1       | info | Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
langgraph-api-1       | info | Started reloader process [1] using StatReload
langgraph-api-1       | info | Will watch for changes in these directories: ['/Users/magaton/Projects/guts/poc/poc']
langgraph-api-1       | info | Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
langgraph-api-1       | info | Started reloader process [1] using StatReload
langgraph-api-1       | info | Started server process [15]
langgraph-api-1       | info | Waiting for application startup.
langgraph-api-1       | warning | No license key found, running in test mode with LangSmith API key. For production use, set LANGGRAPH_CLOUD_LICENSE_KEY in environment.
langgraph-api-1       | info | Started server process [15]
langgraph-api-1       | info | Waiting for application startup.
langgraph-api-1       | warning | No license key found, running in test mode with LangSmith API key. For production use, set LANGGRAPH_CLOUD_LICENSE_KEY in environment.
langgraph-api-1       | info | HTTP Request: GET https://api.smith.langchain.com/auth?langgraph-api=true "HTTP/1.1 200 OK"
langgraph-api-1       | info | HTTP Request: GET https://api.smith.langchain.com/auth?langgraph-api=true "HTTP/1.1 200 OK"
langgraph-api-1       | error | Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 693, in lifespan
    async with self.lifespan_context(app) as maybe_state:
  File "/usr/local/lib/python3.11/contextlib.py", line 210, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/api/langgraph_api/lifespan.py", line 23, in lifespan
  File "/api/langgraph_api/shared/graph.py", line 172, in collect_graphs_from_env
  File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/config.py", line 590, in run_in_executor
    return await asyncio.get_running_loop().run_in_executor(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/config.py", line 581, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/api/langgraph_api/shared/graph.py", line 203, in _graph_from_spec
  File "/api/langgraph_api/shared/graph.py", line 200, in _graph_from_spec
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/magaton/Projects/guts/poc/poc/pipeline/simple_retrieve.py", line 10, in <module>
    from poc.metadata_store import MetadataStore, get_metadata_store
  File "/Users/magaton/Projects/guts/poc/poc/metadata_store.py", line 1, in <module>
    from sqlmodel import Field, SQLModel, create_engine, Session, select, Relationship
ModuleNotFoundError: No module named 'sqlmodel'
Could not import python module for graph: GraphSpec(id='simple_retrieve', path='/Users/magaton/Projects/guts/poc/poc/pipeline/simple_retrieve.py', module=None, variable='graph')

langgraph-api-1       | error | Application startup failed. Exiting.
langgraph-api-1       | error | Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 693, in lifespan
    async with self.lifespan_context(app) as maybe_state:
  File "/usr/local/lib/python3.11/contextlib.py", line 210, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/api/langgraph_api/lifespan.py", line 23, in lifespan
  File "/api/langgraph_api/shared/graph.py", line 172, in collect_graphs_from_env
  File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/config.py", line 590, in run_in_executor
    return await asyncio.get_running_loop().run_in_executor(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/config.py", line 581, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/api/langgraph_api/shared/graph.py", line 203, in _graph_from_spec
  File "/api/langgraph_api/shared/graph.py", line 200, in _graph_from_spec
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/magaton/Projects/guts/poc/poc/pipeline/simple_retrieve.py", line 10, in <module>
    from poc.metadata_store import MetadataStore, get_metadata_store
  File "/Users/magaton/Projects/guts/poc/poc/metadata_store.py", line 1, in <module>
    from sqlmodel import Field, SQLModel, create_engine, Session, select, Relationship
ModuleNotFoundError: No module named 'sqlmodel'
Could not import python module for graph: GraphSpec(id='simple_retrieve', path='/Users/magaton/Projects/guts/poc/poc/pipeline/simple_retrieve.py', module=None, variable='graph')

langgraph-api-1       | error | Application startup failed. Exiting.
langgraph-postgres-1  | 2024-09-17 17:44:00.069 UTC [27] LOG:  checkpoint starting: time
langgraph-postgres-1  | 2024-09-17 17:44:00.084 UTC [27] LOG:  checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.005 s, sync=0.002 s, total=0.015 s; sync files=2, longest=0.001 s, average=0.001 s; distance=0 kB, estimate=0 kB; lsn=0/16A0790, redo lsn=0/16A0758
langgraph-postgres-1  | 2024-09-17 17:44:00.069 UTC [27] LOG:  checkpoint starting: time
langgraph-postgres-1  | 2024-09-17 17:44:00.084 UTC [27] LOG:  checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.005 s, sync=0.002 s, total=0.015 s; sync files=2, longest=0.001 s, average=0.001 s; distance=0 kB, estimate=0 kB; lsn=0/16A0790, redo lsn=0/16A0758
magaton commented 1 month ago

python 3.11, Mac Sonoma, intel chip.

Other relevant dependencies:

python = ">=3.11,<3.12" uvicorn = "^0.23.2" pydantic = "^2.8.2" fastembed = "^0.3.1" langchain-core = "^0.2" langchain-community = "^0.2" langchain-openai = "^0.1.23" langchain-postgres = "^0.0.9" langchain-ollama = "^0.1.3" langchain-anthropic = "^0.1.23" langgraph = "^0.2.22" langgraph-checkpoint-postgres = "^1.0.6" psycopg = ">=3.1.19, <3.2.0" psycopg-binary = ">=3.1.19, <3.2.0"

magaton commented 1 month ago

Anyone?

dqbd commented 1 month ago

Hello @magaton! Will take a look

magaton commented 1 month ago

Any thoughts?

magaton commented 1 month ago

Hi, @dqbd have you had a chance to look at this issue? I would like to know whether it is a bug or a feature (desired behaviour) so I can decide whether to use langgraph studio, or not. Thank you!