From c2b2e9a2865be456bdb0df441b15495120abeaac Mon Sep 17 00:00:00 2001 From: ogabrielluiz Date: Thu, 6 Jun 2024 19:45:18 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20(build=5Fand=5Fpush.Dockerfile):?= =?UTF-8?q?=20Add=20support=20for=20building=20and=20pushing=20frontend=20?= =?UTF-8?q?code=20in=20a=20separate=20node=20builder=20stage=20to=20improv?= =?UTF-8?q?e=20build=20process=20efficiency=20=F0=9F=94=A7=20(build=5Fand?= =?UTF-8?q?=5Fpush.Dockerfile):=20Update=20pip=20install=20command=20to=20?= =?UTF-8?q?force=20reinstall=20dependencies=20to=20ensure=20consistency=20?= =?UTF-8?q?=F0=9F=90=9B=20(code=5Fparser.py):=20Change=20logger.exception?= =?UTF-8?q?=20to=20logger.debug=20to=20prevent=20logging=20full=20exceptio?= =?UTF-8?q?n=20stack=20trace=20=F0=9F=90=9B=20(directory=5Freader.py):=20C?= =?UTF-8?q?hange=20logger.error=20to=20logger.debug=20and=20log=20error=20?= =?UTF-8?q?message=20separately=20to=20improve=20error=20handling=20and=20?= =?UTF-8?q?logging=20clarity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/build_and_push.Dockerfile | 12 ++++++++++-- .../base/langflow/custom/code_parser/code_parser.py | 2 +- .../custom/directory_reader/directory_reader.py | 6 +++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/docker/build_and_push.Dockerfile b/docker/build_and_push.Dockerfile index bd177e9bc..29f9294a6 100644 --- a/docker/build_and_push.Dockerfile +++ b/docker/build_and_push.Dockerfile @@ -1,6 +1,14 @@ # syntax=docker/dockerfile:1 # Keep this syntax directive! It's used to enable Docker BuildKit +FROM node:20-bookworm-slim as builder-node +WORKDIR /app +COPY src/frontend/package.json src/frontend/package-lock.json ./ +RUN npm install +COPY src/frontend/ ./ +RUN npm run build + + ################################ # BUILDER-BASE # Used to build deps + create our virtual environment @@ -48,10 +56,10 @@ COPY pyproject.toml poetry.lock README.md ./ COPY src/ ./src COPY scripts/ ./scripts RUN python -m pip install requests --user && cd ./scripts && python update_dependencies.py +COPY --from=builder-node /app/build ./src/backend/base/langflow/frontend RUN $POETRY_HOME/bin/poetry lock --no-update \ - && $POETRY_HOME/bin/poetry install --no-interaction --no-ansi -E deploy \ && $POETRY_HOME/bin/poetry build -f wheel \ - && $POETRY_HOME/bin/poetry run pip install dist/*.whl + && $POETRY_HOME/bin/poetry run pip install dist/*.whl --force-reinstall ################################ # RUNTIME diff --git a/src/backend/base/langflow/custom/code_parser/code_parser.py b/src/backend/base/langflow/custom/code_parser/code_parser.py index 17fe12896..705e779f4 100644 --- a/src/backend/base/langflow/custom/code_parser/code_parser.py +++ b/src/backend/base/langflow/custom/code_parser/code_parser.py @@ -297,7 +297,7 @@ class CodeParser: bases = self.execute_and_inspect_classes(self.code) except Exception as e: # If the code cannot be executed, return an empty list - logger.exception(e) + logger.debug(e) bases = [] raise e return bases diff --git a/src/backend/base/langflow/custom/directory_reader/directory_reader.py b/src/backend/base/langflow/custom/directory_reader/directory_reader.py index b9f55f21f..52a310314 100644 --- a/src/backend/base/langflow/custom/directory_reader/directory_reader.py +++ b/src/backend/base/langflow/custom/directory_reader/directory_reader.py @@ -78,7 +78,8 @@ class DirectoryReader: component_tuple = (*build_component(component), component) components.append(component_tuple) except Exception as e: - logger.error(f"Error while loading component { component['name']}: {e}") + logger.debug(f"Error while loading component { component['name']}") + logger.debug(e) continue items.append({"name": menu["name"], "path": menu["path"], "components": components}) filtered = [menu for menu in items if menu["components"]] @@ -266,8 +267,7 @@ class DirectoryReader: if validation_result: try: output_types = self.get_output_types_from_code(result_content) - except Exception as exc: - logger.exception(f"Error while getting output types from code: {str(exc)}") + except Exception: output_types = [component_name_camelcase] else: output_types = [component_name_camelcase]