-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.ps1
More file actions
102 lines (88 loc) · 3.87 KB
/
Copy pathsetup.ps1
File metadata and controls
102 lines (88 loc) · 3.87 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
# SatQuery AI - one-command setup for Windows PowerShell.
# Creates a virtual environment, installs the dependencies, copies the
# environment template to .env with a back-end that works with no GPU,
# and prints exactly what to run next.
$ErrorActionPreference = "Stop"
Set-Location $PSScriptRoot
Write-Host "==> SatQuery AI setup"
# --- Check Python (3.10+ required) ---
$pyCmd = $null
foreach ($candidate in @("python", "py")) {
if (Get-Command $candidate -ErrorAction SilentlyContinue) { $pyCmd = $candidate; break }
}
if (-not $pyCmd) {
Write-Error "Python was not found on PATH.`nInstall Python 3.10 or newer (https://www.python.org/downloads/) and re-run this script."
}
# The 'py' launcher needs its own -3 flag to pick Python 3.
function Invoke-Py {
if ($pyCmd -eq "py") { & py -3 @args } else { & python @args }
}
Invoke-Py -c "import sys; exit(0 if sys.version_info >= (3,10) else 1)"
if ($LASTEXITCODE -ne 0) {
$pyver = Invoke-Py -c "import sys; print('%d.%d' % sys.version_info[:2])"
Write-Error "Python $pyver found, but 3.10+ is required."
}
Write-Host "Python: $(Invoke-Py --version)"
# --- Virtual environment ---
if (-not (Test-Path ".venv")) {
Write-Host "Creating virtual environment .venv ..."
Invoke-Py -m venv .venv
if ($LASTEXITCODE -ne 0) { Write-Error "Could not create the virtual environment." }
} else {
Write-Host "Virtual environment .venv already exists - reusing it."
}
$pyexe = ".\.venv\Scripts\python.exe"
# --- Dependencies (main requirements; the model weights are NOT included) ---
Write-Host "Installing dependencies from requirements.txt (this can take a few minutes) ..."
& $pyexe -m pip install --quiet --upgrade pip
if ($LASTEXITCODE -ne 0) { Write-Error "pip upgrade failed." }
& $pyexe -m pip install --quiet -r requirements.txt
if ($LASTEXITCODE -ne 0) { Write-Error "Dependency installation failed." }
# --- Environment file ---
if (Test-Path ".env") {
Write-Host "Existing .env kept untouched."
} else {
Copy-Item .env.example .env
# 'stub' answers queries with deterministic canned outputs and no model
# weights, so the app runs immediately on a laptop with no GPU. The
# README's Colab section explains how to switch to the real model.
$content = Get-Content .env -Raw
$content = $content -replace "(?m)^MODEL_BACKEND=local\s*$", "MODEL_BACKEND=stub"
Set-Content .env $content -NoNewline
Write-Host "Created .env from .env.example (MODEL_BACKEND set to 'stub' for the first run)."
}
# --- Sanity check: the agent stack imports ---
Write-Host "Verifying the installation (import check) ..."
& $pyexe -c "from agent.planner import AgentController"
if ($LASTEXITCODE -ne 0) {
Write-Error "Import check failed - see the messages above."
}
$banner = @"
============================================================
Setup complete.
To start the app:
.\.venv\Scripts\Activate.ps1
streamlit run app/frontend/app.py
...then open http://localhost:8501 in a browser.
Or run the browser app (README "Setup 1b"): in a second terminal,
cd app/frontend-web; npm install; npm run dev
...then open http://localhost:3000 (API on port 8000):
.\.venv\Scripts\Activate.ps1
uvicorn app.webapi.server:app --port 8000
The first run uses MODEL_BACKEND=stub: every query returns a
deterministic, clearly-labelled canned answer while the back-end
switch keeps working, so you can explore the whole interface with
no GPU. To run the real remote-sensing model:
1. Open the free Colab notebook - follow the section
"Run the model backend on Colab" in README.md
2. Copy the tunnel URL it prints
3. In .env set:
MODEL_BACKEND=remote
SATQUERY_REMOTE_URL=<the tunnel URL>
4. Restart the app.
Useful extras:
pytest tests -q run the test suite
docs/DEMO.md demo script for the five queries
============================================================
"@
Write-Host $banner