File size: 1,431 Bytes
0109502
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Run this once (whenever you sit down to run it - daily, every few days,
# whatever works) to process the NEXT batch of rows. It always resumes from
# wherever the last run left off, so running this once a day for a few weeks
# is exactly the intended usage. It's also fine to interrupt with Ctrl+C -
# see README "Stopping and recovering" section.
#
# Usage:
#   scripts\run_daily.ps1                    # dry run, 500 rows (safe default)
#   scripts\run_daily.ps1 -Real               # real run (spends NIM API requests), 500 rows
#   scripts\run_daily.ps1 -Real -Limit 200    # real run, 200 rows this session

param(
    [switch]$Real,
    [int]$Limit = 500
)

$ErrorActionPreference = "Stop"

$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$ProjectDir = Split-Path -Parent $ScriptDir
Set-Location $ProjectDir

if (-not (Test-Path ".venv")) {
    Write-Host "No .venv\ found - run scripts\setup.ps1 first."
    exit 1
}

& .\.venv\Scripts\Activate.ps1

# Keep dependencies in sync with requirements.txt automatically. Fast when
# already installed; never touches anything outside .venv\.
pip install --quiet -r requirements.txt

Write-Host "Running: python main.py --limit $Limit $(if (-not $Real) {'--dry-run'})"
Write-Host "(Ctrl+C once = finish current record, save progress, stop cleanly.)"
Write-Host ""

if ($Real) {
    python main.py --limit $Limit
} else {
    python main.py --limit $Limit --dry-run
}