Testing alpha release with docker compose: required keyword-only argument: 'recursive_guard'
flefevre opened this issue · comments
Describe the bug
The application do not start due to
langflow | field.type_ = evaluate_forwardref(field.type_, globalns, localns or None)
langflow | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
langflow | File "/app/.venv/lib/python3.12/site-packages/pydantic/v1/typing.py", line 66, in evaluate_forwardref
langflow | return cast(Any, type_)._evaluate(globalns, localns, set())
langflow | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
langflow | TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'
Version
- version alpha and 1.0.0a51 and1.0.0a52
docker compose log
docker compose up --build
[+] Building 0.8s (5/5) FINISHED docker:default
=> [langflow internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 652B 0.0s
=> [langflow internal] load metadata for docker.io/langflowai/langflow:1.0-alpha 0.8s
=> [langflow internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> CACHED [langflow 1/1] FROM docker.io/langflowai/langflow:1.0-alpha@sha256:e6863d4bc7c06de8f75f6b25381eb18009e31b8aec49ee745b424b7c1adaecf4 0.0s
=> [langflow] exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:9538bd3d9f2fadd7a5797e530ace230f38a0ad4adf687f5a9f1f28b15d2bf9c2 0.0s
=> => naming to docker.io/library/langflow-langflow 0.0s
[+] Running 1/1
✔ Container langflow Recreated 0.0s
Attaching to langflow
langflow | Traceback (most recent call last):
langflow | File "<frozen runpy>", line 198, in _run_module_as_main
langflow | File "<frozen runpy>", line 88, in _run_code
langflow | File "/app/.venv/lib/python3.12/site-packages/langflow/__main__.py", line 22, in <module>
langflow | from langflow.main import setup_app
langflow | File "/app/.venv/lib/python3.12/site-packages/langflow/main.py", line 16, in <module>
langflow | from langflow.api import router
langflow | File "/app/.venv/lib/python3.12/site-packages/langflow/api/__init__.py", line 1, in <module>
langflow | from langflow.api.router import router
langflow | File "/app/.venv/lib/python3.12/site-packages/langflow/api/router.py", line 4, in <module>
langflow | from langflow.api.v1 import (
langflow | File "/app/.venv/lib/python3.12/site-packages/langflow/api/v1/__init__.py", line 1, in <module>
langflow | from langflow.api.v1.api_key import router as api_key_router
langflow | File "/app/.venv/lib/python3.12/site-packages/langflow/api/v1/api_key.py", line 7, in <module>
langflow | from langflow.api.v1.schemas import ApiKeyCreateRequest, ApiKeysResponse
langflow | File "/app/.venv/lib/python3.12/site-packages/langflow/api/v1/schemas.py", line 9, in <module>
langflow | from langflow.graph.schema import RunOutputs
langflow | File "/app/.venv/lib/python3.12/site-packages/langflow/graph/__init__.py", line 1, in <module>
langflow | from langflow.graph.edge.base import Edge
langflow | File "/app/.venv/lib/python3.12/site-packages/langflow/graph/edge/base.py", line 6, in <module>
langflow | from langflow.schema.schema import INPUT_FIELD_NAME
langflow | File "/app/.venv/lib/python3.12/site-packages/langflow/schema/__init__.py", line 2, in <module>
langflow | from .record import Record
langflow | File "/app/.venv/lib/python3.12/site-packages/langflow/schema/record.py", line 5, in <module>
langflow | from langchain_core.documents import Document
langflow | File "/app/.venv/lib/python3.12/site-packages/langchain_core/documents/__init__.py", line 6, in <module>
langflow | from langchain_core.documents.compressor import BaseDocumentCompressor
langflow | File "/app/.venv/lib/python3.12/site-packages/langchain_core/documents/compressor.py", line 6, in <module>
langflow | from langchain_core.callbacks import Callbacks
langflow | File "/app/.venv/lib/python3.12/site-packages/langchain_core/callbacks/__init__.py", line 22, in <module>
langflow | from langchain_core.callbacks.manager import (
langflow | File "/app/.venv/lib/python3.12/site-packages/langchain_core/callbacks/manager.py", line 29, in <module>
langflow | from langsmith.run_helpers import get_run_tree_context
langflow | File "/app/.venv/lib/python3.12/site-packages/langsmith/run_helpers.py", line 40, in <module>
langflow | from langsmith import client as ls_client
langflow | File "/app/.venv/lib/python3.12/site-packages/langsmith/client.py", line 52, in <module>
langflow | from langsmith import env as ls_env
langflow | File "/app/.venv/lib/python3.12/site-packages/langsmith/env/__init__.py", line 3, in <module>
langflow | from langsmith.env._runtime_env import (
langflow | File "/app/.venv/lib/python3.12/site-packages/langsmith/env/_runtime_env.py", line 10, in <module>
langflow | from langsmith.utils import get_docker_compose_command
langflow | File "/app/.venv/lib/python3.12/site-packages/langsmith/utils.py", line 31, in <module>
langflow | from langsmith import schemas as ls_schemas
langflow | File "/app/.venv/lib/python3.12/site-packages/langsmith/schemas.py", line 69, in <module>
langflow | class Example(ExampleBase):
langflow | File "/app/.venv/lib/python3.12/site-packages/pydantic/v1/main.py", line 286, in __new__
langflow | cls.__try_update_forward_refs__()
langflow | File "/app/.venv/lib/python3.12/site-packages/pydantic/v1/main.py", line 807, in __try_update_forward_refs__
langflow | update_model_forward_refs(cls, cls.__fields__.values(), cls.__config__.json_encoders, localns, (NameError,))
langflow | File "/app/.venv/lib/python3.12/site-packages/pydantic/v1/typing.py", line 554, in update_model_forward_refs
langflow | update_field_forward_refs(f, globalns=globalns, localns=localns)
langflow | File "/app/.venv/lib/python3.12/site-packages/pydantic/v1/typing.py", line 520, in update_field_forward_refs
langflow | field.type_ = evaluate_forwardref(field.type_, globalns, localns or None)
langflow | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
langflow | File "/app/.venv/lib/python3.12/site-packages/pydantic/v1/typing.py", line 66, in evaluate_forwardref
langflow | return cast(Any, type_)._evaluate(globalns, localns, set())
langflow | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
langflow | TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'
Docker compose file
services:
langflow:
build:
context: ./
dockerfile: Dockerfile
pull_policy: build
container_name: langflow
restart: unless-stopped
networks:
traefik_network:
#command: python -m langflow run --host 0.0.0.0 --port 7870
environment:
- TZ=Europe/Paris
- LANGFLOW_PORT=${LANGFLOW_PORT}
#https://docs.langflow.org/guidelines/login
- LANGFLOW_SUPERUSER=${LANGFLOW_SUPERUSER}
- LANGFLOW_SUPERUSER_PASSWORD=${LANGFLOW_SUPERUSER_PASSWORD}
- LANGFLOW_NEW_USER_IS_ACTIVE=${LANGFLOW_NEW_USER_IS_ACTIVE}
- LANGFLOW_AUTO_LOGIN=${LANGFLOW_AUTO_LOGIN}
#Database, configuration FAILED https://github.com/logspace-ai/langflow/issues/1432
- DB_USER=${DB_USER}
- DB_PASSWORD=${DB_PASSWORD}
- DB_HOST=${DB_HOST}
- DB_PORT=${DB_PORT}
- DB_NAME=${DB_NAME}
- LANGFLOW_DATABASE_URL=postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}
# This variable defines where the logs, file storage, monitor data and secret keys are stored.
- LANGFLOW_CONFIG_DIR=app/langflow
volumes:
- langflow-data:/app/langflow
volumes:
langflow-data:
Dockerfile
FROM langflowai/langflow:1.0-alpha
CMD ["python", "-m", "langflow", "run", "--host", "0.0.0.0", "--port", "7860"]
To resolve the issue with your application failing to start using Docker Compose with the alpha release of Langflow due to a TypeError related to Pydantic v1 for Python 3.12.4+, you need to ensure that the correct version of Pydantic is being used. Pydantic v1 is not compatible with Python 3.12.4+, so you should upgrade to Pydantic v2.
Here is how you can modify your Dockerfile to install Pydantic v2:
- Open the
Dockerfile
file. - Add a line to install Pydantic v2.
For example, your Dockerfile
might look like this:
FROM langflowai/langflow:1.0-alpha
# Install Pydantic v2
RUN pip install pydantic==2.0.0
CMD ["python", "-m", "langflow", "run", "--host", "0.0.0.0", "--port", "7860"]
Make sure to replace 2.0.0
with the latest version of Pydantic v2 if necessary.
After making these changes, rebuild your Docker image and restart your Docker Compose setup:
docker-compose down
docker-compose build
docker-compose up
Additionally, ensure that your pyproject.toml
file specifies a compatible Python version. According to the Langflow pyproject.toml
, the supported Python versions are >=3.10,<3.12
. If you are using Python 3.12.4+, you may need to downgrade to a compatible version:
[tool.poetry.dependencies]
python = ">=3.10,<3.12"
This should resolve the TypeError related to Pydantic v1 for Python 3.12.4+. Note that the pyproject.toml
file for Langflow already specifies Pydantic v2.5.0, so ensure your dependencies are up to date:
[tool.poetry.dependencies]
pydantic = "^2.5.0"
This should help you get past the error and successfully start your application [1][2][3].