-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathquicksetup.ps1
More file actions
81 lines (70 loc) · 2.64 KB
/
Copy pathquicksetup.ps1
File metadata and controls
81 lines (70 loc) · 2.64 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
# Quick setup script for Windows PowerShell
$VENV_DIR = ".venv"
$PROJECT_FILE = "pyproject.toml"
$DOCKER_COMPOSE_FILE = "docker-compose.yml"
$CHROMA_SERVICE_NAME = "chroma"
Write-Host "==> Checking Python..."
if (-not (Get-Command python -ErrorAction SilentlyContinue)) {
Write-Error "Python not found. Please install Python 3.9+ and re-run."
exit 1
}
Write-Host "==> Creating virtual environment..."
if (-not (Test-Path $VENV_DIR)) {
python -m venv $VENV_DIR
}
Write-Host "==> Activating virtual environment..."
& "$VENV_DIR\Scripts\Activate.ps1"
Write-Host "==> Upgrading pip..."
python -m pip install --upgrade pip wheel
# --- PyTorch build ------------------------------------------------------
# sentence-transformers needs torch, and the default PyPI wheel is the CUDA
# build: about 4 GB of nvidia libraries a machine without a usable GPU will
# never load. Install the chosen build first so pip keeps it when it later
# resolves sentence-transformers.
#
# Override with $env:CLASSMATE_TORCH = "cpu" or "gpu".
$TorchChoice = $env:CLASSMATE_TORCH
if (-not $TorchChoice) { $TorchChoice = "auto" }
if ($TorchChoice -eq "auto") {
if (Get-Command nvidia-smi -ErrorAction SilentlyContinue) {
$TorchChoice = "gpu"
} else {
$TorchChoice = "cpu"
}
}
$TorchReqs = "requirements-$TorchChoice.txt"
if (Test-Path $TorchReqs) {
Write-Host "==> Installing PyTorch ($TorchChoice build)..."
pip install -r $TorchReqs
} else {
Write-Warning "$TorchReqs not found. Letting pip pick a torch build."
}
if (Test-Path $PROJECT_FILE) {
Write-Host "==> Installing CLASSMATE-RAG and its dependencies..."
# Editable install also creates the `rag` console script declared in
# pyproject.toml, so there is no .cmd shim to keep in sync.
pip install -e .
} else {
Write-Warning "$PROJECT_FILE not found. Skipping install."
}
if ((Test-Path ".env.example") -and -not (Test-Path ".env")) {
Write-Host "==> Copying .env.example → .env"
Copy-Item ".env.example" ".env"
}
# --- Start vector DB via Docker ---
if (Get-Command docker -ErrorAction SilentlyContinue) {
if (Test-Path $DOCKER_COMPOSE_FILE) {
Write-Host "==> Starting vector DB via docker compose..."
docker compose up -d $CHROMA_SERVICE_NAME
if ($LASTEXITCODE -ne 0) {
docker compose up -d
}
} else {
Write-Host "NOTE: $DOCKER_COMPOSE_FILE not found. Skipping Docker startup."
}
} else {
Write-Host "NOTE: Docker not installed. Skipping Docker startup."
}
Write-Host "Setup complete."
Write-Host "To activate the venv in future sessions: .\$VENV_DIR\Scripts\Activate.ps1"
Write-Host "Then run: rag --help"