-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup_modal.bat
More file actions
141 lines (122 loc) · 3.95 KB
/
Copy pathsetup_modal.bat
File metadata and controls
141 lines (122 loc) · 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
@echo off
title LLM Workshop - Modal Setup
echo ==================================================
echo MLSA KIIT LLM Deployment Workshop - Modal Setup
echo ==================================================
echo.
:: Install uv
echo.
echo [1/4] Checking for uv (fast Python package manager)...
set "UV_JUST_INSTALLED=0"
:: Check if uv is already installed
uv --version >nul 2>&1
if %errorlevel% equ 0 (
echo [SKIP] uv is already installed.
) else (
echo [INFO] uv not found, attempting installation...
where winget >nul 2>&1
if %errorlevel% equ 0 (
:: Method 1: Attempt installation via winget
echo [1/2] Trying to install uv via winget...
winget install --id=astral-sh.uv -e --accept-source-agreements --accept-package-agreements
if %errorlevel% neq 0 (
echo [WARN] winget installation failed.
:: Method 2: Fallback to Astral's direct PowerShell installer
echo [2/2] Falling back to Astral direct installer...
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
if %errorlevel% neq 0 (
echo [ERROR] Failed to install uv using both winget and PowerShell.
pause
exit /b 1
)
)
) else (
echo [WARN] winget not found. Using Astral direct installer...
:: Method 2: Fallback to Astral's direct PowerShell installer
echo [2/2] Falling back to Astral direct installer...
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
if %errorlevel% neq 0 (
echo [ERROR] Failed to install uv using PowerShell installer.
pause
exit /b 1
)
)
set "UV_JUST_INSTALLED=1"
echo --------------------------------------------------------
echo [OK] uv installation process completed successfully.
echo [REQUIRED] Please RESTART your terminal/command prompt
echo for the 'uv' command to be recognized.
echo --------------------------------------------------------
pause
)
if "%UV_JUST_INSTALLED%"=="1" exit /b 0
:: Init project (creates pyproject.toml + .venv)
echo.
echo [2/4] Initializing project...
if not exist pyproject.toml (
uv init --no-readme
if %errorlevel% neq 0 (
echo [ERROR] Failed to initialize project.
pause
exit /b 1
)
) else (
echo pyproject.toml already exists, skipping init.
)
echo [OK] Project initialized
:: Add Modal
echo.
echo [3/4] Adding Modal dependency...
uv add modal
if %errorlevel% neq 0 (
echo [ERROR] Failed to add Modal.
pause
exit /b 1
)
echo [OK] Modal added
:: Modal auth
echo.
echo [4/4] Authenticating with Modal...
echo A browser window will open — log in to your Modal account.
uv run modal setup
if %errorlevel% neq 0 (
echo [ERROR] Modal setup failed.
pause
exit /b 1
)
echo [OK] Modal authenticated
:: Deploy and capture output
echo.
echo Deploying to Modal (This will take a long time so please wait)...
chcp 65001 >nul 2>&1
set "PYTHONUTF8=1"
set "PYTHONIOENCODING=utf-8"
set "DEPLOY_LOG=%TEMP%\modal_deploy_output.txt"
uv run modal deploy modal_model.py > "%DEPLOY_LOG%" 2>&1
type "%DEPLOY_LOG%"
:: Extract the UI URL (look for .modal.run URLs containing "ui")
set "UI_URL="
for /f "tokens=*" %%A in ('findstr /i "modal.run" "%DEPLOY_LOG%"') do (
for %%U in (%%A) do (
echo %%U | findstr /i "modal.run" >nul
if not errorlevel 1 (
echo %%U | findstr /i "ui" >nul
if not errorlevel 1 set "UI_URL=%%U"
)
)
)
echo.
echo ============================================
echo Deployment complete!
if defined UI_URL (
echo Opening chat UI: %UI_URL%
start "" "%UI_URL%"
) else (
echo Check the URLs printed above.
echo Open the UI URL in your browser.
)
echo.
echo To re-deploy later:
echo uv run modal deploy modal_model.py
echo ============================================
pause