From dded85df309aabab0032ccd343ed03a7f18b7e9c Mon Sep 17 00:00:00 2001 From: Vraj Mehalana Date: Mon, 1 Jun 2026 15:38:49 -0700 Subject: [PATCH] chore(webui): migrate startup scripts to uv --- webui/run.py | 24 +++++++++++++++++++----- webui/start.sh | 30 +++++++++++++++++++----------- 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/webui/run.py b/webui/run.py index 64a7b167..50bb3f7e 100644 --- a/webui/run.py +++ b/webui/run.py @@ -21,14 +21,23 @@ def check_dependencies(): return True except ImportError as e: print(f"❌ Missing dependency: {e}") - print("Please run: pip install -r requirements.txt") + print("Please run: uv pip install -r requirements.txt") + return False + + +def check_uv_installed(): + """Check if uv package manager is available.""" + try: + subprocess.check_call(["uv", "--version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + return True + except (subprocess.CalledProcessError, FileNotFoundError): return False def install_dependencies(): - """Install dependencies""" - print("Installing dependencies...") + """Install dependencies with uv.""" + print("Installing dependencies with uv...") try: - subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"]) + subprocess.check_call(["uv", "pip", "install", "-r", "requirements.txt"]) print("✅ Dependencies installation completed") return True except subprocess.CalledProcessError: @@ -39,6 +48,11 @@ def main(): """Main function""" print("🚀 Starting Kronos Web UI...") print("=" * 50) + + if not check_uv_installed(): + print("❌ uv is not installed.") + print("Install uv first: https://docs.astral.sh/uv/getting-started/installation/") + return # Check dependencies if not check_dependencies(): @@ -47,7 +61,7 @@ def main(): if not install_dependencies(): return else: - print("Please manually install dependencies and retry") + print("Please manually install dependencies with uv and retry") return # Check model availability diff --git a/webui/start.sh b/webui/start.sh index 0d832b37..49f8649a 100755 --- a/webui/start.sh +++ b/webui/start.sh @@ -5,9 +5,10 @@ echo "🚀 Starting Kronos Web UI..." echo "================================" -# Check if Python is installed -if ! command -v python3 &> /dev/null; then - echo "❌ Python3 not installed, please install Python3 first" +# Check if uv is installed +if ! command -v uv &> /dev/null; then + echo "❌ uv is not installed. Please install uv first:" + echo " https://docs.astral.sh/uv/getting-started/installation/" exit 1 fi @@ -19,22 +20,29 @@ fi # Check dependencies echo "📦 Checking dependencies..." -if ! python3 -c "import flask, flask_cors, pandas, numpy, plotly" &> /dev/null; then - echo "⚠️ Missing dependencies, installing..." - pip3 install -r requirements.txt + +# Create local virtual environment if it does not exist +if [ ! -d ".venv" ]; then + echo "🛠️ Creating virtual environment with uv..." + uv venv if [ $? -ne 0 ]; then - echo "❌ Dependencies installation failed" + echo "❌ Failed to create virtual environment" exit 1 fi - echo "✅ Dependencies installation completed" -else - echo "✅ All dependencies installed" fi +echo "⚠️ Syncing dependencies with uv..." +uv pip install -r requirements.txt +if [ $? -ne 0 ]; then + echo "❌ Dependencies installation failed" + exit 1 +fi +echo "✅ Dependencies installation completed" + # Start application echo "🌐 Starting Web server..." echo "Access URL: http://localhost:7070" echo "Press Ctrl+C to stop server" echo "" -python3 app.py +uv run app.py