-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.ps1
More file actions
78 lines (67 loc) · 3.09 KB
/
setup.ps1
File metadata and controls
78 lines (67 loc) · 3.09 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
# setup.ps1 - Automated environment setup for SpatialTranscriptFormer
$ErrorActionPreference = 'Stop'
Write-Host "--- SpatialTranscriptFormer Setup ---" -ForegroundColor Cyan
$EnvName = "SpatialTranscriptFormer"
# Check if conda exists
try {
conda --version | Out-Null
}
catch {
Write-Error "Conda was not found. Please ensure Conda is installed and added to your PATH."
exit 1
}
# Check if conda environment exists
$CondaEnv = conda env list | Select-String $EnvName
if ($null -eq $CondaEnv) {
Write-Host "Creating conda environment '$EnvName' with Python 3.9..." -ForegroundColor Yellow
conda create -n $EnvName python=3.9 -y
}
else {
Write-Host "Conda environment '$EnvName' already exists." -ForegroundColor Green
}
Write-Host "Installing PyTorch (CUDA 11.8)..." -ForegroundColor Yellow
conda run -n $EnvName pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to install PyTorch."
exit $LASTEXITCODE
}
Write-Host "Installing/Updating package in editable mode..." -ForegroundColor Yellow
conda run -n $EnvName pip install -e .[dev]
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to install SpatialTranscriptFormer."
exit $LASTEXITCODE
}
Write-Host "Checking Hugging Face authentication..." -ForegroundColor Yellow
$HFLoginStatus = conda run -n $EnvName huggingface-cli whoami 2>&1
if ($LASTEXITCODE -ne 0 -or $HFLoginStatus -match "Not logged in") {
$HFNeedLogin = $true
}
else {
$HFNeedLogin = $false
Write-Host "Hugging Face authentication found: $HFLoginStatus" -ForegroundColor Green
}
Write-Host ""
Write-Host "=========================================" -ForegroundColor Green
Write-Host " SETUP COMPLETE! " -ForegroundColor Green
Write-Host "=========================================" -ForegroundColor Green
Write-Host ""
Write-Host "IMPORTANT: You must activate the environment before using the tools:" -ForegroundColor Yellow
Write-Host " conda activate $EnvName" -ForegroundColor Cyan
Write-Host ""
if ($HFNeedLogin) {
Write-Host "------------------------------------------------------------" -ForegroundColor DarkYellow
Write-Host "DATASET ACCESS REQUIRES AUTHENTICATION" -ForegroundColor Red
Write-Host "The HEST-1k dataset on Hugging Face is gated. You must provide an access token." -ForegroundColor DarkYellow
Write-Host "Please do ONE of the following before downloading data:"
Write-Host " Option A (Persistent): Run 'conda run -n $EnvName huggingface-cli login' and paste your token."
Write-Host " Option B (Temporary): Set the 'HF_TOKEN' environment variable."
Write-Host "Get your token from: https://huggingface.co/settings/tokens" -ForegroundColor DarkCyan
Write-Host "------------------------------------------------------------" -ForegroundColor DarkYellow
Write-Host ""
}
Write-Host "You can then use the following commands:"
Write-Host " stf-download --help"
Write-Host " stf-split --help"
Write-Host " stf-build-vocab --help"
Write-Host ""
Write-Host "To run tests, use: .\test.ps1"