-
Notifications
You must be signed in to change notification settings - Fork 8.2k
feat: Add Windows build and run automation scripts #8861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…copy build files to backend, and run Langflow 🔧 (build_and_run.ps1): Add a Windows PowerShell script to build frontend, copy build files to backend, and run Langflow
…er clarity and consistency 📝 scripts/windows/build_and_run.ps1: update script steps numbering and messages for consistency and clarity
…un before opening the browser 📝 (build_and_run.ps1): Add attention message to wait for uvicorn to run before opening the browser
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughTwo new automation scripts for Windows, Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Script (BAT/PS1)
participant Frontend Dir
participant Backend Dir
participant Backend Server
User->>Script (BAT/PS1): Run script
Script (BAT/PS1)->>Frontend Dir: npm install
Script (BAT/PS1)->>Frontend Dir: npm run build
Script (BAT/PS1)->>Frontend Dir: Check for build/dist
Script (BAT/PS1)->>Backend Dir: Clean existing frontend assets
Script (BAT/PS1)->>Backend Dir: Copy new build files
Script (BAT/PS1)->>Backend Server: uv run langflow run
Backend Server-->>User: Server running, ready for browser access
✨ Finishing Touches🧪 Generate Unit Tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Nitpick comments (3)
scripts/windows/build_and_run.ps1 (1)
8-8: Consider using absolute paths for more robust navigation.Using relative paths like
..\..\src\frontendassumes the script is run from a specific location (scripts/windows/). If users run this script from a different directory, it will fail.Consider using the script's location as a reference point:
- Set-Location "..\..\src\frontend" + $scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition + $frontendDir = Join-Path $scriptDir "..\..\src\frontend" + Set-Location $frontendDirscripts/windows/build_and_run.bat (2)
6-11: Consider using pushd/popd for directory navigation.Using
cdwith relative paths can fail if the current directory structure is unexpected. The batch script has the same path robustness issue as the PowerShell script.Consider using
pushdandpopdfor more robust directory handling:-cd ..\..\src\frontend -if errorlevel 1 ( - echo Error: Could not navigate to src\frontend directory - pause - exit /b 1 -) +pushd "%~dp0..\..\src\frontend" +if errorlevel 1 ( + echo Error: Could not navigate to src\frontend directory + pause + exit /b 1 +)
33-33: Missing popd to return to original directory.If using
pushdas suggested earlier, you should addpopdto return to the original directory after the frontend build steps.Add
popdafter the frontend build:echo Running npm run build... call npm run build if errorlevel 1 ( echo Error: npm run build failed pause exit /b 1 ) +popd echo. echo Step 3: Copying build files to backend... -cd ..\..
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
scripts/windows/build_and_run.bat(1 hunks)scripts/windows/build_and_run.ps1(1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-06-30T14:40:29.494Z
Learning: Frontend builds must output static files to 'src/frontend/dist/' for production deployment.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-06-23T12:46:42.048Z
Learning: Frontend builds must be performed using Vite, with production output placed in the dist/ directory and served by the backend in production environments.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.428Z
Learning: Applies to Makefile : Use Makefile targets (make backend, make format_backend, make lint, make unit_tests) for backend development workflows
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/docs_development.mdc:0-0
Timestamp: 2025-06-23T12:46:29.953Z
Learning: The documentation site is built and served locally using 'yarn build' and 'yarn serve', and is automatically deployed on commit to the main branch.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-06-23T12:46:42.048Z
Learning: Frontend code must be formatted using the make format_frontend command and linted with make lint before committing changes.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/docs_development.mdc:0-0
Timestamp: 2025-06-30T14:40:02.667Z
Learning: Documentation is automatically deployed on commit to the main branch; build artifacts are output to the 'build/' directory.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/docs_development.mdc:0-0
Timestamp: 2025-06-30T14:40:02.667Z
Learning: Documentation must build successfully with 'yarn build' before deployment.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-06-30T14:40:29.494Z
Learning: All frontend code must be formatted using the 'make format_frontend' command.
scripts/windows/build_and_run.bat (2)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-06-30T14:40:29.494Z
Learning: Frontend builds must output static files to 'src/frontend/dist/' for production deployment.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.428Z
Learning: Starter project files are auto-formatted after langflow run; these changes can be committed or ignored
scripts/windows/build_and_run.ps1 (3)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.428Z
Learning: Starter project files are auto-formatted after langflow run; these changes can be committed or ignored
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-06-30T14:40:29.494Z
Learning: Frontend builds must output static files to 'src/frontend/dist/' for production deployment.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/docs_development.mdc:0-0
Timestamp: 2025-06-30T14:40:02.667Z
Learning: Documentation must build successfully with 'yarn build' before deployment.
🔇 Additional comments (3)
scripts/windows/build_and_run.ps1 (1)
40-46: Build directory detection logic is well-implemented.The script correctly checks for both
buildanddistdirectories, which aligns with the retrieved learnings that indicate frontend builds should output to 'dist/' directory for production deployment.scripts/windows/build_and_run.bat (2)
14-14: Good use of call command for npm.Using
call npm installis correct for batch files to ensure proper command execution and error level propagation.
35-45: Build directory detection logic is well-implemented.The batch script correctly handles both
buildanddistdirectories, matching the PowerShell script's logic and aligning with project conventions.
| Write-Host "`nStep 4: Running Langflow..." -ForegroundColor Yellow | ||
| Write-Host "`nAttention: Wait until uvicorn is running before opening the browser" -ForegroundColor Red | ||
| try { | ||
| uv run langflow run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add error handling for the uv command execution.
The script uses uv run langflow run but doesn't check if uv is available or if the command execution fails properly within the try/catch block.
Add validation for the uv command:
try {
+ # Check if uv is available
+ if (-not (Get-Command uv -ErrorAction SilentlyContinue)) {
+ throw "uv command not found. Please install uv first."
+ }
uv run langflow run
+ if ($LASTEXITCODE -ne 0) {
+ throw "langflow run failed"
+ }
} catch {🤖 Prompt for AI Agents
In scripts/windows/build_and_run.ps1 at line 76, the script runs the command `uv
run langflow run` without checking if the `uv` command exists or if it executes
successfully. To fix this, add a check before running the command to verify that
`uv` is available in the system path, and wrap the command execution in a
try/catch block to handle any errors. If the command fails or `uv` is not found,
output an appropriate error message and exit the script with a failure code.
| # Remove existing files in target directory (FORCES CLEAN REPLACEMENT) | ||
| Write-Host "Removing existing files from target directory..." -ForegroundColor Cyan | ||
| if (Test-Path "$targetDir\*") { | ||
| Remove-Item "$targetDir\*" -Recurse -Force | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Verify the clean replacement strategy.
The script removes all existing files before copying new ones, which is good for ensuring a clean deployment. However, this approach might be risky if the build process fails after cleanup.
Consider whether the cleanup should happen after successful build verification:
🏁 Script executed:
#!/bin/bash
# Check if there are any existing automation scripts or build processes that might conflict
fd -t f -e ps1 -e bat . | head -10Length of output: 104
🏁 Script executed:
#!/bin/bash
# Display context around the cleanup step in the PowerShell script
sed -n '1,200p' scripts/windows/build_and_run.ps1 | sed -n '1,80p'
echo "----"
sed -n '200,300p' scripts/windows/build_and_run.ps1 | sed -n '1,80p'Length of output: 2678
Review the clean replacement strategy
The Remove-Item call is gated behind the successful completion of both the install and build steps, so cleanup won’t occur if the frontend build fails. However, if the copy step itself errors (e.g. disk/permission issues), the target directory will already have been emptied, leaving the backend without any frontend assets.
Suggestions:
- File: scripts/windows/build_and_run.ps1
Location: Step 3 (“Copy build files to backend”), around lines 56–60. - Adopt an atomic replacement pattern:
- Copy the build output to a temporary folder.
- On success, remove or rename the original target.
- Rename the temp folder to the target name.
Example patch:
@@ scripts/windows/build_and_run.ps1
- # Remove existing files in target directory (FORCES CLEAN REPLACEMENT)
- Write-Host "Removing existing files from target directory..." -ForegroundColor Cyan
- if (Test-Path "$targetDir\*") {
- Remove-Item "$targetDir\*" -Recurse -Force
- }
- Copy-Item "$buildDir\*" -Destination $targetDir -Recurse -Force
+ # Atomic replacement: stage in temp then swap on success
+ $tempDir = "${targetDir}-tmp"
+ if (Test-Path $tempDir) { Remove-Item $tempDir -Recurse -Force }
+ Copy-Item "$buildDir\*" -Destination $tempDir -Recurse -Force
+ # Only on successful copy do we replace the live directory
+ if (Test-Path $targetDir) { Remove-Item $targetDir -Recurse -Force }
+ Rename-Item $tempDir $targetDir📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # Remove existing files in target directory (FORCES CLEAN REPLACEMENT) | |
| Write-Host "Removing existing files from target directory..." -ForegroundColor Cyan | |
| if (Test-Path "$targetDir\*") { | |
| Remove-Item "$targetDir\*" -Recurse -Force | |
| } | |
| # Atomic replacement: stage in temp then swap on success | |
| $tempDir = "${targetDir}-tmp" | |
| if (Test-Path $tempDir) { Remove-Item $tempDir -Recurse -Force } | |
| Copy-Item "$buildDir\*" -Destination $tempDir -Recurse -Force | |
| # Only on successful copy do we replace the live directory | |
| if (Test-Path $targetDir) { Remove-Item $targetDir -Recurse -Force } | |
| Rename-Item $tempDir $targetDir |
🤖 Prompt for AI Agents
In scripts/windows/build_and_run.ps1 around lines 56 to 60, the current cleanup
strategy removes existing files from the target directory only after successful
install and build steps, risking an empty target if the copy step fails. To fix
this, implement an atomic replacement pattern by first copying the build output
to a temporary folder, then upon successful copy, remove or rename the original
target directory, and finally rename the temporary folder to the target
directory name. This ensures the target directory is only replaced if the copy
succeeds, preventing partial or empty deployments.
| uv run langflow run | ||
| if errorlevel 1 ( | ||
| echo Error: Failed to run langflow | ||
| pause | ||
| exit /b 1 | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add validation for uv command availability.
Similar to the PowerShell script, the batch script should verify that uv is available before attempting to run it.
Add validation for the uv command:
+REM Check if uv is available
+where uv >nul 2>nul
+if errorlevel 1 (
+ echo Error: uv command not found. Please install uv first.
+ pause
+ exit /b 1
+)
+
uv run langflow run🤖 Prompt for AI Agents
In scripts/windows/build_and_run.bat around lines 75 to 80, the script attempts
to run the `uv` command without checking if it is available, which can cause
unclear errors. Add a validation step before running `uv` to check if the
command exists in the system path. If `uv` is not found, output an error message
and exit the script early to prevent further failures.
| REM Remove existing files in target directory (FORCES CLEAN REPLACEMENT) | ||
| echo Removing existing files from target directory... | ||
| if exist "src\backend\base\langflow\frontend\*" ( | ||
| del /q /s "src\backend\base\langflow\frontend\*" | ||
| for /d %%d in ("src\backend\base\langflow\frontend\*") do rmdir /s /q "%%d" | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
File deletion logic needs improvement.
The file deletion approach might fail if there are locked files or if the directory structure is complex. The PowerShell script's approach is more robust.
Consider improving the cleanup logic:
-if exist "src\backend\base\langflow\frontend\*" (
- del /q /s "src\backend\base\langflow\frontend\*"
- for /d %%d in ("src\backend\base\langflow\frontend\*") do rmdir /s /q "%%d"
-)
+if exist "src\backend\base\langflow\frontend\*" (
+ echo Cleaning target directory...
+ rmdir /s /q "src\backend\base\langflow\frontend" 2>nul
+ mkdir "src\backend\base\langflow\frontend"
+)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| REM Remove existing files in target directory (FORCES CLEAN REPLACEMENT) | |
| echo Removing existing files from target directory... | |
| if exist "src\backend\base\langflow\frontend\*" ( | |
| del /q /s "src\backend\base\langflow\frontend\*" | |
| for /d %%d in ("src\backend\base\langflow\frontend\*") do rmdir /s /q "%%d" | |
| ) | |
| REM Remove existing files in target directory (FORCES CLEAN REPLACEMENT) | |
| echo Removing existing files from target directory... | |
| if exist "src\backend\base\langflow\frontend\*" ( | |
| echo Cleaning target directory... | |
| rmdir /s /q "src\backend\base\langflow\frontend" 2>nul | |
| mkdir "src\backend\base\langflow\frontend" | |
| ) |
🤖 Prompt for AI Agents
In scripts/windows/build_and_run.bat around lines 53 to 58, the current file
deletion logic using del and rmdir may fail with locked files or complex
directory structures. Replace this with a more robust PowerShell command that
forcefully removes all files and directories in the target path, handling locked
files better and ensuring complete cleanup. Use PowerShell's Remove-Item cmdlet
with appropriate flags to recursively and quietly delete all contents in the
frontend directory.
* 🔧 (build_and_run.bat): Add a Windows batch script to build frontend, copy build files to backend, and run Langflow 🔧 (build_and_run.ps1): Add a Windows PowerShell script to build frontend, copy build files to backend, and run Langflow * 📝 scripts/windows/build_and_run.bat: improve script messages for better clarity and consistency 📝 scripts/windows/build_and_run.ps1: update script steps numbering and messages for consistency and clarity * 📝 (build_and_run.bat): Add attention message to wait for uvicorn to run before opening the browser 📝 (build_and_run.ps1): Add attention message to wait for uvicorn to run before opening the browser
This pull request introduces two new scripts for building and running the Langflow application on Windows systems, one written in Batch (
build_and_run.bat) and the other in PowerShell (build_and_run.ps1). These scripts automate the process of installing frontend dependencies, building the frontend, copying build files to the backend, and running the application. The scripts include error handling and user-friendly messages to guide the user through the process.Windows Build and Run Scripts:
Batch Script (
build_and_run.bat):npm install), frontend build (npm run build), copying build files to the backend, and running the application (uv run langflow run).PowerShell Script (
build_and_run.ps1):try/catchblocks.Test-Path,Remove-Item, andCopy-Item.Summary by CodeRabbit