-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_app.ps1
More file actions
46 lines (37 loc) · 1.11 KB
/
run_app.ps1
File metadata and controls
46 lines (37 loc) · 1.11 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
Param(
[string]$EnvName = "llm-chat",
[switch]$SkipDeps,
[switch]$SkipEnvUpdate
)
$ErrorActionPreference = "Stop"
# Always run relative to the script location so conda sees the right files.
Set-Location -Path (Split-Path -Path $MyInvocation.MyCommand.Path -Parent)
function Invoke-Conda {
param(
[string]$Args
)
Write-Host ">> conda $Args"
conda $Args
}
function Invoke-CondaRun {
param(
[string]$Args
)
Write-Host ">> conda run -n $EnvName $Args"
conda run -n $EnvName $Args
}
if (-not $SkipEnvUpdate) {
Write-Host "Ensuring conda environment '$EnvName' is up to date..."
try {
Invoke-Conda "env update -n `"$EnvName`" -f environment.yml --prune"
} catch {
Write-Host "Env update failed; attempting to create '$EnvName'..."
Invoke-Conda "env create -n `"$EnvName`" -f environment.yml"
}
}
if (-not $SkipDeps) {
Write-Host "Installing pip requirements into '$EnvName'..."
Invoke-CondaRun "pip install -r requirements.txt"
}
Write-Host "Launching Streamlit app..."
Invoke-CondaRun "streamlit run app/streamlit_app.py"