Skip to content

Commit

Permalink
Update Dockerfiles, main.py, constants.py, and package versions (#1691)
Browse files Browse the repository at this point in the history
* Update Dockerfiles to include user creation and use --user flag for pip install

* Add JavaScriptMIMETypeMiddleware to main.py

* Update constants.py and run.py files

* Update package versions in poetry.lock and pyproject.toml files

* Refactor Dockerfile to optimize image building process

* Fix import error in main.py

* Update Dockerfiles to use logspace/langflow image
  • Loading branch information
ogabrielluiz authored Apr 12, 2024
1 parent 30203a0 commit 1a02132
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 123 deletions.
6 changes: 4 additions & 2 deletions base.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ RUN --mount=type=cache,target=/root/.cache \

# copy project requirement files here to ensure they will be cached.
WORKDIR $PYSETUP_PATH
# Copy just one file to avoid rebuilding the whole image
COPY poetry.lock pyproject.toml ./
COPY ./src/backend/langflow/main.py ./src/backend/langflow/main.py
COPY ./src/backend/langflow ./src/backend/langflow
COPY ./src/backend/base/pyproject.toml ./src/backend/base/pyproject.toml
# Copy README.md to the build context
COPY README.md .
# install runtime deps - uses $POETRY_VIRTUALENVS_IN_PROJECT internally
Expand All @@ -84,7 +86,7 @@ COPY --from=builder-base $POETRY_HOME $POETRY_HOME
COPY --from=builder-base $PYSETUP_PATH $PYSETUP_PATH

# Copy just one file to avoid rebuilding the whole image
COPY ./src/backend/langflow/__init__.py ./src/backend/langflow/__init__.py
COPY ./src/backend/langflow ./src/backend/langflow
# quicker install as runtime deps are already installed
RUN --mount=type=cache,target=/root/.cache \
poetry install --with=dev --extras deploy
Expand Down
92 changes: 0 additions & 92 deletions deploy/base.Dockerfile

This file was deleted.

11 changes: 1 addition & 10 deletions deploy/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ services:
- traefik.http.routers.${STACK_NAME?Variable not set}-proxy-http.middlewares=${STACK_NAME?Variable not set}-www-redirect,${STACK_NAME?Variable not set}-https-redirect

backend: &backend
image: "ogabrielluiz/langflow:latest"
build:
context: ../
dockerfile: base.Dockerfile
image: "logspace/langflow:latest"
depends_on:
- db
- broker
Expand Down Expand Up @@ -143,9 +140,6 @@ services:
<<: *backend
env_file:
- .env
build:
context: ../
dockerfile: base.Dockerfile
command: celery -A langflow.worker.celery_app worker --loglevel=INFO --concurrency=1 -n lf-worker@%h -P eventlet
healthcheck:
test: "exit 0"
Expand All @@ -158,9 +152,6 @@ services:
- .env
networks:
- default
build:
context: ../
dockerfile: base.Dockerfile
environment:
- FLOWER_PORT=5555

Expand Down
14 changes: 7 additions & 7 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langflow"
version = "1.0.0a19"
version = "1.0.0a20"
description = "A Python package with a built-in web application"
authors = ["Logspace <[email protected]>"]
maintainers = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2024-03-25 09:40:02.743453
"""

from typing import Sequence, Union

import sqlalchemy as sa
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Create Date: 2024-04-11 19:23:10.697335
"""
from calendar import c

from typing import Sequence, Union

import sqlalchemy as sa
Expand Down
1 change: 1 addition & 0 deletions src/backend/base/langflow/base/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- NODE_FORMAT_ATTRIBUTES: A list of attributes used for formatting nodes.
- FIELD_FORMAT_ATTRIBUTES: A list of attributes used for formatting fields.
"""

STREAM_INFO_TEXT = "Stream the response from the model. Streaming works only in Chat."

NODE_FORMAT_ATTRIBUTES = ["beta", "icon", "display_name", "description"]
Expand Down
4 changes: 0 additions & 4 deletions src/backend/base/langflow/interface/run.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
from typing import Dict, Tuple

from loguru import logger

from langflow.graph import Graph


def get_memory_key(langchain_object):
"""
Expand Down
12 changes: 11 additions & 1 deletion src/backend/base/langflow/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from fastapi.staticfiles import StaticFiles
from loguru import logger
from rich import print as rprint
from starlette.middleware.base import BaseHTTPMiddleware

from langflow.api import router
from langflow.initial_setup.setup import create_or_update_starter_projects
Expand All @@ -20,8 +21,16 @@
from langflow.utils.logger import configure


class JavaScriptMIMETypeMiddleware(BaseHTTPMiddleware):
async def dispatch(self, request: Request, call_next):
response = await call_next(request)
if "files/" not in request.url.path and request.url.path.endswith(".js") and response.status_code == 200:
response.headers["Content-Type"] = "text/javascript"
return response


def get_lifespan(fix_migration=False, socketio_server=None):
from langflow.version import __version__
from langflow.version import __version__ # type: ignore

@asynccontextmanager
async def lifespan(app: FastAPI):
Expand Down Expand Up @@ -62,6 +71,7 @@ def create_app():
allow_methods=["*"],
allow_headers=["*"],
)
app.add_middleware(JavaScriptMIMETypeMiddleware)

@app.middleware("http")
async def flatten_query_string_lists(request: Request, call_next):
Expand Down
6 changes: 3 additions & 3 deletions src/backend/base/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/backend/base/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langflow-base"
version = "0.0.31"
version = "0.0.32"
description = "A Python package with a built-in web application"
authors = ["Logspace <[email protected]>"]
maintainers = [
Expand Down
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from langflow.services.database.models.user.model import User, UserCreate
from langflow.services.database.utils import session_getter
from langflow.services.deps import get_db_service
from sqlmodel import Session, SQLModel, create_engine, select
from sqlmodel.pool import StaticPool
from typer.testing import CliRunner

Expand Down

0 comments on commit 1a02132

Please sign in to comment.