Skip to content

Commit

Permalink
Merge branch 'main' into feat/merge-data-standard-operations
Browse files Browse the repository at this point in the history
  • Loading branch information
ogabrielluiz authored Dec 19, 2024
2 parents 7c6eec2 + e657e9d commit 45af753
Show file tree
Hide file tree
Showing 645 changed files with 31,196 additions and 20,472 deletions.
64 changes: 35 additions & 29 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
# Source: https://github.com/a5chin/python-uv
FROM debian:bookworm-slim AS builder

ENV CARGO_HOME="/opt/.cargo"

SHELL [ "/bin/bash", "-o", "pipefail", "-c" ]

WORKDIR /opt

# The installer requires curl (and certificates) to download the release archive
# hadolint ignore=DL3008
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates curl

# Run uv installer
RUN curl -LsSf https://astral.sh/uv/install.sh | sh


FROM mcr.microsoft.com/vscode/devcontainers/base:bookworm


ENV CARGO_HOME="/opt/.cargo"
ENV PATH="$CARGO_HOME/bin/:$PATH"
ENV PYTHONUNBUFFERED=True
ENV UV_LINK_MODE=copy

WORKDIR /opt

COPY --from=builder --chown=vscode: $CARGO_HOME $CARGO_HOME
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim

# Set timezone
ENV TZ=UTC

# Set up work directory
WORKDIR /workspace

# Install additional dev dependencies
RUN apt-get update && apt-get install -y \
zsh \
curl \
git \
build-essential \
npm \
lsof \
procps \
vim \
less \
net-tools \
sudo \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# Create the vscode user and group with the expected UID and GID (1000)
RUN groupadd -g 1000 langflow && \
useradd -m -u 1000 -g 1000 -s /bin/zsh langflow && \
echo "langflow ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

# Set default shell to Zsh
SHELL ["/bin/zsh", "-c"]

RUN echo 'export PS1="%~ %# "' >> /home/langflow/.zshrc

# Set the default user
USER langflow
60 changes: 60 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Langflow Demo Codespace Readme

These instructions will walk you through the process of running a Langflow demo via GitHub Codespaces.

