Skip to content

Commit

Permalink
Merge branch 'main' into feat-dynamic-model-loading
Browse files Browse the repository at this point in the history
  • Loading branch information
edwinjosechittilappilly authored Oct 31, 2024
2 parents 1bf87b4 + f2af059 commit 74ff94a
Show file tree
Hide file tree
Showing 197 changed files with 4,561 additions and 2,415 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,14 @@ jobs:
ref: ${{ inputs.nightly_tag_main || github.ref }}
persist-credentials: true

- name: "Setup Environment"
uses: ./.github/actions/setup-uv

- name: Get Version from Input
if: ${{ inputs.version != '' }}
id: get-version-input
run: |
# Base version cannot have a version input, since you have to specify a valid main tag to checkout.
# Base version cannot have a version input, since you have to specify a valid main tag to checkout.
if [[ "${{ inputs.release_type }}" == "base" && "${{ inputs.version }}" != '' ]]; then
echo "Cannot specify version for base release."
echo "Build type is 'base' and version is non-empty. Exiting the workflow."
Expand Down Expand Up @@ -150,6 +153,10 @@ jobs:
id: get-version-base
run: |
version=$(uv tree | grep 'langflow-base' | awk '{print $3}' | sed 's/^v//')
if [ -z "$version" ]; then
echo "Failed to extract version from uv tree output"
exit 1
fi
echo version=$version
echo version=$version >> $GITHUB_OUTPUT
- name: Get Version Main
Expand Down Expand Up @@ -196,7 +203,7 @@ jobs:
echo "docker_tags=langflowai/langflow${nightly_suffix}:${{ needs.get-version.outputs.version }},langflowai/langflow${nightly_suffix}:latest" >> $GITHUB_OUTPUT
echo "ghcr_tags=ghcr.io/langflow-ai/langflow${nightly_suffix}:${{ needs.get-version.outputs.version }},ghcr.io/langflow-ai/langflow${nightly_suffix}:latest" >> $GITHUB_OUTPUT
echo "file=./docker/build_and_push.Dockerfile" >> $GITHUB_OUTPUT
else
else
echo "Invalid release type. Exiting the workflow."
exit 1
fi
Expand All @@ -208,7 +215,8 @@ jobs:
- name: Check out the code at a specific ref
uses: actions/checkout@v4
with:
ref: ${{ needs.get-version.outputs.version || github.ref }}
ref: ${{ inputs.nightly_tag_main || github.ref }}
#ref: ${{ needs.get-version.outputs.version && format('v{0}', needs.get-version.outputs.version) || github.ref }}
persist-credentials: true
- name: "Setup Environment"
uses: ./.github/actions/setup-uv
Expand Down Expand Up @@ -284,7 +292,7 @@ jobs:
- name: Check out the code at a specific ref
uses: actions/checkout@v4
with:
ref: ${{ needs.get-version.outputs.version || github.ref }}
ref: ${{ inputs.nightly_tag_main || github.ref }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand Down Expand Up @@ -332,7 +340,7 @@ jobs:
- name: Check out the code at a specific ref
uses: actions/checkout@v4
with:
ref: ${{ needs.get-version.outputs.version || github.ref }}
ref: ${{ inputs.nightly_tag_main || github.ref }}
- name: "Setup Environment"
uses: ./.github/actions/setup-uv

Expand Down
15 changes: 4 additions & 11 deletions .github/workflows/nightly_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
shell: bash -ex -o pipefail {0}
permissions:
# Required to create tag
contents: write
Expand Down Expand Up @@ -69,17 +69,10 @@ jobs:
git config --global user.email "[email protected]"
git config --global user.name "Langflow Bot"
BASE_TAG="${{ steps.generate_base_tag.outputs.base_tag }}"
echo "Updating base project version to $BASE_TAG"
uv run ./scripts/ci/update_pyproject_name.py langflow-base-nightly base
uv run ./scripts/ci/update_pyproject_version.py $BASE_TAG base
# Use the main tag created earlier
MAIN_TAG="${{ steps.generate_main_tag.outputs.main_tag }}"
echo "Updating main project version to $MAIN_TAG"
uv run ./scripts/ci/update_pyproject_version.py $MAIN_TAG main
uv run ./scripts/ci/update_pyproject_name.py langflow-nightly main
uv run ./scripts/ci/update_uv_dependency.py $BASE_TAG
BASE_TAG="${{ steps.generate_base_tag.outputs.base_tag }}"
echo "Updating base project version to $BASE_TAG and updating main project version to $MAIN_TAG"
uv run ./scripts/ci/update_pyproject_combined.py main $MAIN_TAG $BASE_TAG
uv lock
cd src/backend/base && uv lock && cd ../../..
Expand Down
23 changes: 10 additions & 13 deletions .github/workflows/release_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,16 +222,13 @@ jobs:
nightly_tag_main: ${{ inputs.nightly_tag_main }}
secrets: inherit

call_docker_build_main_ep:
name: Call Docker Build Workflow for Langflow with Entrypoint
if: always() && ${{ inputs.build_docker_ep == 'true' }}
needs: [release-nightly-main]
uses: ./.github/workflows/docker-build.yml
with:
release_type: main-ep
nightly_tag_main: ${{ inputs.nightly_tag_main }}
secrets: inherit




# Not currently supported, let's add it later
# call_docker_build_main_ep:
# name: Call Docker Build Workflow for Langflow with Entrypoint
# if: always() && ${{ inputs.build_docker_ep == 'true' }}
# needs: [release-nightly-main]
# uses: ./.github/workflows/docker-build.yml
# with:
# release_type: main-ep
# nightly_tag_main: ${{ inputs.nightly_tag_main }}
# secrets: inherit
1 change: 1 addition & 0 deletions .github/workflows/typescript_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ jobs:
max_attempts: 2
command: |
cd src/frontend
npx playwright test ${{ inputs.tests_folder }} --shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }} --list
npx playwright test ${{ inputs.tests_folder }} --trace on --shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }} --workers 2
- name: Upload blob report to GitHub Actions Artifacts
Expand Down
2 changes: 2 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"type": "debugpy",
"request": "launch",
"module": "uvicorn",
"preLaunchTask": "Install Backend",