If you want a faster and easier demo experience with Langflow, DataStax Langflow is a hosted environment with zero setup: [Sign up for a free account.](https://astra.datastax.com/signup?type=langflow)

## Create a Codespace in GitHub

To setup the demo in Codespace:

1. Navigate to the Langflow repo
2. On the "Code <>" button, select the "Codespaces" tab
3. Click the green "Create codespace on..." button (or "+" icon if you want more options) to create a new Codespace

## Wait for everything to install

After the codespace is opened, there will be two phases to the process. It will take ≈5-10 minutes to complete.

* **Phase 1**: Building Container; you can click on the "Building Codespace" link to watch the logs
* **Phase 2**: Building Langflow; the terminal will now show `Running postCreateCommand...`, similar to:

```
✔ Finishing up...
⠸ Running postCreateCommand...
› sudo chown -R langflow .venv .mypy_cache src/frontend/node_modules src/frontend/build src/backend/base/langflow/frontend && make install_frontend && mak…
```

Once completed, this terminal window will close.

You now need to manually build the frontend. Open a new Terminal and run command:

```bash
make build_frontend
```

This will take a short period of time, you should have a message similar to `Building frontend static files` and the command will complete successfully.

Installation is now complete.

## Start up the Service

Open a new Terminal, and type `uv run langflow run`.

The service will start, and you will may notice a dialog in the lower right indicating there is a port available to connect to. However, the service will not be ready until you see the welcome banner:

```
╭───────────────────────────────────────────────────────────────────╮
│ Welcome to ⛓ Langflow │
│ │
│ │
│ Collaborate, and contribute at our GitHub Repo 🌟 │
│ │
│ We collect anonymous usage data to improve Langflow. │
│ You can opt-out by setting DO_NOT_TRACK=true in your environment. │
│ │
│ Access http://127.0.0.1:7860 │
╰───────────────────────────────────────────────────────────────────╯
```

At this point you can connect to the service via the port, or if the dialog is gone you can find the "Forwarded Address" on the "Ports" tab (which is next the "Terminal" tab). If there is no port forwarded, you can click the "Forward a Port" button on the "Ports" tab, and forward `7860`.
15 changes: 0 additions & 15 deletions .devcontainer/demo/README.md

This file was deleted.

33 changes: 0 additions & 33 deletions .devcontainer/demo/devcontainer.json

This file was deleted.

61 changes: 45 additions & 16 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/universal
{
"name": "Langflow Dev Container",
"build": {
"context": "..",
"dockerfile": "Dockerfile"
},
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/node": {},
"ghcr.io/dhoeric/features/hadolint:1": {}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "make install_frontend && make install_backend",
"postStartCommand": "make init",

// Configure tool-specific properties.
"postCreateCommand": "sudo chown -R langflow .venv .mypy_cache src/frontend/node_modules src/frontend/build src/backend/base/langflow/frontend && make install_frontend && make install_backend",
"customizations": {
"vscode": {
"extensions": [
Expand All @@ -44,8 +33,48 @@
}
}
},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
"remoteUser": "vscode"
"remoteUser": "langflow",
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind",
"workspaceFolder": "/workspace",
"forwardPorts": [7860, 3000],
"containerEnv": {
"FRONTEND_START_FLAGS": "--host"
},
"mounts": [
{
"source": "${localWorkspaceFolderBasename}-frontend-node_modules",
"target": "/workspace/src/frontend/node_modules",
"type": "volume"
},
{
"source": "${localWorkspaceFolderBasename}-frontend-build",
"target": "/workspace/src/frontend/build",
"type": "volume"
},
{
"source": "${localWorkspaceFolderBasename}-backend-frontend",
"target": "/workspace/src/backend/base/langflow/frontend",
"type": "volume"
},
{
"source": "${localWorkspaceFolderBasename}-venv",
"target": "/workspace/.venv",
"type": "volume"
},
{
"source": "${localWorkspaceFolderBasename}-mypy-cache",
"target": "/workspace/.mypy_cache",
"type": "volume"
},
{
"source": "${localWorkspaceFolderBasename}-dist",
"target": "/workspace/dist",
"type": "volume"
},
{
"source": "${localWorkspaceFolderBasename}-backend-dist",
"target": "/workspace/src/backend/base/dist",
"type": "volume"
}
]
}
7 changes: 6 additions & 1 deletion .github/actions/setup-uv/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: "Setup uv"
description: "Checks out code, installs uv, and sets up Python environment"

inputs:
python-version:
description: "Python version to use"
default: "3.12"

runs:
using: "composite"
steps:
Expand All @@ -13,7 +18,7 @@ runs:
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
python-version: ${{ inputs.python-version }}

- name: Restore uv cache
uses: actions/cache@v4
Expand Down
7 changes: 6 additions & 1 deletion .github/changes-filter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ python:
- "src/backend/**"
- "src/backend/**.py"
- "pyproject.toml"
- "poetry.lock"
- "uv.lock"
- "src/backend/base/pyproject.toml"
- "src/backend/base/uv.lock"
- "**/python_test.yml"
components-changes:
- "src/backend/base/langflow/components/**"
Expand All @@ -20,6 +22,9 @@ docs:
# Test categories and their associated paths
starter-projects:
- "src/backend/base/langflow/initial_setup/**"
- "src/backend/base/langflow/components/**"
- "src/backend/base/langflow/services/**"
- "src/backend/base/langflow/custom/**"
- "src/frontend/src/pages/MainPage/**"
- "src/frontend/src/utils/reactflowUtils.ts"
- "src/frontend/tests/extended/features/**"
Expand Down
37 changes: 35 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,56 @@ on:
default: "['3.10']"
pull_request:
types: [synchronize, labeled]

merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
check-nightly-status:
name: Check Nightly Status
runs-on: ubuntu-latest
outputs:
should-proceed: ${{ steps.check-workflow.outputs.success }}
steps:
- name: Check nightly workflow status
id: check-workflow
uses: actions/github-script@v7
with:
script: |
const workflow_name = 'nightly_build.yml';
const { data: runs } = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: workflow_name,
per_page: 1,
status: 'completed'
});
if (runs.workflow_runs.length === 0) {
console.log('No completed workflow runs found');
return core.setOutput('success', 'true');
}
const lastRun = runs.workflow_runs[0];
const success = lastRun.conclusion === 'success';
console.log(`Last nightly build status: ${lastRun.conclusion}`);
core.setOutput('success', success.toString());
set-ci-condition:
needs: check-nightly-status
name: Should Run CI
runs-on: ubuntu-latest
outputs:
should-run-ci: ${{ (contains( github.event.pull_request.labels.*.name, 'lgtm') && github.event.pull_request.draft == false) || (github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call') }}
should-run-ci: ${{ (needs.check-nightly-status.outputs.should-proceed == 'true' || github.event_name == 'workflow_dispatch') && ((contains( github.event.pull_request.labels.*.name, 'lgtm') && github.event.pull_request.draft == false) || (github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' || github.event_name == 'merge_group')) }}
steps:
# Do anything just to make the job run
- run: echo "Debug CI Condition"
- run: echo "Labels -> ${{ join(github.event.pull_request.labels.*.name, ',') }}"
- run: echo "IsDraft -> ${{ github.event.pull_request.draft }}"
- run: echo "Event name -> ${{ github.event_name }}"
- run: echo "Nightly build status -> ${{ needs.check-nightly-status.outputs.should-proceed }}"

path-filter:
needs: set-ci-condition
if: ${{ needs.set-ci-condition.outputs.should-run-ci == 'true' }}
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/codeflash.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Codeflash

on:
pull_request:
paths:
- "src/backend/base/langflow/**"
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
optimize:
name: Optimize new Python code in this PR
if: ${{ github.actor != 'codeflash-ai[bot]' }}
runs-on: ubuntu-latest
env:
CODEFLASH_API_KEY: ${{ secrets.CODEFLASH_API_KEY }}
CODEFLASH_PR_NUMBER: ${{ github.event.number }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: astral-sh/setup-uv@v4
with:
enable-cache: true
python-version: "3.12"
- run: uv sync --extra dev
- name: Run Codeflash Optimizer
working-directory: ./src/backend/base
run: uv run codeflash
- name: Minimize uv cache
run: uv cache prune --ci
Loading

0 comments on commit 45af753

Please sign in to comment.