"args": [
"--factory",
"langflow.main:create_app",
Expand Down
6 changes: 6 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
"label": "Install",
"type": "shell",
"command": "make install_backend && make install_frontend"
},
// install backend
{
"label": "Install Backend",
"type": "shell",
"command": "make install_backend"
}
]
}
16 changes: 14 additions & 2 deletions docker/build_and_push_base.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/*

# Install the project's dependencies using the lockfile and settings
# We need to mount the root uv.lock and pyproject.toml to build the base with uv because we're still using uv workspaces
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=src/backend/base/README.md,target=src/backend/base/README.md \
--mount=type=bind,source=src/backend/base/uv.lock,target=src/backend/base/uv.lock \
--mount=type=bind,source=src/backend/base/pyproject.toml,target=src/backend/base/pyproject.toml \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=README.md,target=README.md \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
cd src/backend/base && uv sync --frozen --no-install-project --no-dev --no-editable

ADD ./src /app/src
Expand All @@ -48,7 +52,14 @@ RUN npm install \
&& cp -r build /app/src/backend/base/langflow/frontend \
&& rm -rf /tmp/src/frontend

ADD ./src/backend/base /app/src/backend/base
WORKDIR /app/src/backend/base
# again we need these because of workspaces
ADD ./pyproject.toml /app/pyproject.toml
ADD ./uv.lock /app/uv.lock
ADD ./src/backend/base/pyproject.toml /app/src/backend/base/pyproject.toml
ADD ./src/backend/base/uv.lock /app/src/backend/base/uv.lock
ADD ./src/backend/base/README.md /app/src/backend/base/README.md
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev --no-editable

Expand All @@ -59,10 +70,11 @@ RUN --mount=type=cache,target=/root/.cache/uv \
FROM python:3.12.3-slim AS runtime

RUN useradd user -u 1000 -g 0 --no-create-home --home-dir /app/data
COPY --from=builder --chown=1000 /app/src/backend/base/.venv /app/src/backend/base/.venv
# and we use the venv at the root because workspaces
COPY --from=builder --chown=1000 /app/.venv /app/.venv

# Place executables in the environment at the front of the path
ENV PATH="/app/src/backend/base/.venv/bin:$PATH"
ENV PATH="/app/.venv/bin:$PATH"

LABEL org.opencontainers.image.title=langflow
LABEL org.opencontainers.image.authors=['Langflow']
Expand Down
52 changes: 52 additions & 0 deletions scripts/ci/update_pyproject_combined.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env python
# scripts/ci/update_pyproject_combined.py
import sys
from pathlib import Path

from update_pyproject_name import update_pyproject_name
from update_pyproject_name import update_uv_dep as update_name_uv_dep
from update_pyproject_version import update_pyproject_version
from update_uv_dependency import update_uv_dep as update_version_uv_dep

# Add the current directory to the path so we can import the other scripts
current_dir = Path(__file__).resolve().parent
sys.path.append(str(current_dir))


def main():
"""Universal update script that handles both base and main updates in a single run.
Usage:
update_pyproject_combined.py main <main_tag> <base_tag>
"""
arg_count = 4
if len(sys.argv) != arg_count:
print("Usage:")
print(" update_pyproject_combined.py main <main_tag> <base_tag>")
sys.exit(1)

mode = sys.argv[1]
if mode != "main":
print("Only 'main' mode is supported")
print("Usage: update_pyproject_combined.py main <main_tag> <base_tag>")
sys.exit(1)

main_tag = sys.argv[2]
base_tag = sys.argv[3]

# First handle base package updates
update_pyproject_name("src/backend/base/pyproject.toml", "langflow-base-nightly")
update_name_uv_dep("pyproject.toml", "langflow-base-nightly")
update_pyproject_version("src/backend/base/pyproject.toml", base_tag)

# Then handle main package updates
update_pyproject_name("pyproject.toml", "langflow-nightly")
update_name_uv_dep("pyproject.toml", "langflow-nightly")
update_pyproject_version("pyproject.toml", main_tag)
# Update dependency version (strip 'v' prefix if present)
base_version = base_tag.lstrip("v")
update_version_uv_dep(base_version)


if __name__ == "__main__":
main()
6 changes: 3 additions & 3 deletions src/backend/base/langflow/api/v1/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ async def build_vertices(
client_consumed_queue: asyncio.Queue,
event_manager: EventManager,
) -> None:
build_task = asyncio.create_task(asyncio.to_thread(asyncio.run, _build_vertex(vertex_id, graph, event_manager)))
build_task = asyncio.create_task(_build_vertex(vertex_id, graph, event_manager))
try:
await build_task
except asyncio.CancelledError as exc:
Expand Down Expand Up @@ -361,8 +361,8 @@ async def build_vertices(

async def event_generator(event_manager: EventManager, client_consumed_queue: asyncio.Queue) -> None:
if not data:
# using another thread since the DB query is I/O bound
vertices_task = asyncio.create_task(asyncio.to_thread(asyncio.run, build_graph_and_get_order()))
# using another task since the build_graph_and_get_order is now an async function
vertices_task = asyncio.create_task(build_graph_and_get_order())
try:
await vertices_task
except asyncio.CancelledError:
Expand Down
2 changes: 1 addition & 1 deletion src/backend/base/langflow/api/v1/folders.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ async def delete_folder(
current_user: CurrentActiveUser,
):
try:
flows = session.exec(select(Flow).where(Flow.folder_id == folder_id, Folder.user_id == current_user.id)).all()
flows = session.exec(select(Flow).where(Flow.folder_id == folder_id, Flow.user_id == current_user.id)).all()
if len(flows) > 0:
for flow in flows:
await cascade_delete_flow(session, flow)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class GetEnvVar(Component):
display_name = "Get env var"
description = "Get env var"
icon = "custom_components"
icon = "code"

inputs = [
StrInput(
Expand Down
2 changes: 1 addition & 1 deletion src/backend/base/langflow/components/data/api_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class APIRequestComponent(Component):
),
MessageTextInput(
name="curl",
display_name="Curl",
display_name="cURL",
info="Paste a curl command to populate the fields. "
"This will fill in the dictionary fields for headers and body.",
advanced=False,
Expand Down
2 changes: 1 addition & 1 deletion src/backend/base/langflow/components/data/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class FileComponent(Component):
display_name = "File"
description = "A generic file loader."
description = "Load a file to be used in your project."
icon = "file-text"
name = "File"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
from .aiml import AIMLEmbeddingsImpl
import warnings

from langchain_core._api.deprecation import LangChainDeprecationWarning

with warnings.catch_warnings():
warnings.simplefilter("ignore", LangChainDeprecationWarning)
from .aiml import AIMLEmbeddingsImpl


__all__ = ["AIMLEmbeddingsImpl"]
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class CustomComponent(Component):
display_name = "Custom Component"
description = "Use as a template to create your own component."
documentation: str = "http://docs.langflow.org/components/custom"
icon = "custom_components"
icon = "code"
name = "CustomComponent"

inputs = [
Expand Down
2 changes: 1 addition & 1 deletion src/backend/base/langflow/components/inputs/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class ChatInput(ChatComponent):
display_name = "Chat Input"
description = "Get chat inputs from the Playground."
icon = "ChatInput"
icon = "MessagesSquare"
name = "ChatInput"

inputs = [
Expand Down
2 changes: 1 addition & 1 deletion src/backend/base/langflow/components/outputs/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class ChatOutput(ChatComponent):
display_name = "Chat Output"
description = "Display a chat message in the Playground."
icon = "ChatOutput"
icon = "MessagesSquare"
name = "ChatOutput"

inputs = [
Expand Down
11 changes: 9 additions & 2 deletions src/backend/base/langflow/components/tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from .astradb import AstraDBToolComponent
from .astradb_cql import AstraDBCQLToolComponent
import warnings

from langchain_core._api.deprecation import LangChainDeprecationWarning

from .bing_search_api import BingSearchAPIComponent
from .calculator import CalculatorToolComponent
from .duck_duck_go_search_run import DuckDuckGoSearchComponent
Expand All @@ -17,6 +19,11 @@
from .wolfram_alpha_api import WolframAlphaAPIComponent
from .yahoo_finance import YfinanceToolComponent

with warnings.catch_warnings():
warnings.simplefilter("ignore", LangChainDeprecationWarning)
from .astradb import AstraDBToolComponent
from .astradb_cql import AstraDBCQLToolComponent

__all__ = [
"AstraDBCQLToolComponent",
"AstraDBToolComponent",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,16 @@ def read_file_content(self, file_path):
_file_path = Path(file_path)
if not _file_path.is_file():
return None
with _file_path.open(encoding="utf-8") as file:
# UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 3069: character maps to <undefined>
try:
try:
with _file_path.open(encoding="utf-8") as file:
# UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 3069:
# character maps to <undefined>
return file.read()
except UnicodeDecodeError:
# This is happening in Windows, so we need to open the file in binary mode
# The file is always just a python file, so we can safely read it as utf-8
with _file_path.open("rb") as f:
return f.read().decode("utf-8")
except UnicodeDecodeError:
# This is happening in Windows, so we need to open the file in binary mode
# The file is always just a python file, so we can safely read it as utf-8
with _file_path.open("rb") as f:
return f.read().decode("utf-8")

def get_files(self):
"""Walk through the directory path and return a list of all .py files."""
Expand Down
Loading

0 comments on commit 74ff94a

Please sign in to comment.